summaryrefslogtreecommitdiff
path: root/src/lib/libssl/tls13_client.c
diff options
context:
space:
mode:
authorjsing <>2020-09-11 17:36:27 +0000
committerjsing <>2020-09-11 17:36:27 +0000
commit188f2a73ec9cc4314b9998227079cccb89e8677a (patch)
tree62dedc456145da98fc6ed3e6c1be5685fe0e1232 /src/lib/libssl/tls13_client.c
parent044cfc226bee4d04817ab4f4d3a6b1d0ab4db4ed (diff)
downloadopenbsd-188f2a73ec9cc4314b9998227079cccb89e8677a.tar.gz
openbsd-188f2a73ec9cc4314b9998227079cccb89e8677a.tar.bz2
openbsd-188f2a73ec9cc4314b9998227079cccb89e8677a.zip
Remove cipher_list_by_id.
When parsing a cipher string, a cipher list is created, before being duplicated and sorted - the second copy being stored as cipher_list_by_id. This is done only so that a client can ensure that the cipher selected by a server is in the cipher list. This is pretty pointless given that most clients are short-lived and that we already had to iterate over the cipher list in order to build the client hello. Additionally, any update to the cipher list requires that cipher_list_by_id also be updated and kept in sync. Remove all of this and replace it with a simple linear scan - the overhead of duplicating and sorting the cipher list likely exceeds that of a simple linear scan over the cipher list (64 maximum, more typically ~9 or so). ok beck@ tb@
Diffstat (limited to 'src/lib/libssl/tls13_client.c')
-rw-r--r--src/lib/libssl/tls13_client.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/lib/libssl/tls13_client.c b/src/lib/libssl/tls13_client.c
index bd72db8be0..35409d92bd 100644
--- a/src/lib/libssl/tls13_client.c
+++ b/src/lib/libssl/tls13_client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_client.c,v 1.66 2020/07/03 04:12:51 tb Exp $ */ 1/* $OpenBSD: tls13_client.c,v 1.67 2020/09/11 17:36: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 *
@@ -304,8 +304,7 @@ tls13_server_hello_process(struct tls13_ctx *ctx, CBS *cbs)
304 * hello and that it matches the TLS version selected. 304 * hello and that it matches the TLS version selected.
305 */ 305 */
306 cipher = ssl3_get_cipher_by_value(cipher_suite); 306 cipher = ssl3_get_cipher_by_value(cipher_suite);
307 if (cipher == NULL || 307 if (cipher == NULL || !ssl_cipher_in_list(SSL_get_ciphers(s), cipher)) {
308 sk_SSL_CIPHER_find(ssl_get_ciphers_by_id(s), cipher) < 0) {
309 ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; 308 ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER;
310 goto err; 309 goto err;
311 } 310 }