summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/objects/obj_dat.c
diff options
context:
space:
mode:
authorjsing <>2022-03-19 17:49:32 +0000
committerjsing <>2022-03-19 17:49:32 +0000
commitd46a632ca35d3f62b29f97c14868a75a30a0ea74 (patch)
treed6cf88609bfc19f0101b68dd40457a903ba5c53a /src/lib/libcrypto/objects/obj_dat.c
parentee5ce96399d588340c4f57044a36ddb289fe2a7a (diff)
downloadopenbsd-d46a632ca35d3f62b29f97c14868a75a30a0ea74.tar.gz
openbsd-d46a632ca35d3f62b29f97c14868a75a30a0ea74.tar.bz2
openbsd-d46a632ca35d3f62b29f97c14868a75a30a0ea74.zip
Provide t2i_ASN1_OBJECT_internal() and use it for OBJ_txt2obj()
The current OBJ_txt2obj() implementation converts the text to ASN.1 object content octets, builds a full DER encoding from it, then feeds the entire thing back through the DER to ASN.1 object conversion. Rather than doing this crazy dance, provide an t2i_ASN1_OBJECT_internal() function that converts the text to ASN.1 object content octets, then creates a new ASN1_OBJECT and attaches the content octets to it. ok inoguchi@ tb@
Diffstat (limited to 'src/lib/libcrypto/objects/obj_dat.c')
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c33
1 files changed, 3 insertions, 30 deletions
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 786bed6c7a..bcb7ee2dbb 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.48 2022/03/02 11:28:00 jsing Exp $ */ 1/* $OpenBSD: obj_dat.c,v 1.49 2022/03/19 17:49:32 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 *
@@ -485,12 +485,7 @@ OBJ_obj2nid(const ASN1_OBJECT *a)
485ASN1_OBJECT * 485ASN1_OBJECT *
486OBJ_txt2obj(const char *s, int no_name) 486OBJ_txt2obj(const char *s, int no_name)
487{ 487{
488 int nid = NID_undef; 488 int nid;
489 ASN1_OBJECT *op = NULL;
490 unsigned char *buf;
491 unsigned char *p;
492 const unsigned char *cp;
493 int i, j;
494 489
495 if (!no_name) { 490 if (!no_name) {
496 if (((nid = OBJ_sn2nid(s)) != NID_undef) || 491 if (((nid = OBJ_sn2nid(s)) != NID_undef) ||
@@ -498,29 +493,7 @@ OBJ_txt2obj(const char *s, int no_name)
498 return OBJ_nid2obj(nid); 493 return OBJ_nid2obj(nid);
499 } 494 }
500 495
501 /* Work out size of content octets */ 496 return t2i_ASN1_OBJECT_internal(s);
502 i = a2d_ASN1_OBJECT(NULL, 0, s, -1);
503 if (i <= 0) {
504 /* Don't clear the error */
505 /*ERR_clear_error();*/
506 return NULL;
507 }
508 /* Work out total size */
509 j = ASN1_object_size(0, i, V_ASN1_OBJECT);
510
511 if ((buf = malloc(j)) == NULL)
512 return NULL;
513
514 p = buf;
515 /* Write out tag+length */
516 ASN1_put_object(&p, 0, i, V_ASN1_OBJECT, V_ASN1_UNIVERSAL);
517 /* Write out contents */
518 a2d_ASN1_OBJECT(p, i, s, -1);
519
520 cp = buf;
521 op = d2i_ASN1_OBJECT(NULL, &cp, j);
522 free(buf);
523 return op;
524} 497}
525 498
526int 499int