summaryrefslogtreecommitdiff
path: root/lib/libssl/ssl_ciph.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2020-04-17 17:26:01 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2020-04-17 17:26:01 +0000
commitc3665edeabc2f5fc4af55c01d246171df02646ba (patch)
treeb3e7bef8ca47999396fcc43e58b504a6e6b91a0f /lib/libssl/ssl_ciph.c
parente368bd53d262a202b82bfad8a6d8de3986dcb326 (diff)
Only include TLSv1.3 cipher suites if there are active cipher suites.
Revise the previous so that we only include TLSv1.3 cipher suites if the cipher rule string resulted in at least one active cipher suite. This more closely matches OpenSSL behaviour. Noted and fix tested by schwarze@ ok beck@ tb@
Diffstat (limited to 'lib/libssl/ssl_ciph.c')
-rw-r--r--lib/libssl/ssl_ciph.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libssl/ssl_ciph.c b/lib/libssl/ssl_ciph.c
index 664ff5456b2..08ddc86c3c5 100644
--- a/lib/libssl/ssl_ciph.c
+++ b/lib/libssl/ssl_ciph.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_ciph.c,v 1.113 2020/04/09 17:54:38 jsing Exp $ */
+/* $OpenBSD: ssl_ciph.c,v 1.114 2020/04/17 17:26:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -1171,6 +1171,7 @@ ssl_create_cipher_list(const SSL_METHOD *ssl_method,
CIPHER_ORDER *co_list = NULL, *head = NULL, *tail = NULL, *curr;
const SSL_CIPHER **ca_list = NULL;
int tls13_seen = 0;
+ int active;
/*
* Return with error if nothing to do.
@@ -1320,13 +1321,20 @@ ssl_create_cipher_list(const SSL_METHOD *ssl_method,
* If the rule string did not contain any references to TLSv1.3,
* include inactive TLSv1.3 cipher suites. This avoids attempts to
* use TLSv1.3 with an older rule string that does not include
- * TLSv1.3 cipher suites.
+ * TLSv1.3 cipher suites. If the rule string resulted in no active
+ * cipher suites then we return an empty stack.
*/
+ active = 0;
for (curr = head; curr != NULL; curr = curr->next) {
if (curr->active ||
(!tls13_seen && curr->cipher->algorithm_ssl == SSL_TLSV1_3))
sk_SSL_CIPHER_push(cipherstack, curr->cipher);
+ if (curr->active)
+ active++;
}
+ if (active == 0)
+ sk_SSL_CIPHER_zero(cipherstack);
+
free(co_list); /* Not needed any longer */
tmp_cipher_list = sk_SSL_CIPHER_dup(cipherstack);