summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/objects
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/objects')
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c62
-rw-r--r--src/lib/libcrypto/objects/obj_xref.c42
2 files changed, 92 insertions, 12 deletions
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)