From 2ea9bc2f2eed516702797aac6d428221092613a3 Mon Sep 17 00:00:00 2001 From: tb <> Date: Wed, 5 Feb 2020 06:12:43 +0000 Subject: Rework tls13_legacy_handshake_message_{recv,sent}_cb() to use their own CBS as a preparation for upcoming HRR diffs. ok jsing --- src/lib/libssl/tls13_handshake.c | 6 +++--- src/lib/libssl/tls13_internal.h | 4 ++-- src/lib/libssl/tls13_lib.c | 28 +++++++++++++++++----------- 3 files changed, 22 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/lib/libssl/tls13_handshake.c b/src/lib/libssl/tls13_handshake.c index 31bd796b93..c850e716e7 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.49 2020/01/29 13:44:42 tb Exp $ */ +/* $OpenBSD: tls13_handshake.c,v 1.50 2020/02/05 06:12:43 tb Exp $ */ /* * Copyright (c) 2018-2019 Theo Buehler * Copyright (c) 2019 Joel Sing @@ -355,7 +355,7 @@ tls13_handshake_send_action(struct tls13_ctx *ctx, } if (ctx->handshake_message_sent_cb != NULL) - ctx->handshake_message_sent_cb(ctx, &cbs); + ctx->handshake_message_sent_cb(ctx); tls13_handshake_msg_free(ctx->hs_msg); ctx->hs_msg = NULL; @@ -394,7 +394,7 @@ tls13_handshake_recv_action(struct tls13_ctx *ctx, return TLS13_IO_FAILURE; if (ctx->handshake_message_recv_cb != NULL) - ctx->handshake_message_recv_cb(ctx, &cbs); + ctx->handshake_message_recv_cb(ctx); /* * In TLSv1.3 there is no way to know if you're going to receive a diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h index 00035ea36e..2c325fe914 100644 --- a/src/lib/libssl/tls13_internal.h +++ b/src/lib/libssl/tls13_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_internal.h,v 1.58 2020/01/30 17:09:23 jsing Exp $ */ +/* $OpenBSD: tls13_internal.h,v 1.59 2020/02/05 06:12:43 tb Exp $ */ /* * Copyright (c) 2018 Bob Beck * Copyright (c) 2018 Theo Buehler @@ -50,7 +50,7 @@ typedef void (*tls13_phh_sent_cb)(void *_cb_arg); typedef ssize_t (*tls13_read_cb)(void *_buf, size_t _buflen, void *_cb_arg); typedef ssize_t (*tls13_write_cb)(const void *_buf, size_t _buflen, void *_cb_arg); -typedef void (*tls13_handshake_message_cb)(void *_cb_arg, CBS *_cbs); +typedef void (*tls13_handshake_message_cb)(void *_cb_arg); /* * Buffers. diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c index 3a90c0d6df..92743ef4b3 100644 --- a/src/lib/libssl/tls13_lib.c +++ b/src/lib/libssl/tls13_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_lib.c,v 1.32 2020/01/29 17:03:58 jsing Exp $ */ +/* $OpenBSD: tls13_lib.c,v 1.33 2020/02/05 06:12:43 tb Exp $ */ /* * Copyright (c) 2018, 2019 Joel Sing * Copyright (c) 2019 Bob Beck @@ -106,27 +106,33 @@ tls13_alert_received_cb(uint8_t alert_desc, void *arg) } static void -tls13_legacy_handshake_message_recv_cb(void *arg, CBS *cbs) +tls13_legacy_handshake_message_recv_cb(void *arg) { struct tls13_ctx *ctx = arg; SSL *s = ctx->ssl; + CBS cbs; - if (s->internal->msg_callback != NULL) - s->internal->msg_callback(0, TLS1_3_VERSION, SSL3_RT_HANDSHAKE, - CBS_data(cbs), CBS_len(cbs), s, - s->internal->msg_callback_arg); + if (s->internal->msg_callback == NULL) + return; + + tls13_handshake_msg_data(ctx->hs_msg, &cbs); + s->internal->msg_callback(0, TLS1_3_VERSION, SSL3_RT_HANDSHAKE, + CBS_data(&cbs), CBS_len(&cbs), s, s->internal->msg_callback_arg); } static void -tls13_legacy_handshake_message_sent_cb(void *arg, CBS *cbs) +tls13_legacy_handshake_message_sent_cb(void *arg) { struct tls13_ctx *ctx = arg; SSL *s = ctx->ssl; + CBS cbs; + + if (s->internal->msg_callback == NULL) + return; - if (s->internal->msg_callback != NULL) - s->internal->msg_callback(1, TLS1_3_VERSION, SSL3_RT_HANDSHAKE, - CBS_data(cbs), CBS_len(cbs), s, - s->internal->msg_callback_arg); + tls13_handshake_msg_data(ctx->hs_msg, &cbs); + s->internal->msg_callback(1, TLS1_3_VERSION, SSL3_RT_HANDSHAKE, + CBS_data(&cbs), CBS_len(&cbs), s, s->internal->msg_callback_arg); } static int -- cgit v1.2.3-55-g6feb