diff options
| author | jsing <> | 2022-07-17 15:49:20 +0000 |
|---|---|---|
| committer | jsing <> | 2022-07-17 15:49:20 +0000 |
| commit | aa01620723c4a62e50c3f8ec40f18389e2240ca8 (patch) | |
| tree | 799ce4082b0a88dbd46501888f2190cfcc8e2109 /src | |
| parent | 051cc88e1fc78696049654a4cba5a6e33648121a (diff) | |
| download | openbsd-aa01620723c4a62e50c3f8ec40f18389e2240ca8.tar.gz openbsd-aa01620723c4a62e50c3f8ec40f18389e2240ca8.tar.bz2 openbsd-aa01620723c4a62e50c3f8ec40f18389e2240ca8.zip | |
Pass SSL pointer to tls13_ctx_new().
struct tls13_ctx already knows about SSL's and this way tls13_ctx_new() can
set up various pointers, rather than duplicating this in
tls13_legacy_accept() and tls13_legacy_connect().
ok tb@
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libssl/tls13_internal.h | 4 | ||||
| -rw-r--r-- | src/lib/libssl/tls13_legacy.c | 14 | ||||
| -rw-r--r-- | src/lib/libssl/tls13_lib.c | 8 |
3 files changed, 11 insertions, 15 deletions
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h index 75e13ac15d..555dd4262e 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.97 2022/06/03 13:11:04 tb Exp $ */ | 1 | /* $OpenBSD: tls13_internal.h,v 1.98 2022/07/17 15:49:20 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> |
| @@ -292,7 +292,7 @@ struct tls13_ctx { | |||
| 292 | #define TLS13_PHH_LIMIT 100 | 292 | #define TLS13_PHH_LIMIT 100 |
| 293 | #endif | 293 | #endif |
| 294 | 294 | ||
| 295 | struct tls13_ctx *tls13_ctx_new(int mode); | 295 | struct tls13_ctx *tls13_ctx_new(int mode, SSL *ssl); |
| 296 | void tls13_ctx_free(struct tls13_ctx *ctx); | 296 | void tls13_ctx_free(struct tls13_ctx *ctx); |
| 297 | 297 | ||
| 298 | const EVP_AEAD *tls13_cipher_aead(const SSL_CIPHER *cipher); | 298 | const EVP_AEAD *tls13_cipher_aead(const SSL_CIPHER *cipher); |
diff --git a/src/lib/libssl/tls13_legacy.c b/src/lib/libssl/tls13_legacy.c index 27e030fa77..545f2cd978 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.37 2022/02/06 16:08:14 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_legacy.c,v 1.38 2022/07/17 15:49:20 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 | * |
| @@ -414,14 +414,10 @@ tls13_legacy_accept(SSL *ssl) | |||
| 414 | int ret; | 414 | int ret; |
| 415 | 415 | ||
| 416 | if (ctx == NULL) { | 416 | if (ctx == NULL) { |
| 417 | if ((ctx = tls13_ctx_new(TLS13_HS_SERVER)) == NULL) { | 417 | if ((ctx = tls13_ctx_new(TLS13_HS_SERVER, ssl)) == NULL) { |
| 418 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); /* XXX */ | 418 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); /* XXX */ |
| 419 | return -1; | 419 | return -1; |
| 420 | } | 420 | } |
| 421 | ssl->internal->tls13 = ctx; | ||
| 422 | ctx->ssl = ssl; | ||
| 423 | ctx->hs = &ssl->s3->hs; | ||
| 424 | |||
| 425 | if (!tls13_server_init(ctx)) { | 421 | if (!tls13_server_init(ctx)) { |
| 426 | if (ERR_peek_error() == 0) | 422 | if (ERR_peek_error() == 0) |
| 427 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); /* XXX */ | 423 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); /* XXX */ |
| @@ -450,14 +446,10 @@ tls13_legacy_connect(SSL *ssl) | |||
| 450 | int ret; | 446 | int ret; |
| 451 | 447 | ||
| 452 | if (ctx == NULL) { | 448 | if (ctx == NULL) { |
| 453 | if ((ctx = tls13_ctx_new(TLS13_HS_CLIENT)) == NULL) { | 449 | if ((ctx = tls13_ctx_new(TLS13_HS_CLIENT, ssl)) == NULL) { |
| 454 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); /* XXX */ | 450 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); /* XXX */ |
| 455 | return -1; | 451 | return -1; |
| 456 | } | 452 | } |
| 457 | ssl->internal->tls13 = ctx; | ||
| 458 | ctx->ssl = ssl; | ||
| 459 | ctx->hs = &ssl->s3->hs; | ||
| 460 | |||
| 461 | if (!tls13_client_init(ctx)) { | 453 | if (!tls13_client_init(ctx)) { |
| 462 | if (ERR_peek_error() == 0) | 454 | if (ERR_peek_error() == 0) |
| 463 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); /* XXX */ | 455 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); /* XXX */ |
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c index 20d3a38412..8b8ea7f01b 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.63 2022/02/05 14:54:10 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_lib.c,v 1.64 2022/07/17 15:49:20 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> |
| @@ -382,14 +382,16 @@ static const struct tls13_record_layer_callbacks rl_callbacks = { | |||
| 382 | }; | 382 | }; |
| 383 | 383 | ||
| 384 | struct tls13_ctx * | 384 | struct tls13_ctx * |
| 385 | tls13_ctx_new(int mode) | 385 | tls13_ctx_new(int mode, SSL *ssl) |
| 386 | { | 386 | { |
| 387 | struct tls13_ctx *ctx = NULL; | 387 | struct tls13_ctx *ctx = NULL; |
| 388 | 388 | ||
| 389 | if ((ctx = calloc(sizeof(struct tls13_ctx), 1)) == NULL) | 389 | if ((ctx = calloc(sizeof(struct tls13_ctx), 1)) == NULL) |
| 390 | goto err; | 390 | goto err; |
| 391 | 391 | ||
| 392 | ctx->hs = &ssl->s3->hs; | ||
| 392 | ctx->mode = mode; | 393 | ctx->mode = mode; |
| 394 | ctx->ssl = ssl; | ||
| 393 | 395 | ||
| 394 | if ((ctx->rl = tls13_record_layer_new(&rl_callbacks, ctx)) == NULL) | 396 | if ((ctx->rl = tls13_record_layer_new(&rl_callbacks, ctx)) == NULL) |
| 395 | goto err; | 397 | goto err; |
| @@ -401,6 +403,8 @@ tls13_ctx_new(int mode) | |||
| 401 | 403 | ||
| 402 | ctx->middlebox_compat = 1; | 404 | ctx->middlebox_compat = 1; |
| 403 | 405 | ||
| 406 | ssl->internal->tls13 = ctx; | ||
| 407 | |||
| 404 | return ctx; | 408 | return ctx; |
| 405 | 409 | ||
| 406 | err: | 410 | err: |
