summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_locl.h
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/ssl_locl.h
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/ssl_locl.h')
-rw-r--r--src/lib/libssl/ssl_locl.h14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index bfd0ea6733..df07ca68a6 100644
--- a/src/lib/libssl/ssl_locl.h
+++ b/src/lib/libssl/ssl_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_locl.h,v 1.289 2020/09/11 15:28:08 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.290 2020/09/11 17:36:27 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 *
@@ -599,9 +599,6 @@ typedef struct ssl_ctx_internal_st {
599 599
600 CRYPTO_EX_DATA ex_data; 600 CRYPTO_EX_DATA ex_data;
601 601
602 /* same cipher_list but sorted for lookup */
603 STACK_OF(SSL_CIPHER) *cipher_list_by_id;
604
605 struct cert_st /* CERT */ *cert; 602 struct cert_st /* CERT */ *cert;
606 603
607 /* Default values used when no per-SSL value is defined follow */ 604 /* Default values used when no per-SSL value is defined follow */
@@ -746,9 +743,6 @@ typedef struct ssl_internal_st {
746 743
747 int hit; /* reusing a previous session */ 744 int hit; /* reusing a previous session */
748 745
749 /* crypto */
750 STACK_OF(SSL_CIPHER) *cipher_list_by_id;
751
752 /* These are the ones being used, the ones in SSL_SESSION are 746 /* These are the ones being used, the ones in SSL_SESSION are
753 * the ones to be 'copied' into these ones */ 747 * the ones to be 'copied' into these ones */
754 int mac_flags; 748 int mac_flags;
@@ -1127,6 +1121,7 @@ int ssl_version_set_min(const SSL_METHOD *meth, uint16_t ver, uint16_t max_ver,
1127int ssl_version_set_max(const SSL_METHOD *meth, uint16_t ver, uint16_t min_ver, 1121int ssl_version_set_max(const SSL_METHOD *meth, uint16_t ver, uint16_t min_ver,
1128 uint16_t *out_ver); 1122 uint16_t *out_ver);
1129int ssl_downgrade_max_version(SSL *s, uint16_t *max_ver); 1123int ssl_downgrade_max_version(SSL *s, uint16_t *max_ver);
1124int ssl_cipher_in_list(STACK_OF(SSL_CIPHER) *ciphers, const SSL_CIPHER *cipher);
1130int ssl_cipher_allowed_in_version_range(const SSL_CIPHER *cipher, 1125int ssl_cipher_allowed_in_version_range(const SSL_CIPHER *cipher,
1131 uint16_t min_ver, uint16_t max_ver); 1126 uint16_t min_ver, uint16_t max_ver);
1132 1127
@@ -1166,13 +1161,10 @@ int ssl_get_prev_session(SSL *s, CBS *session_id, CBS *ext_block,
1166int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b); 1161int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b);
1167SSL_CIPHER *OBJ_bsearch_ssl_cipher_id(SSL_CIPHER *key, SSL_CIPHER const *base, 1162SSL_CIPHER *OBJ_bsearch_ssl_cipher_id(SSL_CIPHER *key, SSL_CIPHER const *base,
1168 int num); 1163 int num);
1169int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap,
1170 const SSL_CIPHER * const *bp);
1171int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *ciphers, CBB *cbb); 1164int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *ciphers, CBB *cbb);
1172STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, CBS *cbs); 1165STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, CBS *cbs);
1173STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *meth, 1166STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *meth,
1174 STACK_OF(SSL_CIPHER) **pref, STACK_OF(SSL_CIPHER) **sorted, 1167 STACK_OF(SSL_CIPHER) **pref, const char *rule_str);
1175 const char *rule_str);
1176void ssl_update_cache(SSL *s, int mode); 1168void ssl_update_cache(SSL *s, int mode);
1177int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, 1169int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc,
1178 const EVP_MD **md, int *mac_pkey_type, int *mac_secret_size); 1170 const EVP_MD **md, int *mac_pkey_type, int *mac_secret_size);