diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libssl/tls13_client.c | 6 | ||||
-rw-r--r-- | src/lib/libssl/tls13_handshake.c | 8 | ||||
-rw-r--r-- | src/lib/libssl/tls13_internal.h | 4 | ||||
-rw-r--r-- | src/lib/libssl/tls13_record_layer.c | 33 |
4 files changed, 45 insertions, 6 deletions
diff --git a/src/lib/libssl/tls13_client.c b/src/lib/libssl/tls13_client.c index d5ac6ba5e0..27b2d712ae 100644 --- a/src/lib/libssl/tls13_client.c +++ b/src/lib/libssl/tls13_client.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_client.c,v 1.56 2020/05/09 15:30:21 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_client.c,v 1.57 2020/05/09 15:47:11 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 | * |
@@ -150,6 +150,9 @@ tls13_client_hello_sent(struct tls13_ctx *ctx) | |||
150 | 150 | ||
151 | tls1_transcript_freeze(ctx->ssl); | 151 | tls1_transcript_freeze(ctx->ssl); |
152 | 152 | ||
153 | if (ctx->middlebox_compat) | ||
154 | ctx->send_dummy_ccs = 1; | ||
155 | |||
153 | return 1; | 156 | return 1; |
154 | } | 157 | } |
155 | 158 | ||
@@ -544,6 +547,7 @@ tls13_server_certificate_request_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
544 | err: | 547 | err: |
545 | if (ctx->alert == 0) | 548 | if (ctx->alert == 0) |
546 | ctx->alert = TLS1_AD_DECODE_ERROR; | 549 | ctx->alert = TLS1_AD_DECODE_ERROR; |
550 | |||
547 | return 0; | 551 | return 0; |
548 | } | 552 | } |
549 | 553 | ||
diff --git a/src/lib/libssl/tls13_handshake.c b/src/lib/libssl/tls13_handshake.c index d739dc99e5..05446380dd 100644 --- a/src/lib/libssl/tls13_handshake.c +++ b/src/lib/libssl/tls13_handshake.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_handshake.c,v 1.56 2020/05/09 08:39:44 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_handshake.c,v 1.57 2020/05/09 15:47:11 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018-2019 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2018-2019 Theo Buehler <tb@openbsd.org> |
4 | * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> | 4 | * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> |
@@ -332,6 +332,12 @@ tls13_handshake_send_action(struct tls13_ctx *ctx, | |||
332 | ssize_t ret; | 332 | ssize_t ret; |
333 | CBB cbb; | 333 | CBB cbb; |
334 | 334 | ||
335 | if (ctx->send_dummy_ccs) { | ||
336 | if ((ret = tls13_send_dummy_ccs(ctx->rl)) != TLS13_IO_SUCCESS) | ||
337 | return ret; | ||
338 | ctx->send_dummy_ccs = 0; | ||
339 | } | ||
340 | |||
335 | /* If we have no handshake message, we need to build one. */ | 341 | /* If we have no handshake message, we need to build one. */ |
336 | if (ctx->hs_msg == NULL) { | 342 | if (ctx->hs_msg == NULL) { |
337 | if ((ctx->hs_msg = tls13_handshake_msg_new()) == NULL) | 343 | if ((ctx->hs_msg = tls13_handshake_msg_new()) == NULL) |
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h index f15d11551a..438423aaff 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.69 2020/05/09 15:30:21 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_internal.h,v 1.70 2020/05/09 15:47:11 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> |
@@ -174,6 +174,7 @@ ssize_t tls13_write_application_data(struct tls13_record_layer *rl, const uint8_ | |||
174 | size_t n); | 174 | size_t n); |
175 | 175 | ||
176 | ssize_t tls13_send_alert(struct tls13_record_layer *rl, uint8_t alert_desc); | 176 | ssize_t tls13_send_alert(struct tls13_record_layer *rl, uint8_t alert_desc); |
177 | ssize_t tls13_send_dummy_ccs(struct tls13_record_layer *rl); | ||
177 | 178 | ||
178 | /* | 179 | /* |
179 | * Handshake Messages. | 180 | * Handshake Messages. |
@@ -219,6 +220,7 @@ struct tls13_ctx { | |||
219 | struct tls13_handshake_stage handshake_stage; | 220 | struct tls13_handshake_stage handshake_stage; |
220 | int handshake_completed; | 221 | int handshake_completed; |
221 | int middlebox_compat; | 222 | int middlebox_compat; |
223 | int send_dummy_ccs; | ||
222 | 224 | ||
223 | int close_notify_sent; | 225 | int close_notify_sent; |
224 | int close_notify_recv; | 226 | int close_notify_recv; |
diff --git a/src/lib/libssl/tls13_record_layer.c b/src/lib/libssl/tls13_record_layer.c index 6b9be4028c..ce6327b694 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.35 2020/05/09 15:39:18 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_record_layer.c,v 1.36 2020/05/09 15:47:11 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 | * |
@@ -30,6 +30,7 @@ struct tls13_record_layer { | |||
30 | 30 | ||
31 | int ccs_allowed; | 31 | int ccs_allowed; |
32 | int ccs_seen; | 32 | int ccs_seen; |
33 | int ccs_sent; | ||
33 | int handshake_completed; | 34 | int handshake_completed; |
34 | int legacy_alerts_allowed; | 35 | int legacy_alerts_allowed; |
35 | int phh; | 36 | int phh; |
@@ -603,7 +604,14 @@ tls13_record_layer_seal_record_plaintext(struct tls13_record_layer *rl, | |||
603 | size_t data_len = 0; | 604 | size_t data_len = 0; |
604 | CBB cbb, body; | 605 | CBB cbb, body; |
605 | 606 | ||
606 | if (rl->aead != NULL) | 607 | /* |
608 | * Allow dummy CCS messages to be sent in plaintext even when | ||
609 | * record protection has been engaged, as long as the handshake | ||
610 | * has not yet completed. | ||
611 | */ | ||
612 | if (rl->handshake_completed) | ||
613 | return 0; | ||
614 | if (rl->aead != NULL && content_type != SSL3_RT_CHANGE_CIPHER_SPEC) | ||
607 | return 0; | 615 | return 0; |
608 | 616 | ||
609 | /* | 617 | /* |
@@ -752,7 +760,7 @@ tls13_record_layer_seal_record(struct tls13_record_layer *rl, | |||
752 | if ((rl->wrec = tls13_record_new()) == NULL) | 760 | if ((rl->wrec = tls13_record_new()) == NULL) |
753 | return 0; | 761 | return 0; |
754 | 762 | ||
755 | if (rl->aead == NULL) | 763 | if (rl->aead == NULL || content_type == SSL3_RT_CHANGE_CIPHER_SPEC) |
756 | return tls13_record_layer_seal_record_plaintext(rl, | 764 | return tls13_record_layer_seal_record_plaintext(rl, |
757 | content_type, content, content_len); | 765 | content_type, content, content_len); |
758 | 766 | ||
@@ -1071,6 +1079,25 @@ tls13_record_layer_write(struct tls13_record_layer *rl, uint8_t content_type, | |||
1071 | return ret; | 1079 | return ret; |
1072 | } | 1080 | } |
1073 | 1081 | ||
1082 | static const uint8_t tls13_dummy_ccs[] = { 0x01 }; | ||
1083 | |||
1084 | ssize_t | ||
1085 | tls13_send_dummy_ccs(struct tls13_record_layer *rl) | ||
1086 | { | ||
1087 | ssize_t ret; | ||
1088 | |||
1089 | if (rl->ccs_sent) | ||
1090 | return TLS13_IO_FAILURE; | ||
1091 | |||
1092 | if ((ret = tls13_record_layer_write(rl, SSL3_RT_CHANGE_CIPHER_SPEC, | ||
1093 | tls13_dummy_ccs, sizeof(tls13_dummy_ccs))) <= 0) | ||
1094 | return ret; | ||
1095 | |||
1096 | rl->ccs_sent = 1; | ||
1097 | |||
1098 | return TLS13_IO_SUCCESS; | ||
1099 | } | ||
1100 | |||
1074 | ssize_t | 1101 | ssize_t |
1075 | tls13_read_handshake_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n) | 1102 | tls13_read_handshake_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n) |
1076 | { | 1103 | { |