diff options
author | tb <> | 2023-12-14 14:02:57 +0000 |
---|---|---|
committer | tb <> | 2023-12-14 14:02:57 +0000 |
commit | 73fcdec30ae4ba0b75e32641abc8c1761c164598 (patch) | |
tree | 62834abcf375de2ba62a75e41ed6f4b6f51cdc8d /src | |
parent | 328833ccd96cfb7a5e2eac21582ffb6cbba6f312 (diff) | |
download | openbsd-73fcdec30ae4ba0b75e32641abc8c1761c164598.tar.gz openbsd-73fcdec30ae4ba0b75e32641abc8c1761c164598.tar.bz2 openbsd-73fcdec30ae4ba0b75e32641abc8c1761c164598.zip |
Simplify OBJ_nid2sn()
This is exactly the same as the previous OBJ_nid2ln() change modulo
s/ln/sn/g.
ok jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/objects/obj_dat.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c index 505de360fb..336673aefe 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.66 2023/12/14 14:01:42 tb Exp $ */ | 1 | /* $OpenBSD: obj_dat.c,v 1.67 2023/12/14 14:02:57 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 | * |
@@ -308,31 +308,34 @@ OBJ_nid2obj(int n) | |||
308 | LCRYPTO_ALIAS(OBJ_nid2obj); | 308 | LCRYPTO_ALIAS(OBJ_nid2obj); |
309 | 309 | ||
310 | const char * | 310 | const char * |
311 | OBJ_nid2sn(int n) | 311 | OBJ_nid2sn(int nid) |
312 | { | 312 | { |
313 | ADDED_OBJ ad, *adp; | 313 | if (nid >= 0 && nid < NUM_NID) { |
314 | ASN1_OBJECT ob; | 314 | if (nid == NID_undef || nid_objs[nid].nid != NID_undef) |
315 | return nid_objs[nid].sn; | ||
315 | 316 | ||
316 | if ((n >= 0) && (n < NUM_NID)) { | 317 | goto unknown; |
317 | if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) { | 318 | } |
318 | OBJerror(OBJ_R_UNKNOWN_NID); | 319 | |
319 | return (NULL); | 320 | /* XXX - locking. */ |
320 | } | 321 | if (added != NULL) { |
321 | return (nid_objs[n].sn); | 322 | ASN1_OBJECT aobj = { |
322 | } else if (added == NULL) | 323 | .nid = nid, |
323 | return (NULL); | 324 | }; |
324 | else { | 325 | ADDED_OBJ needle = { |
325 | ad.type = ADDED_NID; | 326 | .type = ADDED_NID, |
326 | ad.obj = &ob; | 327 | .obj = &aobj, |
327 | ob.nid = n; | 328 | }; |
328 | adp = lh_ADDED_OBJ_retrieve(added, &ad); | 329 | ADDED_OBJ *found; |
329 | if (adp != NULL) | 330 | |
330 | return (adp->obj->sn); | 331 | if ((found = lh_ADDED_OBJ_retrieve(added, &needle)) != NULL) |
331 | else { | 332 | return found->obj->sn; |
332 | OBJerror(OBJ_R_UNKNOWN_NID); | ||
333 | return (NULL); | ||
334 | } | ||
335 | } | 333 | } |
334 | |||
335 | unknown: | ||
336 | OBJerror(OBJ_R_UNKNOWN_NID); | ||
337 | |||
338 | return NULL; | ||
336 | } | 339 | } |
337 | LCRYPTO_ALIAS(OBJ_nid2sn); | 340 | LCRYPTO_ALIAS(OBJ_nid2sn); |
338 | 341 | ||