summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-01-14 08:56:00 +0000
committertb <>2022-01-14 08:56:00 +0000
commit146d5d6a018884a35292917be5886069dd2d04ef (patch)
tree1c8a22f5052221cb4e592d62c0963275aca48485 /src
parent1a06a078976a3bdd85f1457f17c06357e6a94edf (diff)
downloadopenbsd-146d5d6a018884a35292917be5886069dd2d04ef.tar.gz
openbsd-146d5d6a018884a35292917be5886069dd2d04ef.tar.bz2
openbsd-146d5d6a018884a35292917be5886069dd2d04ef.zip
Hide OBJ_bsearch_ from public visibility,
This removes OBJ_bsearch_ex_() from the exported symbols and makes OBJ_bsearch_() semi-private. It is still used in libssl. While here, remove some hideous unused macros ok inoguchi jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/objects/objects.h88
1 files changed, 4 insertions, 84 deletions
diff --git a/src/lib/libcrypto/objects/objects.h b/src/lib/libcrypto/objects/objects.h
index 5f76cf3289..918928e2f0 100644
--- a/src/lib/libcrypto/objects/objects.h
+++ b/src/lib/libcrypto/objects/objects.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: objects.h,v 1.16 2022/01/14 08:52:05 tb Exp $ */ 1/* $OpenBSD: objects.h,v 1.17 2022/01/14 08:56:00 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 *
@@ -1010,94 +1010,14 @@ int OBJ_txt2nid(const char *s);
1010int OBJ_ln2nid(const char *s); 1010int OBJ_ln2nid(const char *s);
1011int OBJ_sn2nid(const char *s); 1011int OBJ_sn2nid(const char *s);
1012int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b); 1012int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);
1013
1014#if defined(LIBRESSL_INTERNAL)
1013const void * OBJ_bsearch_(const void *key, const void *base, int num, 1015const void * OBJ_bsearch_(const void *key, const void *base, int num,
1014 int size, int (*cmp)(const void *, const void *)); 1016 int size, int (*cmp)(const void *, const void *));
1015const void * OBJ_bsearch_ex_(const void *key, const void *base, int num, 1017const void * OBJ_bsearch_ex_(const void *key, const void *base, int num,
1016 int size, int (*cmp)(const void *, const void *), 1018 int size, int (*cmp)(const void *, const void *),
1017 int flags); 1019 int flags);
1018 1020#endif
1019#ifndef LIBRESSL_INTERNAL
1020
1021#define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \
1022 static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \
1023 static int nm##_cmp(type1 const *, type2 const *); \
1024 scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)
1025
1026#define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp) \
1027 _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp)
1028#define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \
1029 type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)
1030
1031/*
1032 * Unsolved problem: if a type is actually a pointer type, like
1033 * nid_triple is, then its impossible to get a const where you need
1034 * it. Consider:
1035 *
1036 * typedef int nid_triple[3];
1037 * const void *a_;
1038 * const nid_triple const *a = a_;
1039 *
1040 * The assignement discards a const because what you really want is:
1041 *
1042 * const int const * const *a = a_;
1043 *
1044 * But if you do that, you lose the fact that a is an array of 3 ints,
1045 * which breaks comparison functions.
1046 *
1047 * Thus we end up having to cast, sadly, or unpack the
1048 * declarations. Or, as I finally did in this case, delcare nid_triple
1049 * to be a struct, which it should have been in the first place.
1050 *
1051 * Ben, August 2008.
1052 *
1053 * Also, strictly speaking not all types need be const, but handling
1054 * the non-constness means a lot of complication, and in practice
1055 * comparison routines do always not touch their arguments.
1056 */
1057
1058#define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm) \
1059 static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \
1060 { \
1061 type1 const *a = a_; \
1062 type2 const *b = b_; \
1063 return nm##_cmp(a,b); \
1064 } \
1065 static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \
1066 { \
1067 return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \
1068 nm##_cmp_BSEARCH_CMP_FN); \
1069 } \
1070 extern void dummy_prototype(void)
1071
1072#define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \
1073 static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \
1074 { \
1075 type1 const *a = a_; \
1076 type2 const *b = b_; \
1077 return nm##_cmp(a,b); \
1078 } \
1079 type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \
1080 { \
1081 return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \
1082 nm##_cmp_BSEARCH_CMP_FN); \
1083 } \
1084 extern void dummy_prototype(void)
1085
1086#define OBJ_bsearch(type1,key,type2,base,num,cmp) \
1087 ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \
1088 num,sizeof(type2), \
1089 ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \
1090 (void)CHECKED_PTR_OF(type2,cmp##_type_2), \
1091 cmp##_BSEARCH_CMP_FN)))
1092
1093#define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags) \
1094 ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \
1095 num,sizeof(type2), \
1096 ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \
1097 (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \
1098 cmp##_BSEARCH_CMP_FN)),flags)
1099
1100#endif /* !LIBRESSL_INTERNAL */
1101 1021
1102int OBJ_new_nid(int num); 1022int OBJ_new_nid(int num);
1103int OBJ_add_object(const ASN1_OBJECT *obj); 1023int OBJ_add_object(const ASN1_OBJECT *obj);