diff options
author | jsing <> | 2020-02-05 16:42:29 +0000 |
---|---|---|
committer | jsing <> | 2020-02-05 16:42:29 +0000 |
commit | 64bc5fcd6f34580fce955a9b9bd9f202f56abd36 (patch) | |
tree | d27a0938ac2171e5add0e24ecda8201f4b926a07 | |
parent | 2ea9bc2f2eed516702797aac6d428221092613a3 (diff) | |
download | openbsd-64bc5fcd6f34580fce955a9b9bd9f202f56abd36.tar.gz openbsd-64bc5fcd6f34580fce955a9b9bd9f202f56abd36.tar.bz2 openbsd-64bc5fcd6f34580fce955a9b9bd9f202f56abd36.zip |
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@
-rw-r--r-- | src/lib/libssl/tls13_handshake.c | 18 | ||||
-rw-r--r-- | src/lib/libssl/tls13_internal.h | 3 |
2 files changed, 14 insertions, 7 deletions
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 @@ | |||
1 | /* $OpenBSD: tls13_handshake.c,v 1.50 2020/02/05 06:12:43 tb Exp $ */ | 1 | /* $OpenBSD: tls13_handshake.c,v 1.51 2020/02/05 16:42:29 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018-2019 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2018-2019 Theo Buehler <tb@openbsd.org> |
4 | * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> | 4 | * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> |
@@ -285,6 +285,15 @@ tls13_handshake_advance_state_machine(struct tls13_ctx *ctx) | |||
285 | } | 285 | } |
286 | 286 | ||
287 | int | 287 | int |
288 | tls13_handshake_msg_record(struct tls13_ctx *ctx) | ||
289 | { | ||
290 | CBS cbs; | ||
291 | |||
292 | tls13_handshake_msg_data(ctx->hs_msg, &cbs); | ||
293 | return tls1_transcript_record(ctx->ssl, CBS_data(&cbs), CBS_len(&cbs)); | ||
294 | } | ||
295 | |||
296 | int | ||
288 | tls13_handshake_perform(struct tls13_ctx *ctx) | 297 | tls13_handshake_perform(struct tls13_ctx *ctx) |
289 | { | 298 | { |
290 | struct tls13_handshake_action *action; | 299 | struct tls13_handshake_action *action; |
@@ -322,7 +331,6 @@ tls13_handshake_send_action(struct tls13_ctx *ctx, | |||
322 | { | 331 | { |
323 | ssize_t ret; | 332 | ssize_t ret; |
324 | CBB cbb; | 333 | CBB cbb; |
325 | CBS cbs; | ||
326 | 334 | ||
327 | /* If we have no handshake message, we need to build one. */ | 335 | /* If we have no handshake message, we need to build one. */ |
328 | if (ctx->hs_msg == NULL) { | 336 | if (ctx->hs_msg == NULL) { |
@@ -343,8 +351,7 @@ tls13_handshake_send_action(struct tls13_ctx *ctx, | |||
343 | if ((ret = tls13_handshake_msg_send(ctx->hs_msg, ctx->rl)) <= 0) | 351 | if ((ret = tls13_handshake_msg_send(ctx->hs_msg, ctx->rl)) <= 0) |
344 | return ret; | 352 | return ret; |
345 | 353 | ||
346 | tls13_handshake_msg_data(ctx->hs_msg, &cbs); | 354 | if (!tls13_handshake_msg_record(ctx)) |
347 | if (!tls1_transcript_record(ctx->ssl, CBS_data(&cbs), CBS_len(&cbs))) | ||
348 | return TLS13_IO_FAILURE; | 355 | return TLS13_IO_FAILURE; |
349 | 356 | ||
350 | if (action->send_preserve_transcript_hash) { | 357 | if (action->send_preserve_transcript_hash) { |
@@ -389,8 +396,7 @@ tls13_handshake_recv_action(struct tls13_ctx *ctx, | |||
389 | return TLS13_IO_FAILURE; | 396 | return TLS13_IO_FAILURE; |
390 | } | 397 | } |
391 | 398 | ||
392 | tls13_handshake_msg_data(ctx->hs_msg, &cbs); | 399 | if (!tls13_handshake_msg_record(ctx)) |
393 | if (!tls1_transcript_record(ctx->ssl, CBS_data(&cbs), CBS_len(&cbs))) | ||
394 | return TLS13_IO_FAILURE; | 400 | return TLS13_IO_FAILURE; |
395 | 401 | ||
396 | if (ctx->handshake_message_recv_cb != NULL) | 402 | if (ctx->handshake_message_recv_cb != NULL) |
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h index 2c325fe914..76b1ebf914 100644 --- a/src/lib/libssl/tls13_internal.h +++ b/src/lib/libssl/tls13_internal.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_internal.h,v 1.59 2020/02/05 06:12:43 tb Exp $ */ | 1 | /* $OpenBSD: tls13_internal.h,v 1.60 2020/02/05 16:42:29 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> |
4 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> |
@@ -287,6 +287,7 @@ int tls13_legacy_shutdown(SSL *ssl); | |||
287 | #define TLS13_MT_KEY_UPDATE 24 | 287 | #define TLS13_MT_KEY_UPDATE 24 |
288 | #define TLS13_MT_MESSAGE_HASH 254 | 288 | #define TLS13_MT_MESSAGE_HASH 254 |
289 | 289 | ||
290 | int tls13_handshake_msg_record(struct tls13_ctx *ctx); | ||
290 | int tls13_handshake_perform(struct tls13_ctx *ctx); | 291 | int tls13_handshake_perform(struct tls13_ctx *ctx); |
291 | 292 | ||
292 | int tls13_client_hello_send(struct tls13_ctx *ctx, CBB *cbb); | 293 | int tls13_client_hello_send(struct tls13_ctx *ctx, CBB *cbb); |