summaryrefslogtreecommitdiff
path: root/src/lib/libssl/tls13_lib.c
diff options
context:
space:
mode:
authorjsing <>2020-05-11 17:28:33 +0000
committerjsing <>2020-05-11 17:28:33 +0000
commit7fc47fb1fd67ca9212681c6ffdaa77fe0f2e7332 (patch)
treeda6bc62c26f406643a28cb04f02d6bef6e8ed477 /src/lib/libssl/tls13_lib.c
parent0457cfe2c74f9fa05dfdd745fa5292dd986b52d4 (diff)
downloadopenbsd-7fc47fb1fd67ca9212681c6ffdaa77fe0f2e7332.tar.gz
openbsd-7fc47fb1fd67ca9212681c6ffdaa77fe0f2e7332.tar.bz2
openbsd-7fc47fb1fd67ca9212681c6ffdaa77fe0f2e7332.zip
Move the record layer callbacks into a struct.
This makes the code more readable, requires less code churn when adding a new callback and is likely to avoid bugs due to function argument ordering. ok beck@ inoguchi@ tb@
Diffstat (limited to 'src/lib/libssl/tls13_lib.c')
-rw-r--r--src/lib/libssl/tls13_lib.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c
index d3e4050c1e..f096fe633e 100644
--- a/src/lib/libssl/tls13_lib.c
+++ b/src/lib/libssl/tls13_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_lib.c,v 1.41 2020/05/10 16:56:11 jsing Exp $ */ 1/* $OpenBSD: tls13_lib.c,v 1.42 2020/05/11 17:28:33 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2019 Bob Beck <beck@openbsd.org> 4 * Copyright (c) 2019 Bob Beck <beck@openbsd.org>
@@ -332,6 +332,14 @@ tls13_phh_received_cb(void *cb_arg, CBS *cbs)
332 return ret; 332 return ret;
333} 333}
334 334
335static const struct tls13_record_layer_callbacks rl_callbacks = {
336 .wire_read = tls13_legacy_wire_read_cb,
337 .wire_write = tls13_legacy_wire_write_cb,
338 .alert_recv = tls13_alert_received_cb,
339 .phh_recv = tls13_phh_received_cb,
340 .phh_sent = tls13_phh_done_cb,
341};
342
335struct tls13_ctx * 343struct tls13_ctx *
336tls13_ctx_new(int mode) 344tls13_ctx_new(int mode)
337{ 345{
@@ -342,9 +350,7 @@ tls13_ctx_new(int mode)
342 350
343 ctx->mode = mode; 351 ctx->mode = mode;
344 352
345 if ((ctx->rl = tls13_record_layer_new(tls13_legacy_wire_read_cb, 353 if ((ctx->rl = tls13_record_layer_new(&rl_callbacks, ctx)) == NULL)
346 tls13_legacy_wire_write_cb, tls13_alert_received_cb,
347 tls13_phh_received_cb, tls13_phh_done_cb, ctx)) == NULL)
348 goto err; 354 goto err;
349 355
350 ctx->handshake_message_sent_cb = tls13_legacy_handshake_message_sent_cb; 356 ctx->handshake_message_sent_cb = tls13_legacy_handshake_message_sent_cb;