summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
authortb <>2023-11-29 13:39:34 +0000
committertb <>2023-11-29 13:39:34 +0000
commit5fc61c757deaae46e25cc163ae9e92831528fbc8 (patch)
treef6fe9a9fb0e2f88a15ec1b3eb39c745c2618710c /src/lib/libssl/ssl_lib.c
parent49adf1fb564c33009eb18992e86dac6577364047 (diff)
downloadopenbsd-5fc61c757deaae46e25cc163ae9e92831528fbc8.tar.gz
openbsd-5fc61c757deaae46e25cc163ae9e92831528fbc8.tar.bz2
openbsd-5fc61c757deaae46e25cc163ae9e92831528fbc8.zip
Convert ssl3_cipher_by_id() to bsearch()
This was previously the only user of OBJ_bsearch_ssl_cipher_id(), which in turn is the one remaining user of OBJ_bsearch_() outside of libcrypto. OBJ_bsearch_() is OpenSSL's idiosyncratic reimplementation of ANSI C89's bsearch(). Since this used to be hidden behind macro insanity, the result was three inscrutable layers of comparison functions. It is much simpler and cleaner to use the standard API. Move all the code to s3_lib.c, since it's ony used there. In a few further diffs, OBJ_bsearch_() will be removed from libcrypto. Unfortunately, we'll need to keep OBJ_bsearch_ex(), because it is exposed via sk_find_ex(), which is exposed by M2Crypto... ok jsing
Diffstat (limited to 'src/lib/libssl/ssl_lib.c')
-rw-r--r--src/lib/libssl/ssl_lib.c29
1 files changed, 1 insertions, 28 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index 5cd0e82f89..ce14ce710a 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_lib.c,v 1.316 2023/11/25 12:05:08 tb Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.317 2023/11/29 13:39:34 tb 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 *
@@ -3638,30 +3638,3 @@ SSL_set_quic_use_legacy_codepoint(SSL *ssl, int use_legacy)
3638 /* Not supported. */ 3638 /* Not supported. */
3639} 3639}
3640LSSL_ALIAS(SSL_set_quic_use_legacy_codepoint); 3640LSSL_ALIAS(SSL_set_quic_use_legacy_codepoint);
3641
3642static int
3643ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b)
3644{
3645 long l;
3646
3647 l = a->id - b->id;
3648 if (l == 0L)
3649 return (0);
3650 else
3651 return ((l > 0) ? 1:-1);
3652}
3653
3654static int
3655ssl_cipher_id_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
3656{
3657 SSL_CIPHER const *a = a_;
3658 SSL_CIPHER const *b = b_;
3659 return ssl_cipher_id_cmp(a, b);
3660}
3661
3662SSL_CIPHER *
3663OBJ_bsearch_ssl_cipher_id(SSL_CIPHER *key, SSL_CIPHER const *base, int num)
3664{
3665 return (SSL_CIPHER *)OBJ_bsearch_(key, base, num, sizeof(SSL_CIPHER),
3666 ssl_cipher_id_cmp_BSEARCH_CMP_FN);
3667}