summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_strnid.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_strnid.c')
-rw-r--r--src/lib/libcrypto/asn1/a_strnid.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c
index fe515b52ba..753021a7a2 100644
--- a/src/lib/libcrypto/asn1/a_strnid.c
+++ b/src/lib/libcrypto/asn1/a_strnid.c
@@ -67,7 +67,6 @@ static STACK_OF(ASN1_STRING_TABLE) *stable = NULL;
67static void st_free(ASN1_STRING_TABLE *tbl); 67static void st_free(ASN1_STRING_TABLE *tbl);
68static int sk_table_cmp(const ASN1_STRING_TABLE * const *a, 68static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
69 const ASN1_STRING_TABLE * const *b); 69 const ASN1_STRING_TABLE * const *b);
70static int table_cmp(const void *a, const void *b);
71 70
72 71
73/* This is the global mask for the mbstring functions: this is use to 72/* This is the global mask for the mbstring functions: this is use to
@@ -158,7 +157,7 @@ ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in,
158 157
159/* This table must be kept in NID order */ 158/* This table must be kept in NID order */
160 159
161static ASN1_STRING_TABLE tbl_standard[] = { 160static const ASN1_STRING_TABLE tbl_standard[] = {
162{NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0}, 161{NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
163{NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}, 162{NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
164{NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0}, 163{NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
@@ -186,22 +185,23 @@ static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
186 return (*a)->nid - (*b)->nid; 185 return (*a)->nid - (*b)->nid;
187} 186}
188 187
189static int table_cmp(const void *a, const void *b) 188DECLARE_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table);
189
190static int table_cmp(const ASN1_STRING_TABLE *a, const ASN1_STRING_TABLE *b)
190{ 191{
191 const ASN1_STRING_TABLE *sa = a, *sb = b; 192 return a->nid - b->nid;
192 return sa->nid - sb->nid;
193} 193}
194 194
195IMPLEMENT_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table);
196
195ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid) 197ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
196{ 198{
197 int idx; 199 int idx;
198 ASN1_STRING_TABLE *ttmp; 200 ASN1_STRING_TABLE *ttmp;
199 ASN1_STRING_TABLE fnd; 201 ASN1_STRING_TABLE fnd;
200 fnd.nid = nid; 202 fnd.nid = nid;
201 ttmp = (ASN1_STRING_TABLE *) OBJ_bsearch((char *)&fnd, 203 ttmp = OBJ_bsearch_table(&fnd, tbl_standard,
202 (char *)tbl_standard, 204 sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE));
203 sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE),
204 sizeof(ASN1_STRING_TABLE), table_cmp);
205 if(ttmp) return ttmp; 205 if(ttmp) return ttmp;
206 if(!stable) return NULL; 206 if(!stable) return NULL;
207 idx = sk_ASN1_STRING_TABLE_find(stable, &fnd); 207 idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);