diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libssl/ssl_ciph.c | 25 |
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 | ||
908 | static int | 908 | static int |
909 | ssl_cipher_process_rulestr(const char *rule_str, CIPHER_ORDER **head_p, | 909 | ssl_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 | ||