From f329cdbc72828d8eb1770becc3ef47f7c8c03555 Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 2 Mar 2024 09:47:16 +0000 Subject: [PATCH] Remove OBJ_bsearch_() The only reason this has still been part of the public API was that libssl used it for cipher lookup. This was fixed by replacing the lookup by proper bsearch() -- why OpenSSL felt the need to reinvent ANSI C API badly will forever remain a mystery. The stack code in libcrypto still uses a version of this. This should be rewritten. It will be a bit easier once sk_find_ex() is removed. ok jsing --- lib/libcrypto/Symbols.list | 1 - lib/libcrypto/Symbols.namespace | 1 - lib/libcrypto/hidden/openssl/objects.h | 3 +-- lib/libcrypto/objects/obj_dat.c | 19 +------------------ lib/libcrypto/objects/objects.h | 14 +------------- lib/libcrypto/stack/stack.c | 5 ++++- 6 files changed, 7 insertions(+), 36 deletions(-) diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 85ee8bf071a..ee69864df5c 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -1689,7 +1689,6 @@ NOTICEREF_new OBJ_NAME_do_all OBJ_NAME_do_all_sorted OBJ_add_object -OBJ_bsearch_ OBJ_cleanup OBJ_cmp OBJ_create diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index 936526085c4..b7d9e75569f 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -2408,7 +2408,6 @@ _libre_OBJ_txt2nid _libre_OBJ_ln2nid _libre_OBJ_sn2nid _libre_OBJ_cmp -_libre_OBJ_bsearch_ _libre_OBJ_new_nid _libre_OBJ_add_object _libre_OBJ_create diff --git a/lib/libcrypto/hidden/openssl/objects.h b/lib/libcrypto/hidden/openssl/objects.h index 80c0644137c..5b39cd8215d 100644 --- a/lib/libcrypto/hidden/openssl/objects.h +++ b/lib/libcrypto/hidden/openssl/objects.h @@ -1,4 +1,4 @@ -/* $OpenBSD: objects.h,v 1.3 2024/03/02 09:41:02 tb Exp $ */ +/* $OpenBSD: objects.h,v 1.4 2024/03/02 09:47:16 tb Exp $ */ /* * Copyright (c) 2023 Bob Beck * @@ -38,7 +38,6 @@ LCRYPTO_USED(OBJ_txt2nid); LCRYPTO_USED(OBJ_ln2nid); LCRYPTO_USED(OBJ_sn2nid); LCRYPTO_USED(OBJ_cmp); -LCRYPTO_USED(OBJ_bsearch_); LCRYPTO_USED(OBJ_new_nid); LCRYPTO_USED(OBJ_add_object); LCRYPTO_USED(OBJ_create); diff --git a/lib/libcrypto/objects/obj_dat.c b/lib/libcrypto/objects/obj_dat.c index 1719cc73e20..bfa9ba3cc89 100644 --- a/lib/libcrypto/objects/obj_dat.c +++ b/lib/libcrypto/objects/obj_dat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_dat.c,v 1.86 2024/02/26 15:00:30 tb Exp $ */ +/* $OpenBSD: obj_dat.c,v 1.87 2024/03/02 09:47:16 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -436,23 +436,6 @@ OBJ_ln2nid(const char *ln) } LCRYPTO_ALIAS(OBJ_ln2nid); -const void * -OBJ_bsearch_(const void *key, const void *base, int num, int size, - int (*cmp)(const void *, const void *)) -{ - OBJerror(ERR_R_DISABLED); - return NULL; -} -LCRYPTO_ALIAS(OBJ_bsearch_); - -const void * -OBJ_bsearch_ex_(const void *key, const void *base_, int num, int size, - int (*cmp)(const void *, const void *), int flags) -{ - OBJerror(ERR_R_DISABLED); - return NULL; -} - /* Convert an object name into an ASN1_OBJECT * if "noname" is not set then search for short and long names first. * This will convert the "dotted" form into an object: unlike OBJ_txt2nid diff --git a/lib/libcrypto/objects/objects.h b/lib/libcrypto/objects/objects.h index 2d3aa986d52..ef6fc233bf8 100644 --- a/lib/libcrypto/objects/objects.h +++ b/lib/libcrypto/objects/objects.h @@ -1,4 +1,4 @@ -/* $OpenBSD: objects.h,v 1.25 2024/03/02 09:43:10 tb Exp $ */ +/* $OpenBSD: objects.h,v 1.26 2024/03/02 09:47:16 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -77,10 +77,6 @@ #define OBJ_NAME_ALIAS 0x8000 -#define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01 -#define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 - - #ifdef __cplusplus extern "C" { #endif @@ -111,14 +107,6 @@ int OBJ_ln2nid(const char *s); int OBJ_sn2nid(const char *s); int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b); -#if defined(LIBRESSL_INTERNAL) -const void * OBJ_bsearch_(const void *key, const void *base, int num, - int size, int (*cmp)(const void *, const void *)); -const void * OBJ_bsearch_ex_(const void *key, const void *base, int num, - int size, int (*cmp)(const void *, const void *), - int flags); -#endif - int OBJ_new_nid(int num); int OBJ_add_object(const ASN1_OBJECT *obj); int OBJ_create(const char *oid, const char *sn, const char *ln); diff --git a/lib/libcrypto/stack/stack.c b/lib/libcrypto/stack/stack.c index 818e7384470..86117f07a7e 100644 --- a/lib/libcrypto/stack/stack.c +++ b/lib/libcrypto/stack/stack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stack.c,v 1.25 2024/02/26 15:00:30 tb Exp $ */ +/* $OpenBSD: stack.c,v 1.26 2024/03/02 09:47:16 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,6 +66,9 @@ #undef MIN_NODES #define MIN_NODES 4 +#define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01 +#define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 + int (*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *)))( const void *, const void *) -- 2.20.1