diff options
-rw-r--r-- | src/lib/libssl/tls13_client.c | 28 | ||||
-rw-r--r-- | src/lib/libssl/tls13_internal.h | 3 | ||||
-rw-r--r-- | src/lib/libssl/tls13_record_layer.c | 8 |
3 files changed, 30 insertions, 9 deletions
diff --git a/src/lib/libssl/tls13_client.c b/src/lib/libssl/tls13_client.c index b842cbd39c..4ec29ea956 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.21 2020/01/21 03:40:05 beck Exp $ */ | 1 | /* $OpenBSD: tls13_client.c,v 1.22 2020/01/21 12:08:04 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 | * |
@@ -115,14 +115,28 @@ tls13_use_legacy_client(struct tls13_ctx *ctx) | |||
115 | if (s->bbio != s->wbio) | 115 | if (s->bbio != s->wbio) |
116 | s->wbio = BIO_push(s->bbio, s->wbio); | 116 | s->wbio = BIO_push(s->bbio, s->wbio); |
117 | 117 | ||
118 | if (!tls13_handshake_msg_content(ctx->hs_msg, &cbs)) | 118 | /* Stash any unprocessed data from the last record. */ |
119 | goto err; | 119 | tls13_record_layer_rbuf(ctx->rl, &cbs); |
120 | if (CBS_len(&cbs) > 0) { | ||
121 | if (!CBS_write_bytes(&cbs, | ||
122 | S3I(s)->rbuf.buf + SSL3_RT_HEADER_LENGTH, | ||
123 | S3I(s)->rbuf.len - SSL3_RT_HEADER_LENGTH, NULL)) | ||
124 | goto err; | ||
120 | 125 | ||
121 | if (!BUF_MEM_grow_clean(s->internal->init_buf, CBS_len(&cbs) + 4)) | 126 | S3I(s)->rbuf.offset = SSL3_RT_HEADER_LENGTH; |
122 | goto err; | 127 | S3I(s)->rbuf.left = CBS_len(&cbs); |
128 | S3I(s)->rrec.type = SSL3_RT_HANDSHAKE; | ||
129 | S3I(s)->rrec.length = CBS_len(&cbs); | ||
130 | s->internal->rstate = SSL_ST_READ_BODY; | ||
131 | s->internal->packet = S3I(s)->rbuf.buf; | ||
132 | s->internal->packet_length = SSL3_RT_HEADER_LENGTH; | ||
133 | s->internal->mac_packet = 1; | ||
134 | } | ||
123 | 135 | ||
124 | if (!CBS_write_bytes(&cbs, s->internal->init_buf->data + 4, | 136 | /* Stash the current handshake message. */ |
125 | s->internal->init_buf->length - 4, NULL)) | 137 | tls13_handshake_msg_data(ctx->hs_msg, &cbs); |
138 | if (!CBS_write_bytes(&cbs, s->internal->init_buf->data, | ||
139 | s->internal->init_buf->length, NULL)) | ||
126 | goto err; | 140 | goto err; |
127 | 141 | ||
128 | S3I(s)->tmp.reuse_message = 1; | 142 | S3I(s)->tmp.reuse_message = 1; |
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h index 530ace41af..3ee73782ec 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.38 2020/01/21 03:40:05 beck Exp $ */ | 1 | /* $OpenBSD: tls13_internal.h,v 1.39 2020/01/21 12:08:04 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> |
@@ -116,6 +116,7 @@ struct tls13_record_layer *tls13_record_layer_new(tls13_read_cb wire_read, | |||
116 | tls13_phh_recv_cb phh_recv_cb, | 116 | tls13_phh_recv_cb phh_recv_cb, |
117 | tls13_phh_sent_cb phh_sent_cb, void *cb_arg); | 117 | tls13_phh_sent_cb phh_sent_cb, void *cb_arg); |
118 | void tls13_record_layer_free(struct tls13_record_layer *rl); | 118 | void tls13_record_layer_free(struct tls13_record_layer *rl); |
119 | void tls13_record_layer_rbuf(struct tls13_record_layer *rl, CBS *cbs); | ||
119 | void tls13_record_layer_set_aead(struct tls13_record_layer *rl, | 120 | void tls13_record_layer_set_aead(struct tls13_record_layer *rl, |
120 | const EVP_AEAD *aead); | 121 | const EVP_AEAD *aead); |
121 | void tls13_record_layer_set_hash(struct tls13_record_layer *rl, | 122 | void tls13_record_layer_set_hash(struct tls13_record_layer *rl, |
diff --git a/src/lib/libssl/tls13_record_layer.c b/src/lib/libssl/tls13_record_layer.c index e1007b3f7b..a6b00a83b3 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.17 2020/01/20 22:04:17 beck Exp $ */ | 1 | /* $OpenBSD: tls13_record_layer.c,v 1.18 2020/01/21 12:08:04 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 | * |
@@ -154,6 +154,12 @@ tls13_record_layer_free(struct tls13_record_layer *rl) | |||
154 | freezero(rl, sizeof(struct tls13_record_layer)); | 154 | freezero(rl, sizeof(struct tls13_record_layer)); |
155 | } | 155 | } |
156 | 156 | ||
157 | void | ||
158 | tls13_record_layer_rbuf(struct tls13_record_layer *rl, CBS *cbs) | ||
159 | { | ||
160 | CBS_dup(&rl->rbuf_cbs, cbs); | ||
161 | } | ||
162 | |||
157 | static int | 163 | static int |
158 | tls13_record_layer_inc_seq_num(uint8_t *seq_num) | 164 | tls13_record_layer_inc_seq_num(uint8_t *seq_num) |
159 | { | 165 | { |