summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
authortb <>2023-04-23 18:51:53 +0000
committertb <>2023-04-23 18:51:53 +0000
commitfb7a7adad4b566192144a21e4c93b739671b0cae (patch)
treefa6d649a58d3a734a4bc9dea3b97a71426074f8b /src/lib/libssl/ssl_lib.c
parent292e18c3ddebe32b0e929925c98c01b416d0210e (diff)
downloadopenbsd-fb7a7adad4b566192144a21e4c93b739671b0cae.tar.gz
openbsd-fb7a7adad4b566192144a21e4c93b739671b0cae.tar.bz2
openbsd-fb7a7adad4b566192144a21e4c93b739671b0cae.zip
Randomize the order of TLS extensions
On creation of an SSL using SSL_new(), randomize the order in which the extensions will be sent. There are several constraints: the PSK extension must always come last. The order cannot be randomized on a per-message basis as the strict interpretation of the standard chosen in the CH hashing doesn't allow changing the order between first and second ClientHello. Another constraint is that the current code calls callbacks directly on parsing an extension, which means that the order callbacks are called depends on the order in which the peer sent the extensions. This results in breaking apache-httpd setups using virtual hosts with full ranomization because virtual hosts don't work if the SNI is unknown at the time the ALPN callback is called. So for the time being, we ensure that SNI always precedes ALPN to avoid issues until this issue is fixed. This is based on an idea by David Benjamin https://boringssl-review.googlesource.com/c/boringssl/+/48045 Input & ok jsing
Diffstat (limited to 'src/lib/libssl/ssl_lib.c')
-rw-r--r--src/lib/libssl/ssl_lib.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index de4ef3fb5e..68e60a5481 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_lib.c,v 1.308 2022/11/26 16:08:55 tb Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.309 2023/04/23 18:51:53 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -302,6 +302,9 @@ SSL_new(SSL_CTX *ctx)
302 CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); 302 CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);
303 s->initial_ctx = ctx; 303 s->initial_ctx = ctx;
304 304
305 if (!tlsext_randomize_build_order(s))
306 goto err;
307
305 if (ctx->tlsext_ecpointformatlist != NULL) { 308 if (ctx->tlsext_ecpointformatlist != NULL) {
306 s->tlsext_ecpointformatlist = 309 s->tlsext_ecpointformatlist =
307 calloc(ctx->tlsext_ecpointformatlist_length, 310 calloc(ctx->tlsext_ecpointformatlist_length,
@@ -550,6 +553,8 @@ SSL_free(SSL *s)
550 553
551 ssl_cert_free(s->cert); 554 ssl_cert_free(s->cert);
552 555
556 free(s->tlsext_build_order);
557
553 free(s->tlsext_hostname); 558 free(s->tlsext_hostname);
554 SSL_CTX_free(s->initial_ctx); 559 SSL_CTX_free(s->initial_ctx);
555 560