From: jsing Date: Sat, 10 Sep 2022 15:29:33 +0000 (+0000) Subject: Provide a version of ssl_msg_callback() that takes a CBS. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d16eb93aa8930257d783978db8d0a9089ebb9927;p=openbsd Provide a version of ssl_msg_callback() that takes a CBS. Use this from the TLSv1.3 code. ok tb@ --- diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c index c0ca19c7c18..f5f7bf66c1c 100644 --- a/lib/libssl/ssl_lib.c +++ b/lib/libssl/ssl_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_lib.c,v 1.304 2022/08/21 19:42:15 jsing Exp $ */ +/* $OpenBSD: ssl_lib.c,v 1.305 2022/09/10 15:29:33 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -2939,9 +2939,17 @@ void ssl_msg_callback(SSL *s, int is_write, int content_type, const void *msg_buf, size_t msg_len) { - if (s->internal->msg_callback != NULL) - s->internal->msg_callback(is_write, s->version, content_type, - msg_buf, msg_len, s, s->internal->msg_callback_arg); + if (s->internal->msg_callback == NULL) + return; + + s->internal->msg_callback(is_write, s->version, content_type, + msg_buf, msg_len, s, s->internal->msg_callback_arg); +} + +void +ssl_msg_callback_cbs(SSL *s, int is_write, int content_type, CBS *cbs) +{ + ssl_msg_callback(s, is_write, content_type, CBS_data(cbs), CBS_len(cbs)); } /* Fix this function so that it takes an optional type parameter */ diff --git a/lib/libssl/ssl_locl.h b/lib/libssl/ssl_locl.h index fa3a5f9cfd5..a6fc6eaa322 100644 --- a/lib/libssl/ssl_locl.h +++ b/lib/libssl/ssl_locl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_locl.h,v 1.424 2022/08/21 19:39:44 jsing Exp $ */ +/* $OpenBSD: ssl_locl.h,v 1.425 2022/09/10 15:29:33 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1290,6 +1290,7 @@ int ssl_clear_bad_session(SSL *s); void ssl_info_callback(const SSL *s, int type, int value); void ssl_msg_callback(SSL *s, int is_write, int content_type, const void *msg_buf, size_t msg_len); +void ssl_msg_callback_cbs(SSL *s, int is_write, int content_type, CBS *cbs); SSL_CERT *ssl_cert_new(void); SSL_CERT *ssl_cert_dup(SSL_CERT *cert); diff --git a/lib/libssl/tls13_lib.c b/lib/libssl/tls13_lib.c index 57c58a3d305..651c34ca296 100644 --- a/lib/libssl/tls13_lib.c +++ b/lib/libssl/tls13_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_lib.c,v 1.70 2022/07/24 14:28:16 jsing Exp $ */ +/* $OpenBSD: tls13_lib.c,v 1.71 2022/09/10 15:29:33 jsing Exp $ */ /* * Copyright (c) 2018, 2019 Joel Sing * Copyright (c) 2019 Bob Beck @@ -162,7 +162,7 @@ tls13_legacy_handshake_message_recv_cb(void *arg) return; tls13_handshake_msg_data(ctx->hs_msg, &cbs); - ssl_msg_callback(s, 0, SSL3_RT_HANDSHAKE, CBS_data(&cbs), CBS_len(&cbs)); + ssl_msg_callback_cbs(s, 0, SSL3_RT_HANDSHAKE, &cbs); } static void @@ -176,7 +176,7 @@ tls13_legacy_handshake_message_sent_cb(void *arg) return; tls13_handshake_msg_data(ctx->hs_msg, &cbs); - ssl_msg_callback(s, 1, SSL3_RT_HANDSHAKE, CBS_data(&cbs), CBS_len(&cbs)); + ssl_msg_callback_cbs(s, 1, SSL3_RT_HANDSHAKE, &cbs); } static void