summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2022-07-20 06:32:24 +0000
committerjsing <>2022-07-20 06:32:24 +0000
commitccb4f685d743447d79e76e1380f93ba28b5b8e1e (patch)
tree71c8f3c98cc3af4e296c929982738339c5534368
parent65be960bd3c39cb5e24e7479f7f1dfd10d8c6f69 (diff)
downloadopenbsd-ccb4f685d743447d79e76e1380f93ba28b5b8e1e.tar.gz
openbsd-ccb4f685d743447d79e76e1380f93ba28b5b8e1e.tar.bz2
openbsd-ccb4f685d743447d79e76e1380f93ba28b5b8e1e.zip
Remove tls_buffer_set_data() and remove/revise callers.
There is no way that tls_buffer_set_data() can currently work in conjunction with tls_buffer_expand(). This fact is currently hidden by the way that PHH works, which reads the same data from the record layer (which it needs to do anyway, since we may not have all of the handshake message in a single record). Since this is broken, mop it up and change the PHH callback to not provide the record data. ok beck@ tb@
-rw-r--r--src/lib/libssl/tls13_handshake_msg.c8
-rw-r--r--src/lib/libssl/tls13_internal.h5
-rw-r--r--src/lib/libssl/tls13_lib.c17
-rw-r--r--src/lib/libssl/tls13_record_layer.c4
-rw-r--r--src/lib/libssl/tls_buffer.c11
-rw-r--r--src/lib/libssl/tls_internal.h3
6 files changed, 14 insertions, 34 deletions
diff --git a/src/lib/libssl/tls13_handshake_msg.c b/src/lib/libssl/tls13_handshake_msg.c
index 67eab3152f..946ccaccd6 100644
--- a/src/lib/libssl/tls13_handshake_msg.c
+++ b/src/lib/libssl/tls13_handshake_msg.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_handshake_msg.c,v 1.4 2021/10/23 13:12:14 jsing Exp $ */ 1/* $OpenBSD: tls13_handshake_msg.c,v 1.5 2022/07/20 06:32:24 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 * 4 *
@@ -71,12 +71,6 @@ tls13_handshake_msg_data(struct tls13_handshake_msg *msg, CBS *cbs)
71 CBS_init(cbs, msg->data, msg->data_len); 71 CBS_init(cbs, msg->data, msg->data_len);
72} 72}
73 73
74int
75tls13_handshake_msg_set_buffer(struct tls13_handshake_msg *msg, CBS *cbs)
76{
77 return tls_buffer_set_data(msg->buf, cbs);
78}
79
80uint8_t 74uint8_t
81tls13_handshake_msg_type(struct tls13_handshake_msg *msg) 75tls13_handshake_msg_type(struct tls13_handshake_msg *msg)
82{ 76{
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h
index 555dd4262e..599eb200cb 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.98 2022/07/17 15:49:20 jsing Exp $ */ 1/* $OpenBSD: tls13_internal.h,v 1.99 2022/07/20 06:32:24 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>
@@ -88,7 +88,7 @@ __BEGIN_HIDDEN_DECLS
88#define TLS13_INFO_CONNECT_EXIT SSL_CB_CONNECT_EXIT 88#define TLS13_INFO_CONNECT_EXIT SSL_CB_CONNECT_EXIT
89 89
90typedef void (*tls13_alert_cb)(uint8_t _alert_desc, void *_cb_arg); 90typedef void (*tls13_alert_cb)(uint8_t _alert_desc, void *_cb_arg);
91typedef ssize_t (*tls13_phh_recv_cb)(void *_cb_arg, CBS *_cbs); 91typedef ssize_t (*tls13_phh_recv_cb)(void *_cb_arg);
92typedef void (*tls13_phh_sent_cb)(void *_cb_arg); 92typedef void (*tls13_phh_sent_cb)(void *_cb_arg);
93typedef void (*tls13_handshake_message_cb)(void *_cb_arg); 93typedef void (*tls13_handshake_message_cb)(void *_cb_arg);
94typedef void (*tls13_info_cb)(void *_cb_arg, int _state, int _ret); 94typedef void (*tls13_info_cb)(void *_cb_arg, int _state, int _ret);
@@ -226,7 +226,6 @@ struct tls13_handshake_msg;
226struct tls13_handshake_msg *tls13_handshake_msg_new(void); 226struct tls13_handshake_msg *tls13_handshake_msg_new(void);
227void tls13_handshake_msg_free(struct tls13_handshake_msg *msg); 227void tls13_handshake_msg_free(struct tls13_handshake_msg *msg);
228void tls13_handshake_msg_data(struct tls13_handshake_msg *msg, CBS *cbs); 228void tls13_handshake_msg_data(struct tls13_handshake_msg *msg, CBS *cbs);
229int tls13_handshake_msg_set_buffer(struct tls13_handshake_msg *msg, CBS *cbs);
230uint8_t tls13_handshake_msg_type(struct tls13_handshake_msg *msg); 229uint8_t tls13_handshake_msg_type(struct tls13_handshake_msg *msg);
231int tls13_handshake_msg_content(struct tls13_handshake_msg *msg, CBS *cbs); 230int tls13_handshake_msg_content(struct tls13_handshake_msg *msg, CBS *cbs);
232int tls13_handshake_msg_start(struct tls13_handshake_msg *msg, CBB *body, 231int tls13_handshake_msg_start(struct tls13_handshake_msg *msg, CBB *body,
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c
index 8b28bf55a4..8d0e030b5a 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.66 2022/07/20 06:20:44 jsing Exp $ */ 1/* $OpenBSD: tls13_lib.c,v 1.67 2022/07/20 06:32:24 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>
@@ -338,11 +338,11 @@ tls13_phh_done_cb(void *cb_arg)
338} 338}
339 339
340static ssize_t 340static ssize_t
341tls13_phh_received_cb(void *cb_arg, CBS *cbs) 341tls13_phh_received_cb(void *cb_arg)
342{ 342{
343 ssize_t ret = TLS13_IO_FAILURE; 343 ssize_t ret = TLS13_IO_FAILURE;
344 struct tls13_ctx *ctx = cb_arg; 344 struct tls13_ctx *ctx = cb_arg;
345 CBS phh_cbs; 345 CBS cbs;
346 346
347 if (!tls13_phh_limit_check(ctx)) 347 if (!tls13_phh_limit_check(ctx))
348 return tls13_send_alert(ctx->rl, TLS13_ALERT_UNEXPECTED_MESSAGE); 348 return tls13_send_alert(ctx->rl, TLS13_ALERT_UNEXPECTED_MESSAGE);
@@ -351,19 +351,16 @@ tls13_phh_received_cb(void *cb_arg, CBS *cbs)
351 ((ctx->hs_msg = tls13_handshake_msg_new()) == NULL)) 351 ((ctx->hs_msg = tls13_handshake_msg_new()) == NULL))
352 return TLS13_IO_FAILURE; 352 return TLS13_IO_FAILURE;
353 353
354 if (!tls13_handshake_msg_set_buffer(ctx->hs_msg, cbs)) 354 if ((ret = tls13_handshake_msg_recv(ctx->hs_msg, ctx->rl)) !=
355 return TLS13_IO_FAILURE; 355 TLS13_IO_SUCCESS)
356
357 if ((ret = tls13_handshake_msg_recv(ctx->hs_msg, ctx->rl))
358 != TLS13_IO_SUCCESS)
359 return ret; 356 return ret;
360 357
361 if (!tls13_handshake_msg_content(ctx->hs_msg, &phh_cbs)) 358 if (!tls13_handshake_msg_content(ctx->hs_msg, &cbs))
362 return TLS13_IO_FAILURE; 359 return TLS13_IO_FAILURE;
363 360
364 switch(tls13_handshake_msg_type(ctx->hs_msg)) { 361 switch(tls13_handshake_msg_type(ctx->hs_msg)) {
365 case TLS13_MT_KEY_UPDATE: 362 case TLS13_MT_KEY_UPDATE:
366 ret = tls13_key_update_recv(ctx, &phh_cbs); 363 ret = tls13_key_update_recv(ctx, &cbs);
367 break; 364 break;
368 case TLS13_MT_NEW_SESSION_TICKET: 365 case TLS13_MT_NEW_SESSION_TICKET:
369 /* XXX do nothing for now and ignore this */ 366 /* XXX do nothing for now and ignore this */
diff --git a/src/lib/libssl/tls13_record_layer.c b/src/lib/libssl/tls13_record_layer.c
index c68ee3b3a5..2b7052c30e 100644
--- a/src/lib/libssl/tls13_record_layer.c
+++ b/src/lib/libssl/tls13_record_layer.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_record_layer.c,v 1.67 2022/01/14 09:12:15 tb Exp $ */ 1/* $OpenBSD: tls13_record_layer.c,v 1.68 2022/07/20 06:32:24 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 * 4 *
@@ -909,7 +909,7 @@ tls13_record_layer_recv_phh(struct tls13_record_layer *rl)
909 * TLS13_IO_FAILURE something broke. 909 * TLS13_IO_FAILURE something broke.
910 */ 910 */
911 if (rl->cb.phh_recv != NULL) 911 if (rl->cb.phh_recv != NULL)
912 ret = rl->cb.phh_recv(rl->cb_arg, tls_content_cbs(rl->rcontent)); 912 ret = rl->cb.phh_recv(rl->cb_arg);
913 913
914 tls_content_clear(rl->rcontent); 914 tls_content_clear(rl->rcontent);
915 915
diff --git a/src/lib/libssl/tls_buffer.c b/src/lib/libssl/tls_buffer.c
index 5c0ca7e40e..9bb6b62e51 100644
--- a/src/lib/libssl/tls_buffer.c
+++ b/src/lib/libssl/tls_buffer.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_buffer.c,v 1.1 2021/10/23 13:12:14 jsing Exp $ */ 1/* $OpenBSD: tls_buffer.c,v 1.2 2022/07/20 06:32:24 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 * 4 *
@@ -76,15 +76,6 @@ tls_buffer_resize(struct tls_buffer *buf, size_t capacity)
76 return 1; 76 return 1;
77} 77}
78 78
79int
80tls_buffer_set_data(struct tls_buffer *buf, CBS *data)
81{
82 if (!tls_buffer_resize(buf, CBS_len(data)))
83 return 0;
84 memcpy(buf->data, CBS_data(data), CBS_len(data));
85 return 1;
86}
87
88ssize_t 79ssize_t
89tls_buffer_extend(struct tls_buffer *buf, size_t len, 80tls_buffer_extend(struct tls_buffer *buf, size_t len,
90 tls_read_cb read_cb, void *cb_arg) 81 tls_read_cb read_cb, void *cb_arg)
diff --git a/src/lib/libssl/tls_internal.h b/src/lib/libssl/tls_internal.h
index 0065f0f39f..ac2d14da48 100644
--- a/src/lib/libssl/tls_internal.h
+++ b/src/lib/libssl/tls_internal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_internal.h,v 1.6 2022/06/29 08:27:51 tb Exp $ */ 1/* $OpenBSD: tls_internal.h,v 1.7 2022/07/20 06:32:24 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018, 2019, 2021 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018, 2019, 2021 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -47,7 +47,6 @@ typedef ssize_t (*tls_flush_cb)(void *_cb_arg);
47struct tls_buffer; 47struct tls_buffer;
48 48
49struct tls_buffer *tls_buffer_new(size_t init_size); 49struct tls_buffer *tls_buffer_new(size_t init_size);
50int tls_buffer_set_data(struct tls_buffer *buf, CBS *data);
51void tls_buffer_free(struct tls_buffer *buf); 50void tls_buffer_free(struct tls_buffer *buf);
52ssize_t tls_buffer_extend(struct tls_buffer *buf, size_t len, 51ssize_t tls_buffer_extend(struct tls_buffer *buf, size_t len,
53 tls_read_cb read_cb, void *cb_arg); 52 tls_read_cb read_cb, void *cb_arg);