summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2017-01-21 04:44:43 +0000
committerjsing <>2017-01-21 04:44:43 +0000
commitcf9904a4b13d79f0e11e7db5209260a381b4a83f (patch)
tree59d52ecb3cef99a21130ed575a0a20c9b6536385 /src
parent4a0bade454554867032b09f31d540604366200d5 (diff)
downloadopenbsd-cf9904a4b13d79f0e11e7db5209260a381b4a83f.tar.gz
openbsd-cf9904a4b13d79f0e11e7db5209260a381b4a83f.tar.bz2
openbsd-cf9904a4b13d79f0e11e7db5209260a381b4a83f.zip
Expand DECLARE_OBJ_BSEARCH_CMP_FN and IMPLEMENT_OBJ_BSEARCH_CMP_FN macros.
No change to generated assembly excluding line numbers.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/evp/evp_pbe.c22
-rw-r--r--src/lib/libcrypto/evp/pmeth_lib.c24
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c62
-rw-r--r--src/lib/libcrypto/objects/obj_xref.c42
-rw-r--r--src/lib/libcrypto/x509v3/v3_lib.c24
-rw-r--r--src/lib/libcrypto/x509v3/v3_purp.c22
6 files changed, 168 insertions, 28 deletions
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c
index 0787e2dc94..c7f0c7749a 100644
--- a/src/lib/libcrypto/evp/evp_pbe.c
+++ b/src/lib/libcrypto/evp/evp_pbe.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_pbe.c,v 1.23 2015/02/08 22:20:18 miod Exp $ */ 1/* $OpenBSD: evp_pbe.c,v 1.24 2017/01/21 04:38:23 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -169,7 +169,9 @@ EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
169 return 1; 169 return 1;
170} 170}
171 171
172DECLARE_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe2); 172static int pbe2_cmp_BSEARCH_CMP_FN(const void *, const void *);
173static int pbe2_cmp(EVP_PBE_CTL const *, EVP_PBE_CTL const *);
174static EVP_PBE_CTL *OBJ_bsearch_pbe2(EVP_PBE_CTL *key, EVP_PBE_CTL const *base, int num);
173 175
174static int 176static int
175pbe2_cmp(const EVP_PBE_CTL *pbe1, const EVP_PBE_CTL *pbe2) 177pbe2_cmp(const EVP_PBE_CTL *pbe1, const EVP_PBE_CTL *pbe2)
@@ -182,7 +184,21 @@ pbe2_cmp(const EVP_PBE_CTL *pbe1, const EVP_PBE_CTL *pbe2)
182 return pbe1->pbe_nid - pbe2->pbe_nid; 184 return pbe1->pbe_nid - pbe2->pbe_nid;
183} 185}
184 186
185IMPLEMENT_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe2); 187
188static int
189pbe2_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
190{
191 EVP_PBE_CTL const *a = a_;
192 EVP_PBE_CTL const *b = b_;
193 return pbe2_cmp(a, b);
194}
195
196static EVP_PBE_CTL *
197OBJ_bsearch_pbe2(EVP_PBE_CTL *key, EVP_PBE_CTL const *base, int num)
198{
199 return (EVP_PBE_CTL *)OBJ_bsearch_(key, base, num, sizeof(EVP_PBE_CTL),
200 pbe2_cmp_BSEARCH_CMP_FN);
201}
186 202
187static int 203static int
188pbe_cmp(const EVP_PBE_CTL * const *a, const EVP_PBE_CTL * const *b) 204pbe_cmp(const EVP_PBE_CTL * const *a, const EVP_PBE_CTL * const *b)
diff --git a/src/lib/libcrypto/evp/pmeth_lib.c b/src/lib/libcrypto/evp/pmeth_lib.c
index c93fa99cc6..1d64edcbeb 100644
--- a/src/lib/libcrypto/evp/pmeth_lib.c
+++ b/src/lib/libcrypto/evp/pmeth_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pmeth_lib.c,v 1.11 2015/02/11 03:19:37 doug Exp $ */ 1/* $OpenBSD: pmeth_lib.c,v 1.12 2017/01/21 04:38:23 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -103,8 +103,9 @@ static const EVP_PKEY_METHOD *standard_methods[] = {
103 &cmac_pkey_meth, 103 &cmac_pkey_meth,
104}; 104};
105 105
106DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD *, const EVP_PKEY_METHOD *, 106static int pmeth_cmp_BSEARCH_CMP_FN(const void *, const void *);
107 pmeth); 107static int pmeth_cmp(const EVP_PKEY_METHOD * const *, const EVP_PKEY_METHOD * const *);
108static const EVP_PKEY_METHOD * *OBJ_bsearch_pmeth(const EVP_PKEY_METHOD * *key, const EVP_PKEY_METHOD * const *base, int num);
108 109
109static int 110static int
110pmeth_cmp(const EVP_PKEY_METHOD * const *a, const EVP_PKEY_METHOD * const *b) 111pmeth_cmp(const EVP_PKEY_METHOD * const *a, const EVP_PKEY_METHOD * const *b)
@@ -112,8 +113,21 @@ pmeth_cmp(const EVP_PKEY_METHOD * const *a, const EVP_PKEY_METHOD * const *b)
112 return ((*a)->pkey_id - (*b)->pkey_id); 113 return ((*a)->pkey_id - (*b)->pkey_id);
113} 114}
114 115
115IMPLEMENT_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD *, const EVP_PKEY_METHOD *, 116
116 pmeth); 117static int
118pmeth_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
119{
120 const EVP_PKEY_METHOD * const *a = a_;
121 const EVP_PKEY_METHOD * const *b = b_;
122 return pmeth_cmp(a, b);
123}
124
125static const EVP_PKEY_METHOD * *
126OBJ_bsearch_pmeth(const EVP_PKEY_METHOD * *key, const EVP_PKEY_METHOD * const *base, int num)
127{
128 return (const EVP_PKEY_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const EVP_PKEY_METHOD *),
129 pmeth_cmp_BSEARCH_CMP_FN);
130}
117 131
118const EVP_PKEY_METHOD * 132const EVP_PKEY_METHOD *
119EVP_PKEY_meth_find(int type) 133EVP_PKEY_meth_find(int type)
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 1d6207072d..e1dacc0d39 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: obj_dat.c,v 1.37 2016/12/22 16:57:38 inoguchi Exp $ */ 1/* $OpenBSD: obj_dat.c,v 1.38 2017/01/21 04:44:43 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 *
@@ -72,9 +72,15 @@
72/* obj_dat.h is generated from objects.h by obj_dat.pl */ 72/* obj_dat.h is generated from objects.h by obj_dat.pl */
73#include "obj_dat.h" 73#include "obj_dat.h"
74 74
75DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); 75static int sn_cmp_BSEARCH_CMP_FN(const void *, const void *);
76DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); 76static int sn_cmp(const ASN1_OBJECT * const *, unsigned int const *);
77DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); 77static unsigned int *OBJ_bsearch_sn(const ASN1_OBJECT * *key, unsigned int const *base, int num);
78static int ln_cmp_BSEARCH_CMP_FN(const void *, const void *);
79static int ln_cmp(const ASN1_OBJECT * const *, unsigned int const *);
80static unsigned int *OBJ_bsearch_ln(const ASN1_OBJECT * *key, unsigned int const *base, int num);
81static int obj_cmp_BSEARCH_CMP_FN(const void *, const void *);
82static int obj_cmp(const ASN1_OBJECT * const *, unsigned int const *);
83static unsigned int *OBJ_bsearch_obj(const ASN1_OBJECT * *key, unsigned int const *base, int num);
78 84
79#define ADDED_DATA 0 85#define ADDED_DATA 0
80#define ADDED_SNAME 1 86#define ADDED_SNAME 1
@@ -95,14 +101,42 @@ static int sn_cmp(const ASN1_OBJECT * const *a, const unsigned int *b)
95 return (strcmp((*a)->sn, nid_objs[*b].sn)); 101 return (strcmp((*a)->sn, nid_objs[*b].sn));
96} 102}
97 103
98IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); 104
105static int
106sn_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
107{
108 const ASN1_OBJECT * const *a = a_;
109 unsigned int const *b = b_;
110 return sn_cmp(a, b);
111}
112
113static unsigned int *
114OBJ_bsearch_sn(const ASN1_OBJECT * *key, unsigned int const *base, int num)
115{
116 return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int),
117 sn_cmp_BSEARCH_CMP_FN);
118}
99 119
100static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) 120static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b)
101{ 121{
102 return (strcmp((*a)->ln, nid_objs[*b].ln)); 122 return (strcmp((*a)->ln, nid_objs[*b].ln));
103} 123}
104 124
105IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); 125
126static int
127ln_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
128{
129 const ASN1_OBJECT * const *a = a_;
130 unsigned int const *b = b_;
131 return ln_cmp(a, b);
132}
133
134static unsigned int *
135OBJ_bsearch_ln(const ASN1_OBJECT * *key, unsigned int const *base, int num)
136{
137 return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int),
138 ln_cmp_BSEARCH_CMP_FN);
139}
106 140
107static unsigned long 141static unsigned long
108added_obj_hash(const ADDED_OBJ *ca) 142added_obj_hash(const ADDED_OBJ *ca)
@@ -400,7 +434,21 @@ obj_cmp(const ASN1_OBJECT * const *ap, const unsigned int *bp)
400 return (memcmp(a->data, b->data, a->length)); 434 return (memcmp(a->data, b->data, a->length));
401} 435}
402 436
403IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); 437
438static int
439obj_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
440{
441 const ASN1_OBJECT * const *a = a_;
442 unsigned int const *b = b_;
443 return obj_cmp(a, b);
444}
445
446static unsigned int *
447OBJ_bsearch_obj(const ASN1_OBJECT * *key, unsigned int const *base, int num)
448{
449 return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int),
450 obj_cmp_BSEARCH_CMP_FN);
451}
404 452
405int 453int
406OBJ_obj2nid(const ASN1_OBJECT *a) 454OBJ_obj2nid(const ASN1_OBJECT *a)
diff --git a/src/lib/libcrypto/objects/obj_xref.c b/src/lib/libcrypto/objects/obj_xref.c
index 94dd6293dd..3e8730d1c6 100644
--- a/src/lib/libcrypto/objects/obj_xref.c
+++ b/src/lib/libcrypto/objects/obj_xref.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: obj_xref.c,v 1.7 2014/06/12 15:49:30 deraadt Exp $ */ 1/* $OpenBSD: obj_xref.c,v 1.8 2017/01/21 04:44:43 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -68,8 +68,24 @@ sig_cmp(const nid_triple *a, const nid_triple *b)
68 return a->sign_id - b->sign_id; 68 return a->sign_id - b->sign_id;
69} 69}
70 70
71DECLARE_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); 71static int sig_cmp_BSEARCH_CMP_FN(const void *, const void *);
72IMPLEMENT_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); 72static int sig_cmp(nid_triple const *, nid_triple const *);
73static nid_triple *OBJ_bsearch_sig(nid_triple *key, nid_triple const *base, int num);
74
75static int
76sig_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
77{
78 nid_triple const *a = a_;
79 nid_triple const *b = b_;
80 return sig_cmp(a, b);
81}
82
83static nid_triple *
84OBJ_bsearch_sig(nid_triple *key, nid_triple const *base, int num)
85{
86 return (nid_triple *)OBJ_bsearch_(key, base, num, sizeof(nid_triple),
87 sig_cmp_BSEARCH_CMP_FN);
88}
73 89
74static int 90static int
75sig_sk_cmp(const nid_triple * const *a, const nid_triple * const *b) 91sig_sk_cmp(const nid_triple * const *a, const nid_triple * const *b)
@@ -77,7 +93,9 @@ sig_sk_cmp(const nid_triple * const *a, const nid_triple * const *b)
77 return (*a)->sign_id - (*b)->sign_id; 93 return (*a)->sign_id - (*b)->sign_id;
78} 94}
79 95
80DECLARE_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); 96static int sigx_cmp_BSEARCH_CMP_FN(const void *, const void *);
97static int sigx_cmp(const nid_triple * const *, const nid_triple * const *);
98static const nid_triple * *OBJ_bsearch_sigx(const nid_triple * *key, const nid_triple * const *base, int num);
81 99
82static int 100static int
83sigx_cmp(const nid_triple * const *a, const nid_triple * const *b) 101sigx_cmp(const nid_triple * const *a, const nid_triple * const *b)
@@ -90,7 +108,21 @@ sigx_cmp(const nid_triple * const *a, const nid_triple * const *b)
90 return (*a)->pkey_id - (*b)->pkey_id; 108 return (*a)->pkey_id - (*b)->pkey_id;
91} 109}
92 110
93IMPLEMENT_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); 111
112static int
113sigx_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
114{
115 const nid_triple * const *a = a_;
116 const nid_triple * const *b = b_;
117 return sigx_cmp(a, b);
118}
119
120static const nid_triple * *
121OBJ_bsearch_sigx(const nid_triple * *key, const nid_triple * const *base, int num)
122{
123 return (const nid_triple * *)OBJ_bsearch_(key, base, num, sizeof(const nid_triple *),
124 sigx_cmp_BSEARCH_CMP_FN);
125}
94 126
95int 127int
96OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid) 128OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid)
diff --git a/src/lib/libcrypto/x509v3/v3_lib.c b/src/lib/libcrypto/x509v3/v3_lib.c
index 2e92747d43..946ef1d54e 100644
--- a/src/lib/libcrypto/x509v3/v3_lib.c
+++ b/src/lib/libcrypto/x509v3/v3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_lib.c,v 1.15 2016/12/30 15:54:49 jsing Exp $ */ 1/* $OpenBSD: v3_lib.c,v 1.16 2017/01/21 04:42:16 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -91,10 +91,24 @@ ext_cmp(const X509V3_EXT_METHOD * const *a, const X509V3_EXT_METHOD * const *b)
91 return ((*a)->ext_nid - (*b)->ext_nid); 91 return ((*a)->ext_nid - (*b)->ext_nid);
92} 92}
93 93
94DECLARE_OBJ_BSEARCH_CMP_FN(const X509V3_EXT_METHOD *, 94static int ext_cmp_BSEARCH_CMP_FN(const void *, const void *);
95 const X509V3_EXT_METHOD *, ext); 95static int ext_cmp(const X509V3_EXT_METHOD * const *, const X509V3_EXT_METHOD * const *);
96IMPLEMENT_OBJ_BSEARCH_CMP_FN(const X509V3_EXT_METHOD *, 96static const X509V3_EXT_METHOD * *OBJ_bsearch_ext(const X509V3_EXT_METHOD * *key, const X509V3_EXT_METHOD * const *base, int num);
97 const X509V3_EXT_METHOD *, ext); 97
98static int
99ext_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
100{
101 const X509V3_EXT_METHOD * const *a = a_;
102 const X509V3_EXT_METHOD * const *b = b_;
103 return ext_cmp(a, b);
104}
105
106static const X509V3_EXT_METHOD * *
107OBJ_bsearch_ext(const X509V3_EXT_METHOD * *key, const X509V3_EXT_METHOD * const *base, int num)
108{
109 return (const X509V3_EXT_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const X509V3_EXT_METHOD *),
110 ext_cmp_BSEARCH_CMP_FN);
111}
98 112
99const X509V3_EXT_METHOD * 113const X509V3_EXT_METHOD *
100X509V3_EXT_get_nid(int nid) 114X509V3_EXT_get_nid(int nid)
diff --git a/src/lib/libcrypto/x509v3/v3_purp.c b/src/lib/libcrypto/x509v3/v3_purp.c
index a091a7f425..d8ab679304 100644
--- a/src/lib/libcrypto/x509v3/v3_purp.c
+++ b/src/lib/libcrypto/x509v3/v3_purp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: v3_purp.c,v 1.27 2016/11/08 20:01:06 miod Exp $ */ 1/* $OpenBSD: v3_purp.c,v 1.28 2017/01/21 04:42:16 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -325,8 +325,24 @@ nid_cmp(const int *a, const int *b)
325 return *a - *b; 325 return *a - *b;
326} 326}
327 327
328DECLARE_OBJ_BSEARCH_CMP_FN(int, int, nid); 328static int nid_cmp_BSEARCH_CMP_FN(const void *, const void *);
329IMPLEMENT_OBJ_BSEARCH_CMP_FN(int, int, nid); 329static int nid_cmp(int const *, int const *);
330static int *OBJ_bsearch_nid(int *key, int const *base, int num);
331
332static int
333nid_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)
334{
335 int const *a = a_;
336 int const *b = b_;
337 return nid_cmp(a, b);
338}
339
340static int *
341OBJ_bsearch_nid(int *key, int const *base, int num)
342{
343 return (int *)OBJ_bsearch_(key, base, num, sizeof(int),
344 nid_cmp_BSEARCH_CMP_FN);
345}
330 346
331int 347int
332X509_supported_extension(X509_EXTENSION *ex) 348X509_supported_extension(X509_EXTENSION *ex)