summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libssl/ssl_methods.c6
-rw-r--r--src/lib/libssl/tls13_internal.h4
-rw-r--r--src/lib/libssl/tls13_lib.c18
-rw-r--r--src/lib/libssl/tls13_record_layer.c20
4 files changed, 42 insertions, 6 deletions
diff --git a/src/lib/libssl/ssl_methods.c b/src/lib/libssl/ssl_methods.c
index 355cd8823a..8e4b678d3a 100644
--- a/src/lib/libssl/ssl_methods.c
+++ b/src/lib/libssl/ssl_methods.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_methods.c,v 1.9 2020/01/23 03:17:40 jsing Exp $ */ 1/* $OpenBSD: ssl_methods.c,v 1.10 2020/01/23 05:08:30 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -231,7 +231,7 @@ static const SSL_METHOD_INTERNAL TLS_client_method_internal_data = {
231 .ssl_renegotiate = ssl_undefined_function, 231 .ssl_renegotiate = ssl_undefined_function,
232 .ssl_renegotiate_check = ssl_ok, 232 .ssl_renegotiate_check = ssl_ok,
233 .ssl_get_message = ssl3_get_message, 233 .ssl_get_message = ssl3_get_message,
234 .ssl_pending = ssl3_pending, 234 .ssl_pending = tls13_legacy_pending,
235 .ssl_read_bytes = tls13_legacy_read_bytes, 235 .ssl_read_bytes = tls13_legacy_read_bytes,
236 .ssl_write_bytes = tls13_legacy_write_bytes, 236 .ssl_write_bytes = tls13_legacy_write_bytes,
237 .ssl3_enc = &TLSv1_2_enc_data, 237 .ssl3_enc = &TLSv1_2_enc_data,
@@ -608,7 +608,7 @@ static const SSL_METHOD_INTERNAL TLS_server_method_internal_data = {
608 .ssl_renegotiate = ssl_undefined_function, 608 .ssl_renegotiate = ssl_undefined_function,
609 .ssl_renegotiate_check = ssl_ok, 609 .ssl_renegotiate_check = ssl_ok,
610 .ssl_get_message = ssl3_get_message, 610 .ssl_get_message = ssl3_get_message,
611 .ssl_pending = ssl3_pending, 611 .ssl_pending = tls13_legacy_pending,
612 .ssl_read_bytes = tls13_legacy_read_bytes, 612 .ssl_read_bytes = tls13_legacy_read_bytes,
613 .ssl_write_bytes = tls13_legacy_write_bytes, 613 .ssl_write_bytes = tls13_legacy_write_bytes,
614 .ssl3_enc = &TLSv1_2_enc_data, 614 .ssl3_enc = &TLSv1_2_enc_data,
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h
index 4d6d626433..12ba5750a0 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.47 2020/01/23 02:49:38 jsing Exp $ */ 1/* $OpenBSD: tls13_internal.h,v 1.48 2020/01/23 05:08:30 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>
@@ -138,6 +138,7 @@ ssize_t tls13_record_layer_phh(struct tls13_record_layer *rl, CBS *cbs);
138ssize_t tls13_read_handshake_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n); 138ssize_t tls13_read_handshake_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n);
139ssize_t tls13_write_handshake_data(struct tls13_record_layer *rl, const uint8_t *buf, 139ssize_t tls13_write_handshake_data(struct tls13_record_layer *rl, const uint8_t *buf,
140 size_t n); 140 size_t n);
141ssize_t tls13_pending_application_data(struct tls13_record_layer *rl);
141ssize_t tls13_peek_application_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n); 142ssize_t tls13_peek_application_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n);
142ssize_t tls13_read_application_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n); 143ssize_t tls13_read_application_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n);
143ssize_t tls13_write_application_data(struct tls13_record_layer *rl, const uint8_t *buf, 144ssize_t tls13_write_application_data(struct tls13_record_layer *rl, const uint8_t *buf,
@@ -223,6 +224,7 @@ int tls13_legacy_connect(SSL *ssl);
223int tls13_legacy_return_code(SSL *ssl, ssize_t ret); 224int tls13_legacy_return_code(SSL *ssl, ssize_t ret);
224ssize_t tls13_legacy_wire_read_cb(void *buf, size_t n, void *arg); 225ssize_t tls13_legacy_wire_read_cb(void *buf, size_t n, void *arg);
225ssize_t tls13_legacy_wire_write_cb(const void *buf, size_t n, void *arg); 226ssize_t tls13_legacy_wire_write_cb(const void *buf, size_t n, void *arg);
227int tls13_legacy_pending(const SSL *ssl);
226int tls13_legacy_read_bytes(SSL *ssl, int type, unsigned char *buf, int len, 228int tls13_legacy_read_bytes(SSL *ssl, int type, unsigned char *buf, int len,
227 int peek); 229 int peek);
228int tls13_legacy_write_bytes(SSL *ssl, int type, const void *buf, int len); 230int tls13_legacy_write_bytes(SSL *ssl, int type, const void *buf, int len);
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c
index 727f617471..de3e840a84 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.22 2020/01/23 02:49:38 jsing Exp $ */ 1/* $OpenBSD: tls13_lib.c,v 1.23 2020/01/23 05:08:30 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>
@@ -411,6 +411,22 @@ tls13_legacy_return_code(SSL *ssl, ssize_t ret)
411} 411}
412 412
413int 413int
414tls13_legacy_pending(const SSL *ssl)
415{
416 struct tls13_ctx *ctx = ssl->internal->tls13;
417 ssize_t ret;
418
419 if (ctx == NULL)
420 return 0;
421
422 ret = tls13_pending_application_data(ctx->rl);
423 if (ret < 0 || ret > INT_MAX)
424 return 0;
425
426 return ret;
427}
428
429int
414tls13_legacy_read_bytes(SSL *ssl, int type, unsigned char *buf, int len, int peek) 430tls13_legacy_read_bytes(SSL *ssl, int type, unsigned char *buf, int len, int peek)
415{ 431{
416 struct tls13_ctx *ctx = ssl->internal->tls13; 432 struct tls13_ctx *ctx = ssl->internal->tls13;
diff --git a/src/lib/libssl/tls13_record_layer.c b/src/lib/libssl/tls13_record_layer.c
index f6dbbf1550..aa8968484b 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.23 2020/01/23 02:49:38 jsing Exp $ */ 1/* $OpenBSD: tls13_record_layer.c,v 1.24 2020/01/23 05:08:30 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 *
@@ -815,6 +815,15 @@ tls13_record_layer_read_record(struct tls13_record_layer *rl)
815} 815}
816 816
817ssize_t 817ssize_t
818tls13_record_layer_pending(struct tls13_record_layer *rl, uint8_t content_type)
819{
820 if (rl->rbuf_content_type != content_type)
821 return 0;
822
823 return CBS_len(&rl->rbuf_cbs);
824}
825
826static ssize_t
818tls13_record_layer_read_internal(struct tls13_record_layer *rl, 827tls13_record_layer_read_internal(struct tls13_record_layer *rl,
819 uint8_t content_type, uint8_t *buf, size_t n, int peek) 828 uint8_t content_type, uint8_t *buf, size_t n, int peek)
820{ 829{
@@ -1026,6 +1035,15 @@ tls13_write_handshake_data(struct tls13_record_layer *rl, const uint8_t *buf,
1026} 1035}
1027 1036
1028ssize_t 1037ssize_t
1038tls13_pending_application_data(struct tls13_record_layer *rl)
1039{
1040 if (!rl->handshake_completed)
1041 return 0;
1042
1043 return tls13_record_layer_pending(rl, SSL3_RT_APPLICATION_DATA);
1044}
1045
1046ssize_t
1029tls13_peek_application_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n) 1047tls13_peek_application_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n)
1030{ 1048{
1031 if (!rl->handshake_completed) 1049 if (!rl->handshake_completed)