diff options
| author | jsing <> | 2017-01-21 04:44:43 +0000 |
|---|---|---|
| committer | jsing <> | 2017-01-21 04:44:43 +0000 |
| commit | cf9904a4b13d79f0e11e7db5209260a381b4a83f (patch) | |
| tree | 59d52ecb3cef99a21130ed575a0a20c9b6536385 /src/lib/libcrypto/objects | |
| parent | 4a0bade454554867032b09f31d540604366200d5 (diff) | |
| download | openbsd-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/lib/libcrypto/objects')
| -rw-r--r-- | src/lib/libcrypto/objects/obj_dat.c | 62 | ||||
| -rw-r--r-- | src/lib/libcrypto/objects/obj_xref.c | 42 |
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 | ||
| 75 | DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); | 75 | static int sn_cmp_BSEARCH_CMP_FN(const void *, const void *); |
| 76 | DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); | 76 | static int sn_cmp(const ASN1_OBJECT * const *, unsigned int const *); |
| 77 | DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); | 77 | static unsigned int *OBJ_bsearch_sn(const ASN1_OBJECT * *key, unsigned int const *base, int num); |
| 78 | static int ln_cmp_BSEARCH_CMP_FN(const void *, const void *); | ||
| 79 | static int ln_cmp(const ASN1_OBJECT * const *, unsigned int const *); | ||
| 80 | static unsigned int *OBJ_bsearch_ln(const ASN1_OBJECT * *key, unsigned int const *base, int num); | ||
| 81 | static int obj_cmp_BSEARCH_CMP_FN(const void *, const void *); | ||
| 82 | static int obj_cmp(const ASN1_OBJECT * const *, unsigned int const *); | ||
| 83 | static 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 | ||
| 98 | IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); | 104 | |
| 105 | static int | ||
| 106 | sn_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 | |||
| 113 | static unsigned int * | ||
| 114 | OBJ_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 | ||
| 100 | static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) | 120 | static 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 | ||
| 105 | IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); | 125 | |
| 126 | static int | ||
| 127 | ln_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 | |||
| 134 | static unsigned int * | ||
| 135 | OBJ_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 | ||
| 107 | static unsigned long | 141 | static unsigned long |
| 108 | added_obj_hash(const ADDED_OBJ *ca) | 142 | added_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 | ||
| 403 | IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); | 437 | |
| 438 | static int | ||
| 439 | obj_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 | |||
| 446 | static unsigned int * | ||
| 447 | OBJ_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 | ||
| 405 | int | 453 | int |
| 406 | OBJ_obj2nid(const ASN1_OBJECT *a) | 454 | OBJ_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 | ||
| 71 | DECLARE_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); | 71 | static int sig_cmp_BSEARCH_CMP_FN(const void *, const void *); |
| 72 | IMPLEMENT_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); | 72 | static int sig_cmp(nid_triple const *, nid_triple const *); |
| 73 | static nid_triple *OBJ_bsearch_sig(nid_triple *key, nid_triple const *base, int num); | ||
| 74 | |||
| 75 | static int | ||
| 76 | sig_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 | |||
| 83 | static nid_triple * | ||
| 84 | OBJ_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 | ||
| 74 | static int | 90 | static int |
| 75 | sig_sk_cmp(const nid_triple * const *a, const nid_triple * const *b) | 91 | sig_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 | ||
| 80 | DECLARE_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); | 96 | static int sigx_cmp_BSEARCH_CMP_FN(const void *, const void *); |
| 97 | static int sigx_cmp(const nid_triple * const *, const nid_triple * const *); | ||
| 98 | static const nid_triple * *OBJ_bsearch_sigx(const nid_triple * *key, const nid_triple * const *base, int num); | ||
| 81 | 99 | ||
| 82 | static int | 100 | static int |
| 83 | sigx_cmp(const nid_triple * const *a, const nid_triple * const *b) | 101 | sigx_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 | ||
| 93 | IMPLEMENT_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); | 111 | |
| 112 | static int | ||
| 113 | sigx_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 | |||
| 120 | static const nid_triple * * | ||
| 121 | OBJ_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 | ||
| 95 | int | 127 | int |
| 96 | OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid) | 128 | OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid) |
