From: tb Date: Fri, 15 Dec 2023 01:51:23 +0000 (+0000) Subject: Hoist OBJ_sn2nid() over OBJ_ln2nid() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bd5b787cc4986966ead549dfccedfacbbe5ba2fe;p=openbsd Hoist OBJ_sn2nid() over OBJ_ln2nid() In all other places, the short name comes before the long name, so fix the only exception. --- diff --git a/lib/libcrypto/objects/obj_dat.c b/lib/libcrypto/objects/obj_dat.c index f97a5b76d9d..e72598ef616 100644 --- a/lib/libcrypto/objects/obj_dat.c +++ b/lib/libcrypto/objects/obj_dat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_dat.c,v 1.81 2023/12/15 01:47:50 tb Exp $ */ +/* $OpenBSD: obj_dat.c,v 1.82 2023/12/15 01:51:23 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -377,27 +377,27 @@ OBJ_obj2nid(const ASN1_OBJECT *aobj) LCRYPTO_ALIAS(OBJ_obj2nid); static int -ln_objs_cmp(const void *ln, const void *b) +sn_objs_cmp(const void *sn, const void *b) { const unsigned int *nid = b; OPENSSL_assert(*nid < NUM_NID); - return strcmp(ln, nid_objs[*nid].ln); + return strcmp(sn, nid_objs[*nid].sn); } int -OBJ_ln2nid(const char *ln) +OBJ_sn2nid(const char *sn) { const unsigned int *nid; /* XXX - locking. OpenSSL 3 moved this after built-in object lookup. */ if (added != NULL) { ASN1_OBJECT aobj = { - .ln = ln, + .sn = sn, }; ADDED_OBJ needle = { - .type = ADDED_LNAME, + .type = ADDED_SNAME, .obj = &aobj, }; ADDED_OBJ *found; @@ -406,37 +406,37 @@ OBJ_ln2nid(const char *ln) return found->obj->nid; } - /* ln_objs holds NIDs in ascending alphabetical order of LN. */ - nid = bsearch(ln, ln_objs, NUM_LN, sizeof(unsigned int), ln_objs_cmp); + /* sn_objs holds NIDs in ascending alphabetical order of SN. */ + nid = bsearch(sn, sn_objs, NUM_SN, sizeof(unsigned int), sn_objs_cmp); if (nid != NULL) return *nid; return NID_undef; } -LCRYPTO_ALIAS(OBJ_ln2nid); +LCRYPTO_ALIAS(OBJ_sn2nid); static int -sn_objs_cmp(const void *sn, const void *b) +ln_objs_cmp(const void *ln, const void *b) { const unsigned int *nid = b; OPENSSL_assert(*nid < NUM_NID); - return strcmp(sn, nid_objs[*nid].sn); + return strcmp(ln, nid_objs[*nid].ln); } int -OBJ_sn2nid(const char *sn) +OBJ_ln2nid(const char *ln) { const unsigned int *nid; /* XXX - locking. OpenSSL 3 moved this after built-in object lookup. */ if (added != NULL) { ASN1_OBJECT aobj = { - .sn = sn, + .ln = ln, }; ADDED_OBJ needle = { - .type = ADDED_SNAME, + .type = ADDED_LNAME, .obj = &aobj, }; ADDED_OBJ *found; @@ -445,14 +445,14 @@ OBJ_sn2nid(const char *sn) return found->obj->nid; } - /* sn_objs holds NIDs in ascending alphabetical order of SN. */ - nid = bsearch(sn, sn_objs, NUM_SN, sizeof(unsigned int), sn_objs_cmp); + /* ln_objs holds NIDs in ascending alphabetical order of LN. */ + nid = bsearch(ln, ln_objs, NUM_LN, sizeof(unsigned int), ln_objs_cmp); if (nid != NULL) return *nid; return NID_undef; } -LCRYPTO_ALIAS(OBJ_sn2nid); +LCRYPTO_ALIAS(OBJ_ln2nid); const void * OBJ_bsearch_(const void *key, const void *base, int num, int size,