summaryrefslogtreecommitdiff
path: root/src/lib/libssl/tls13_record_layer.c
diff options
context:
space:
mode:
authortb <>2020-01-22 02:39:45 +0000
committertb <>2020-01-22 02:39:45 +0000
commite841f2e08f8bcc62f31051874b1b2a491665e7c6 (patch)
treee3b7e917f86898f6c4c09cc95fd58779cf635a2f /src/lib/libssl/tls13_record_layer.c
parente42a9af6bede5e8c30f66cf9013f858a29caed3e (diff)
downloadopenbsd-e841f2e08f8bcc62f31051874b1b2a491665e7c6.tar.gz
openbsd-e841f2e08f8bcc62f31051874b1b2a491665e7c6.tar.bz2
openbsd-e841f2e08f8bcc62f31051874b1b2a491665e7c6.zip
The legacy_record_version must be set to TLS1_2_VERSION except
in the ClientHello where it may be set to TLS1_VERSION. Use the minimal supported version to decide whether we choose to do so or not. Use a sent hook to set it back TLS1_2_VERSION right after the ClientHello message is on the wire. ok beck jsing
Diffstat (limited to 'src/lib/libssl/tls13_record_layer.c')
-rw-r--r--src/lib/libssl/tls13_record_layer.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/lib/libssl/tls13_record_layer.c b/src/lib/libssl/tls13_record_layer.c
index dff5cd2bbe..600990a878 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.19 2020/01/22 01:02:28 jsing Exp $ */ 1/* $OpenBSD: tls13_record_layer.c,v 1.20 2020/01/22 02:39:45 tb 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 *
@@ -28,6 +28,7 @@ static ssize_t tls13_record_layer_write_record(struct tls13_record_layer *rl,
28 uint8_t content_type, const uint8_t *content, size_t content_len); 28 uint8_t content_type, const uint8_t *content, size_t content_len);
29 29
30struct tls13_record_layer { 30struct tls13_record_layer {
31 uint16_t legacy_version;
31 int change_cipher_spec_seen; 32 int change_cipher_spec_seen;
32 int handshake_completed; 33 int handshake_completed;
33 int phh; 34 int phh;
@@ -124,6 +125,8 @@ tls13_record_layer_new(tls13_read_cb wire_read, tls13_write_cb wire_write,
124 if ((rl = calloc(1, sizeof(struct tls13_record_layer))) == NULL) 125 if ((rl = calloc(1, sizeof(struct tls13_record_layer))) == NULL)
125 return NULL; 126 return NULL;
126 127
128 rl->legacy_version = TLS1_2_VERSION;
129
127 rl->wire_read = wire_read; 130 rl->wire_read = wire_read;
128 rl->wire_write = wire_write; 131 rl->wire_write = wire_write;
129 rl->alert_cb = alert_cb; 132 rl->alert_cb = alert_cb;
@@ -211,6 +214,13 @@ tls13_record_layer_set_hash(struct tls13_record_layer *rl,
211} 214}
212 215
213void 216void
217tls13_record_layer_set_legacy_version(struct tls13_record_layer *rl,
218 uint16_t version)
219{
220 rl->legacy_version = version;
221}
222
223void
214tls13_record_layer_handshake_completed(struct tls13_record_layer *rl) 224tls13_record_layer_handshake_completed(struct tls13_record_layer *rl)
215{ 225{
216 rl->handshake_completed = 1; 226 rl->handshake_completed = 1;
@@ -563,15 +573,11 @@ tls13_record_layer_seal_record_plaintext(struct tls13_record_layer *rl,
563{ 573{
564 uint8_t *data = NULL; 574 uint8_t *data = NULL;
565 size_t data_len = 0; 575 size_t data_len = 0;
566 uint16_t version;
567 CBB cbb, body; 576 CBB cbb, body;
568 577
569 if (rl->aead != NULL) 578 if (rl->aead != NULL)
570 return 0; 579 return 0;
571 580
572 /* XXX - TLS1_VERSION for first client hello... */
573 version = TLS1_2_VERSION;
574
575 /* 581 /*
576 * We're still operating in plaintext mode, so just copy the 582 * We're still operating in plaintext mode, so just copy the
577 * content into the record. 583 * content into the record.
@@ -581,7 +587,7 @@ tls13_record_layer_seal_record_plaintext(struct tls13_record_layer *rl,
581 587
582 if (!CBB_add_u8(&cbb, content_type)) 588 if (!CBB_add_u8(&cbb, content_type))
583 goto err; 589 goto err;
584 if (!CBB_add_u16(&cbb, version)) 590 if (!CBB_add_u16(&cbb, rl->legacy_version))
585 goto err; 591 goto err;
586 if (!CBB_add_u16_length_prefixed(&cbb, &body)) 592 if (!CBB_add_u16_length_prefixed(&cbb, &body))
587 goto err; 593 goto err;