From 64bc5fcd6f34580fce955a9b9bd9f202f56abd36 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Wed, 5 Feb 2020 16:42:29 +0000 Subject: Pull the handshake message transcript code into its own function. This is soon going to be used in the TLSv1.3 client code. ok tb@ --- src/lib/libssl/tls13_handshake.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/lib/libssl/tls13_handshake.c') diff --git a/src/lib/libssl/tls13_handshake.c b/src/lib/libssl/tls13_handshake.c index c850e716e7..677fca3cf3 100644 --- a/src/lib/libssl/tls13_handshake.c +++ b/src/lib/libssl/tls13_handshake.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_handshake.c,v 1.50 2020/02/05 06:12:43 tb Exp $ */ +/* $OpenBSD: tls13_handshake.c,v 1.51 2020/02/05 16:42:29 jsing Exp $ */ /* * Copyright (c) 2018-2019 Theo Buehler * Copyright (c) 2019 Joel Sing @@ -284,6 +284,15 @@ tls13_handshake_advance_state_machine(struct tls13_ctx *ctx) return 1; } +int +tls13_handshake_msg_record(struct tls13_ctx *ctx) +{ + CBS cbs; + + tls13_handshake_msg_data(ctx->hs_msg, &cbs); + return tls1_transcript_record(ctx->ssl, CBS_data(&cbs), CBS_len(&cbs)); +} + int tls13_handshake_perform(struct tls13_ctx *ctx) { @@ -322,7 +331,6 @@ tls13_handshake_send_action(struct tls13_ctx *ctx, { ssize_t ret; CBB cbb; - CBS cbs; /* If we have no handshake message, we need to build one. */ if (ctx->hs_msg == NULL) { @@ -343,8 +351,7 @@ tls13_handshake_send_action(struct tls13_ctx *ctx, if ((ret = tls13_handshake_msg_send(ctx->hs_msg, ctx->rl)) <= 0) return ret; - tls13_handshake_msg_data(ctx->hs_msg, &cbs); - if (!tls1_transcript_record(ctx->ssl, CBS_data(&cbs), CBS_len(&cbs))) + if (!tls13_handshake_msg_record(ctx)) return TLS13_IO_FAILURE; if (action->send_preserve_transcript_hash) { @@ -389,8 +396,7 @@ tls13_handshake_recv_action(struct tls13_ctx *ctx, return TLS13_IO_FAILURE; } - tls13_handshake_msg_data(ctx->hs_msg, &cbs); - if (!tls1_transcript_record(ctx->ssl, CBS_data(&cbs), CBS_len(&cbs))) + if (!tls13_handshake_msg_record(ctx)) return TLS13_IO_FAILURE; if (ctx->handshake_message_recv_cb != NULL) -- cgit v1.2.3-55-g6feb