summaryrefslogtreecommitdiff
path: root/src/lib/libssl/tls13_legacy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/tls13_legacy.c')
-rw-r--r--src/lib/libssl/tls13_legacy.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/lib/libssl/tls13_legacy.c b/src/lib/libssl/tls13_legacy.c
index a62e936ccb..0379c978e9 100644
--- a/src/lib/libssl/tls13_legacy.c
+++ b/src/lib/libssl/tls13_legacy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_legacy.c,v 1.35 2022/01/25 15:00:09 tb Exp $ */ 1/* $OpenBSD: tls13_legacy.c,v 1.36 2022/02/05 14:54:10 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 *
@@ -127,7 +127,7 @@ tls13_legacy_error(SSL *ssl)
127 int reason = SSL_R_UNKNOWN; 127 int reason = SSL_R_UNKNOWN;
128 128
129 /* If we received a fatal alert we already put an error on the stack. */ 129 /* If we received a fatal alert we already put an error on the stack. */
130 if (S3I(ssl)->fatal_alert != 0) 130 if (ssl->s3->fatal_alert != 0)
131 return; 131 return;
132 132
133 switch (ctx->error.code) { 133 switch (ctx->error.code) {
@@ -288,7 +288,7 @@ tls13_legacy_write_bytes(SSL *ssl, int type, const void *vbuf, int len)
288 * In the non-SSL_MODE_ENABLE_PARTIAL_WRITE case we have to loop until 288 * In the non-SSL_MODE_ENABLE_PARTIAL_WRITE case we have to loop until
289 * we have written out all of the requested data. 289 * we have written out all of the requested data.
290 */ 290 */
291 sent = S3I(ssl)->wnum; 291 sent = ssl->s3->wnum;
292 if (len < sent) { 292 if (len < sent) {
293 SSLerror(ssl, SSL_R_BAD_LENGTH); 293 SSLerror(ssl, SSL_R_BAD_LENGTH);
294 return -1; 294 return -1;
@@ -296,12 +296,12 @@ tls13_legacy_write_bytes(SSL *ssl, int type, const void *vbuf, int len)
296 n = len - sent; 296 n = len - sent;
297 for (;;) { 297 for (;;) {
298 if (n == 0) { 298 if (n == 0) {
299 S3I(ssl)->wnum = 0; 299 ssl->s3->wnum = 0;
300 return sent; 300 return sent;
301 } 301 }
302 if ((ret = tls13_write_application_data(ctx->rl, 302 if ((ret = tls13_write_application_data(ctx->rl,
303 &buf[sent], n)) <= 0) { 303 &buf[sent], n)) <= 0) {
304 S3I(ssl)->wnum = sent; 304 ssl->s3->wnum = sent;
305 return tls13_legacy_return_code(ssl, ret); 305 return tls13_legacy_return_code(ssl, ret);
306 } 306 }
307 sent += ret; 307 sent += ret;
@@ -330,8 +330,8 @@ tls13_use_legacy_stack(struct tls13_ctx *ctx)
330 /* Stash any unprocessed data from the last record. */ 330 /* Stash any unprocessed data from the last record. */
331 tls13_record_layer_rcontent(ctx->rl, &cbs); 331 tls13_record_layer_rcontent(ctx->rl, &cbs);
332 if (CBS_len(&cbs) > 0) { 332 if (CBS_len(&cbs) > 0) {
333 if (!CBB_init_fixed(&cbb, S3I(s)->rbuf.buf, 333 if (!CBB_init_fixed(&cbb, s->s3->rbuf.buf,
334 S3I(s)->rbuf.len)) 334 s->s3->rbuf.len))
335 goto err; 335 goto err;
336 if (!CBB_add_u8(&cbb, SSL3_RT_HANDSHAKE)) 336 if (!CBB_add_u8(&cbb, SSL3_RT_HANDSHAKE))
337 goto err; 337 goto err;
@@ -344,12 +344,12 @@ tls13_use_legacy_stack(struct tls13_ctx *ctx)
344 if (!CBB_finish(&cbb, NULL, NULL)) 344 if (!CBB_finish(&cbb, NULL, NULL))
345 goto err; 345 goto err;
346 346
347 S3I(s)->rbuf.offset = SSL3_RT_HEADER_LENGTH; 347 s->s3->rbuf.offset = SSL3_RT_HEADER_LENGTH;
348 S3I(s)->rbuf.left = CBS_len(&cbs); 348 s->s3->rbuf.left = CBS_len(&cbs);
349 S3I(s)->rrec.type = SSL3_RT_HANDSHAKE; 349 s->s3->rrec.type = SSL3_RT_HANDSHAKE;
350 S3I(s)->rrec.length = CBS_len(&cbs); 350 s->s3->rrec.length = CBS_len(&cbs);
351 s->internal->rstate = SSL_ST_READ_BODY; 351 s->internal->rstate = SSL_ST_READ_BODY;
352 s->internal->packet = S3I(s)->rbuf.buf; 352 s->internal->packet = s->s3->rbuf.buf;
353 s->internal->packet_length = SSL3_RT_HEADER_LENGTH; 353 s->internal->packet_length = SSL3_RT_HEADER_LENGTH;
354 s->internal->mac_packet = 1; 354 s->internal->mac_packet = 1;
355 } 355 }
@@ -362,9 +362,9 @@ tls13_use_legacy_stack(struct tls13_ctx *ctx)
362 s->internal->init_buf->length, NULL)) 362 s->internal->init_buf->length, NULL))
363 goto err; 363 goto err;
364 364
365 S3I(s)->hs.tls12.reuse_message = 1; 365 s->s3->hs.tls12.reuse_message = 1;
366 S3I(s)->hs.tls12.message_type = tls13_handshake_msg_type(ctx->hs_msg); 366 s->s3->hs.tls12.message_type = tls13_handshake_msg_type(ctx->hs_msg);
367 S3I(s)->hs.tls12.message_size = CBS_len(&cbs) - SSL3_HM_HEADER_LENGTH; 367 s->s3->hs.tls12.message_size = CBS_len(&cbs) - SSL3_HM_HEADER_LENGTH;
368 368
369 return 1; 369 return 1;
370 370
@@ -416,7 +416,7 @@ tls13_legacy_accept(SSL *ssl)
416 } 416 }
417 ssl->internal->tls13 = ctx; 417 ssl->internal->tls13 = ctx;
418 ctx->ssl = ssl; 418 ctx->ssl = ssl;
419 ctx->hs = &S3I(ssl)->hs; 419 ctx->hs = &ssl->s3->hs;
420 420
421 if (!tls13_server_init(ctx)) { 421 if (!tls13_server_init(ctx)) {
422 if (ERR_peek_error() == 0) 422 if (ERR_peek_error() == 0)
@@ -452,7 +452,7 @@ tls13_legacy_connect(SSL *ssl)
452 } 452 }
453 ssl->internal->tls13 = ctx; 453 ssl->internal->tls13 = ctx;
454 ctx->ssl = ssl; 454 ctx->ssl = ssl;
455 ctx->hs = &S3I(ssl)->hs; 455 ctx->hs = &ssl->s3->hs;
456 456
457 if (!tls13_client_init(ctx)) { 457 if (!tls13_client_init(ctx)) {
458 if (ERR_peek_error() == 0) 458 if (ERR_peek_error() == 0)