summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-12-15 01:51:23 +0000
committertb <>2023-12-15 01:51:23 +0000
commit884ca327ec84fbad9a6f32474fd2089181a29138 (patch)
tree052995a6a5ae5e31c51ed8e07ba242d0f006af0a /src
parent32b6fa1b20f4be67189b213957c2df33b762df2b (diff)
downloadopenbsd-884ca327ec84fbad9a6f32474fd2089181a29138.tar.gz
openbsd-884ca327ec84fbad9a6f32474fd2089181a29138.tar.bz2
openbsd-884ca327ec84fbad9a6f32474fd2089181a29138.zip
Hoist OBJ_sn2nid() over OBJ_ln2nid()
In all other places, the short name comes before the long name, so fix the only exception.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index f97a5b76d9..e72598ef61 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.81 2023/12/15 01:47:50 tb Exp $ */ 1/* $OpenBSD: obj_dat.c,v 1.82 2023/12/15 01:51:23 tb 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 *
@@ -377,27 +377,27 @@ OBJ_obj2nid(const ASN1_OBJECT *aobj)
377LCRYPTO_ALIAS(OBJ_obj2nid); 377LCRYPTO_ALIAS(OBJ_obj2nid);
378 378
379static int 379static int
380ln_objs_cmp(const void *ln, const void *b) 380sn_objs_cmp(const void *sn, const void *b)
381{ 381{
382 const unsigned int *nid = b; 382 const unsigned int *nid = b;
383 383
384 OPENSSL_assert(*nid < NUM_NID); 384 OPENSSL_assert(*nid < NUM_NID);
385 385
386 return strcmp(ln, nid_objs[*nid].ln); 386 return strcmp(sn, nid_objs[*nid].sn);
387} 387}
388 388
389int 389int
390OBJ_ln2nid(const char *ln) 390OBJ_sn2nid(const char *sn)
391{ 391{
392 const unsigned int *nid; 392 const unsigned int *nid;
393 393
394 /* XXX - locking. OpenSSL 3 moved this after built-in object lookup. */ 394 /* XXX - locking. OpenSSL 3 moved this after built-in object lookup. */
395 if (added != NULL) { 395 if (added != NULL) {
396 ASN1_OBJECT aobj = { 396 ASN1_OBJECT aobj = {
397 .ln = ln, 397 .sn = sn,
398 }; 398 };
399 ADDED_OBJ needle = { 399 ADDED_OBJ needle = {
400 .type = ADDED_LNAME, 400 .type = ADDED_SNAME,
401 .obj = &aobj, 401 .obj = &aobj,
402 }; 402 };
403 ADDED_OBJ *found; 403 ADDED_OBJ *found;
@@ -406,37 +406,37 @@ OBJ_ln2nid(const char *ln)
406 return found->obj->nid; 406 return found->obj->nid;
407 } 407 }
408 408
409 /* ln_objs holds NIDs in ascending alphabetical order of LN. */ 409 /* sn_objs holds NIDs in ascending alphabetical order of SN. */
410 nid = bsearch(ln, ln_objs, NUM_LN, sizeof(unsigned int), ln_objs_cmp); 410 nid = bsearch(sn, sn_objs, NUM_SN, sizeof(unsigned int), sn_objs_cmp);
411 if (nid != NULL) 411 if (nid != NULL)
412 return *nid; 412 return *nid;
413 413
414 return NID_undef; 414 return NID_undef;
415} 415}
416LCRYPTO_ALIAS(OBJ_ln2nid); 416LCRYPTO_ALIAS(OBJ_sn2nid);
417 417
418static int 418static int
419sn_objs_cmp(const void *sn, const void *b) 419ln_objs_cmp(const void *ln, const void *b)
420{ 420{
421 const unsigned int *nid = b; 421 const unsigned int *nid = b;
422 422
423 OPENSSL_assert(*nid < NUM_NID); 423 OPENSSL_assert(*nid < NUM_NID);
424 424
425 return strcmp(sn, nid_objs[*nid].sn); 425 return strcmp(ln, nid_objs[*nid].ln);
426} 426}
427 427
428int 428int
429OBJ_sn2nid(const char *sn) 429OBJ_ln2nid(const char *ln)
430{ 430{
431 const unsigned int *nid; 431 const unsigned int *nid;
432 432
433 /* XXX - locking. OpenSSL 3 moved this after built-in object lookup. */ 433 /* XXX - locking. OpenSSL 3 moved this after built-in object lookup. */
434 if (added != NULL) { 434 if (added != NULL) {
435 ASN1_OBJECT aobj = { 435 ASN1_OBJECT aobj = {
436 .sn = sn, 436 .ln = ln,
437 }; 437 };
438 ADDED_OBJ needle = { 438 ADDED_OBJ needle = {
439 .type = ADDED_SNAME, 439 .type = ADDED_LNAME,
440 .obj = &aobj, 440 .obj = &aobj,
441 }; 441 };
442 ADDED_OBJ *found; 442 ADDED_OBJ *found;
@@ -445,14 +445,14 @@ OBJ_sn2nid(const char *sn)
445 return found->obj->nid; 445 return found->obj->nid;
446 } 446 }
447 447
448 /* sn_objs holds NIDs in ascending alphabetical order of SN. */ 448 /* ln_objs holds NIDs in ascending alphabetical order of LN. */
449 nid = bsearch(sn, sn_objs, NUM_SN, sizeof(unsigned int), sn_objs_cmp); 449 nid = bsearch(ln, ln_objs, NUM_LN, sizeof(unsigned int), ln_objs_cmp);
450 if (nid != NULL) 450 if (nid != NULL)
451 return *nid; 451 return *nid;
452 452
453 return NID_undef; 453 return NID_undef;
454} 454}
455LCRYPTO_ALIAS(OBJ_sn2nid); 455LCRYPTO_ALIAS(OBJ_ln2nid);
456 456
457const void * 457const void *
458OBJ_bsearch_(const void *key, const void *base, int num, int size, 458OBJ_bsearch_(const void *key, const void *base, int num, int size,