summaryrefslogtreecommitdiff
path: root/src/lib/libssl/tls13_legacy.c
diff options
context:
space:
mode:
authorjsing <>2020-10-11 02:22:27 +0000
committerjsing <>2020-10-11 02:22:27 +0000
commitde4705827be90015506e4065c5fcaa759a5eeb2e (patch)
treea536d961ab89e5f295dc904ee7d6fcf5483675c9 /src/lib/libssl/tls13_legacy.c
parent4884af0400cb036042f4e33c5f8c58fb076986b4 (diff)
downloadopenbsd-de4705827be90015506e4065c5fcaa759a5eeb2e.tar.gz
openbsd-de4705827be90015506e4065c5fcaa759a5eeb2e.tar.bz2
openbsd-de4705827be90015506e4065c5fcaa759a5eeb2e.zip
Condense and simplify TLS methods.
Historically, OpenSSL has had client and server specific methods - the only difference between these is that the .ssl_connect or .ssl_accept function pointer is set to ssl_undefined_function, with the intention of reducing code size for a statically linked binary that was only a client or server. These days the difference is minimal or non-existant in many cases and we can reduce the amount of code and complexity by having single method. Internally remove all of the client and server specific methods, simplifying code in the process. The external client/server specific API remain, however these now return the same thing as TLS_method() does. ok tb@
Diffstat (limited to '')
-rw-r--r--src/lib/libssl/tls13_legacy.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/lib/libssl/tls13_legacy.c b/src/lib/libssl/tls13_legacy.c
index e9e17293e1..943e2db9a1 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.15 2020/10/07 10:14:45 tb Exp $ */ 1/* $OpenBSD: tls13_legacy.c,v 1.16 2020/10/11 02:22:27 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 *
@@ -302,6 +302,8 @@ tls13_use_legacy_stack(struct tls13_ctx *ctx)
302 302
303 memset(&cbb, 0, sizeof(cbb)); 303 memset(&cbb, 0, sizeof(cbb));
304 304
305 s->method = tls_legacy_method();
306
305 if (!ssl3_setup_init_buffer(s)) 307 if (!ssl3_setup_init_buffer(s))
306 goto err; 308 goto err;
307 if (!ssl3_setup_buffers(s)) 309 if (!ssl3_setup_buffers(s))
@@ -359,13 +361,12 @@ tls13_use_legacy_client(struct tls13_ctx *ctx)
359{ 361{
360 SSL *s = ctx->ssl; 362 SSL *s = ctx->ssl;
361 363
362 s->method = tls_legacy_client_method();
363 s->internal->handshake_func = s->method->internal->ssl_connect;
364 s->client_version = s->version = s->method->internal->max_version;
365
366 if (!tls13_use_legacy_stack(ctx)) 364 if (!tls13_use_legacy_stack(ctx))
367 return 0; 365 return 0;
368 366
367 s->internal->handshake_func = s->method->internal->ssl_connect;
368 s->client_version = s->version = s->method->internal->max_version;
369
369 S3I(s)->hs.state = SSL3_ST_CR_SRVR_HELLO_A; 370 S3I(s)->hs.state = SSL3_ST_CR_SRVR_HELLO_A;
370 371
371 return 1; 372 return 1;
@@ -376,14 +377,13 @@ tls13_use_legacy_server(struct tls13_ctx *ctx)
376{ 377{
377 SSL *s = ctx->ssl; 378 SSL *s = ctx->ssl;
378 379
379 s->method = tls_legacy_server_method(); 380 if (!tls13_use_legacy_stack(ctx))
381 return 0;
382
380 s->internal->handshake_func = s->method->internal->ssl_accept; 383 s->internal->handshake_func = s->method->internal->ssl_accept;
381 s->client_version = s->version = s->method->internal->max_version; 384 s->client_version = s->version = s->method->internal->max_version;
382 s->server = 1; 385 s->server = 1;
383 386
384 if (!tls13_use_legacy_stack(ctx))
385 return 0;
386
387 S3I(s)->hs.state = SSL3_ST_SR_CLNT_HELLO_A; 387 S3I(s)->hs.state = SSL3_ST_SR_CLNT_HELLO_A;
388 388
389 return 1; 389 return 1;