summaryrefslogtreecommitdiff
path: root/lib/libcrypto/objects/obj_dat.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2022-03-19 17:49:33 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2022-03-19 17:49:33 +0000
commit083364c45a737067b6c3fc9f323abdcbd13cb211 (patch)
tree9c4b66388d408da8b90d4a6da0627ea48862a2b9 /lib/libcrypto/objects/obj_dat.c
parent3d61ea903d018f376c126f03f1d53081f872b5b7 (diff)
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 'lib/libcrypto/objects/obj_dat.c')
-rw-r--r--lib/libcrypto/objects/obj_dat.c33
1 files changed, 3 insertions, 30 deletions
diff --git a/lib/libcrypto/objects/obj_dat.c b/lib/libcrypto/objects/obj_dat.c
index 786bed6c7ab..bcb7ee2dbbd 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.48 2022/03/02 11:28:00 jsing Exp $ */
+/* $OpenBSD: obj_dat.c,v 1.49 2022/03/19 17:49:32 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -485,12 +485,7 @@ OBJ_obj2nid(const ASN1_OBJECT *a)
ASN1_OBJECT *
OBJ_txt2obj(const char *s, int no_name)
{
- int nid = NID_undef;
- ASN1_OBJECT *op = NULL;
- unsigned char *buf;
- unsigned char *p;
- const unsigned char *cp;
- int i, j;
+ int nid;
if (!no_name) {
if (((nid = OBJ_sn2nid(s)) != NID_undef) ||
@@ -498,29 +493,7 @@ OBJ_txt2obj(const char *s, int no_name)
return OBJ_nid2obj(nid);
}
- /* Work out size of content octets */
- i = a2d_ASN1_OBJECT(NULL, 0, s, -1);
- if (i <= 0) {
- /* Don't clear the error */
- /*ERR_clear_error();*/
- return NULL;
- }
- /* Work out total size */
- j = ASN1_object_size(0, i, V_ASN1_OBJECT);
-
- if ((buf = malloc(j)) == NULL)
- return NULL;
-
- p = buf;
- /* Write out tag+length */
- ASN1_put_object(&p, 0, i, V_ASN1_OBJECT, V_ASN1_UNIVERSAL);
- /* Write out contents */
- a2d_ASN1_OBJECT(p, i, s, -1);
-
- cp = buf;
- op = d2i_ASN1_OBJECT(NULL, &cp, j);
- free(buf);
- return op;
+ return t2i_ASN1_OBJECT_internal(s);
}
int