summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2020-04-09 17:54:38 +0000
committerjsing <>2020-04-09 17:54:38 +0000
commitfd39076d1c57d059fde6223ba9f5f54678a94c86 (patch)
treeed61866d30c836266a9ba7ada2c122c2abbbef2d /src
parent5bd1d2b41a46cd4757fc2cecfc8592a8cbdef6df (diff)
downloadopenbsd-fd39076d1c57d059fde6223ba9f5f54678a94c86.tar.gz
openbsd-fd39076d1c57d059fde6223ba9f5f54678a94c86.tar.bz2
openbsd-fd39076d1c57d059fde6223ba9f5f54678a94c86.zip
Include TLSv1.3 cipher suites unless cipher string references TLSv1.3.
OpenSSL has always taken the approach of enabling almost everything by default. As a result, if you wanted to run a secure TLS client/server you had to specify your own "secure" cipher string, rather than being able to trust the defaults as being sensible and secure. The problem is that with the introduction of TLSv1.3, most of these "secure" cipher strings result in the new TLSv1.3 cipher suites being excluded. The "work around" for this issue in OpenSSL was to add a new TLSv1.3 API (SSL_CTX_set_ciphersuites(), SSL_set_ciphersuites()) and have separate knobs for the pre-TLSv1.3 and TLSv1.3 cipher suites. This of course means that every application now needs to call two APIs, but it does mean that applications that only call SSL_CTX_set_cipher_list()/SSL_set_cipher_list() cannot remove TLSv1.3 cipher suites and prevent TLSv1.3 from working. We've taken a different approach and have allowed TLSv1.3 cipher suites to be manipulated via the existing SSL_set_cipher_list() API. However, in order to avoid problems with hardcoded cipher strings, change this behaviour so that we always include TLSv1.3 cipher suites unless the cipher string has a specific reference to the TLSv1.3 protocol or a TLSv1.3 cipher suite. This means that: $ openssl ciphers -v TLSv1.2:!TLSv1.3 still gives TLSv1.2 only cipher suites and: $ openssl ciphers -v AEAD-CHACHA20-POLY1305-SHA256 only lists a single TLSv1.3 cipher, however: $ openssl ciphers -v ECDHE-RSA-AES256-GCM-SHA384 now includes both TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 and all TLSv1.3 cipher suites (which also matches OpenSSL's openssl(1) behaviour). Issue encountered by kn@ with mumble. ok tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/ssl_ciph.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/lib/libssl/ssl_ciph.c b/src/lib/libssl/ssl_ciph.c
index 393f0fbd18..664ff5456b 100644
--- a/src/lib/libssl/ssl_ciph.c
+++ b/src/lib/libssl/ssl_ciph.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_ciph.c,v 1.112 2020/04/09 17:24:11 jsing Exp $ */ 1/* $OpenBSD: ssl_ciph.c,v 1.113 2020/04/09 17:54:38 jsing 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 *
@@ -907,7 +907,7 @@ ssl_cipher_strength_sort(CIPHER_ORDER **head_p, CIPHER_ORDER **tail_p)
907 907
908static int 908static int
909ssl_cipher_process_rulestr(const char *rule_str, CIPHER_ORDER **head_p, 909ssl_cipher_process_rulestr(const char *rule_str, CIPHER_ORDER **head_p,
910 CIPHER_ORDER **tail_p, const SSL_CIPHER **ca_list) 910 CIPHER_ORDER **tail_p, const SSL_CIPHER **ca_list, int *tls13_seen)
911{ 911{
912 unsigned long alg_mkey, alg_auth, alg_enc, alg_mac, alg_ssl; 912 unsigned long alg_mkey, alg_auth, alg_enc, alg_mac, alg_ssl;
913 unsigned long algo_strength; 913 unsigned long algo_strength;
@@ -916,6 +916,8 @@ ssl_cipher_process_rulestr(const char *rule_str, CIPHER_ORDER **head_p,
916 const char *l, *buf; 916 const char *l, *buf;
917 char ch; 917 char ch;
918 918
919 *tls13_seen = 0;
920
919 retval = 1; 921 retval = 1;
920 l = rule_str; 922 l = rule_str;
921 for (;;) { 923 for (;;) {
@@ -1083,6 +1085,8 @@ ssl_cipher_process_rulestr(const char *rule_str, CIPHER_ORDER **head_p,
1083 * pattern! 1085 * pattern!
1084 */ 1086 */
1085 cipher_id = ca_list[j]->id; 1087 cipher_id = ca_list[j]->id;
1088 if (ca_list[j]->algorithm_ssl == SSL_TLSV1_3)
1089 *tls13_seen = 1;
1086 } else { 1090 } else {
1087 /* 1091 /*
1088 * not an explicit ciphersuite; only in this 1092 * not an explicit ciphersuite; only in this
@@ -1128,6 +1132,8 @@ ssl_cipher_process_rulestr(const char *rule_str, CIPHER_ORDER **head_p,
1128 while ((*l != '\0') && !ITEM_SEP(*l)) 1132 while ((*l != '\0') && !ITEM_SEP(*l))
1129 l++; 1133 l++;
1130 } else if (found) { 1134 } else if (found) {
1135 if (alg_ssl == SSL_TLSV1_3)
1136 *tls13_seen = 1;
1131 ssl_cipher_apply_rule(cipher_id, alg_mkey, alg_auth, 1137 ssl_cipher_apply_rule(cipher_id, alg_mkey, alg_auth,
1132 alg_enc, alg_mac, alg_ssl, algo_strength, rule, 1138 alg_enc, alg_mac, alg_ssl, algo_strength, rule,
1133 -1, head_p, tail_p); 1139 -1, head_p, tail_p);
@@ -1164,6 +1170,7 @@ ssl_create_cipher_list(const SSL_METHOD *ssl_method,
1164 const char *rule_p; 1170 const char *rule_p;
1165 CIPHER_ORDER *co_list = NULL, *head = NULL, *tail = NULL, *curr; 1171 CIPHER_ORDER *co_list = NULL, *head = NULL, *tail = NULL, *curr;
1166 const SSL_CIPHER **ca_list = NULL; 1172 const SSL_CIPHER **ca_list = NULL;
1173 int tls13_seen = 0;
1167 1174
1168 /* 1175 /*
1169 * Return with error if nothing to do. 1176 * Return with error if nothing to do.
@@ -1279,14 +1286,15 @@ ssl_create_cipher_list(const SSL_METHOD *ssl_method,
1279 rule_p = rule_str; 1286 rule_p = rule_str;
1280 if (strncmp(rule_str, "DEFAULT", 7) == 0) { 1287 if (strncmp(rule_str, "DEFAULT", 7) == 0) {
1281 ok = ssl_cipher_process_rulestr(SSL_DEFAULT_CIPHER_LIST, 1288 ok = ssl_cipher_process_rulestr(SSL_DEFAULT_CIPHER_LIST,
1282 &head, &tail, ca_list); 1289 &head, &tail, ca_list, &tls13_seen);
1283 rule_p += 7; 1290 rule_p += 7;
1284 if (*rule_p == ':') 1291 if (*rule_p == ':')
1285 rule_p++; 1292 rule_p++;
1286 } 1293 }
1287 1294
1288 if (ok && (strlen(rule_p) > 0)) 1295 if (ok && (strlen(rule_p) > 0))
1289 ok = ssl_cipher_process_rulestr(rule_p, &head, &tail, ca_list); 1296 ok = ssl_cipher_process_rulestr(rule_p, &head, &tail, ca_list,
1297 &tls13_seen);
1290 1298
1291 free((void *)ca_list); /* Not needed anymore */ 1299 free((void *)ca_list); /* Not needed anymore */
1292 1300
@@ -1308,11 +1316,16 @@ ssl_create_cipher_list(const SSL_METHOD *ssl_method,
1308 /* 1316 /*
1309 * The cipher selection for the list is done. The ciphers are added 1317 * The cipher selection for the list is done. The ciphers are added
1310 * to the resulting precedence to the STACK_OF(SSL_CIPHER). 1318 * to the resulting precedence to the STACK_OF(SSL_CIPHER).
1319 *
1320 * If the rule string did not contain any references to TLSv1.3,
1321 * include inactive TLSv1.3 cipher suites. This avoids attempts to
1322 * use TLSv1.3 with an older rule string that does not include
1323 * TLSv1.3 cipher suites.
1311 */ 1324 */
1312 for (curr = head; curr != NULL; curr = curr->next) { 1325 for (curr = head; curr != NULL; curr = curr->next) {
1313 if (curr->active) { 1326 if (curr->active ||
1327 (!tls13_seen && curr->cipher->algorithm_ssl == SSL_TLSV1_3))
1314 sk_SSL_CIPHER_push(cipherstack, curr->cipher); 1328 sk_SSL_CIPHER_push(cipherstack, curr->cipher);
1315 }
1316 } 1329 }
1317 free(co_list); /* Not needed any longer */ 1330 free(co_list); /* Not needed any longer */
1318 1331