summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/asn1_par.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/asn1_par.c')
-rw-r--r--src/lib/libcrypto/asn1/asn1_par.c78
1 files changed, 26 insertions, 52 deletions
diff --git a/src/lib/libcrypto/asn1/asn1_par.c b/src/lib/libcrypto/asn1/asn1_par.c
index 86886606ef..d1e9816bad 100644
--- a/src/lib/libcrypto/asn1/asn1_par.c
+++ b/src/lib/libcrypto/asn1/asn1_par.c
@@ -93,55 +93,8 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
93 sprintf(str,"cont [ %d ]",tag); 93 sprintf(str,"cont [ %d ]",tag);
94 else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION) 94 else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
95 sprintf(str,"appl [ %d ]",tag); 95 sprintf(str,"appl [ %d ]",tag);
96 else if ((tag == V_ASN1_EOC) /* && (xclass == V_ASN1_UNIVERSAL) */) 96 else p = ASN1_tag2str(tag);
97 p="EOC";
98 else if (tag == V_ASN1_BOOLEAN)
99 p="BOOLEAN";
100 else if (tag == V_ASN1_INTEGER)
101 p="INTEGER";
102 else if (tag == V_ASN1_ENUMERATED)
103 p="ENUMERATED";
104 else if (tag == V_ASN1_BIT_STRING)
105 p="BIT STRING";
106 else if (tag == V_ASN1_OCTET_STRING)
107 p="OCTET STRING";
108 else if (tag == V_ASN1_NULL)
109 p="NULL";
110 else if (tag == V_ASN1_OBJECT)
111 p="OBJECT";
112 else if (tag == V_ASN1_SEQUENCE)
113 p="SEQUENCE";
114 else if (tag == V_ASN1_SET)
115 p="SET";
116 else if (tag == V_ASN1_PRINTABLESTRING)
117 p="PRINTABLESTRING";
118 else if (tag == V_ASN1_T61STRING)
119 p="T61STRING";
120 else if (tag == V_ASN1_IA5STRING)
121 p="IA5STRING";
122 else if (tag == V_ASN1_UTCTIME)
123 p="UTCTIME";
124 97
125 /* extras */
126 else if (tag == V_ASN1_NUMERICSTRING)
127 p="NUMERICSTRING";
128 else if (tag == V_ASN1_VIDEOTEXSTRING)
129 p="VIDEOTEXSTRING";
130 else if (tag == V_ASN1_GENERALIZEDTIME)
131 p="GENERALIZEDTIME";
132 else if (tag == V_ASN1_GRAPHICSTRING)
133 p="GRAPHICSTRING";
134 else if (tag == V_ASN1_VISIBLESTRING)
135 p="VISIBLESTRING";
136 else if (tag == V_ASN1_GENERALSTRING)
137 p="GENERALSTRING";
138 else if (tag == V_ASN1_UNIVERSALSTRING)
139 p="UNIVERSALSTRING";
140 else if (tag == V_ASN1_BMPSTRING)
141 p="BMPSTRING";
142 else
143 p2="(unknown)";
144
145 if (p2 != NULL) 98 if (p2 != NULL)
146 { 99 {
147 if (BIO_printf(bp,fmt2,tag,p2) <= 0) goto err; 100 if (BIO_printf(bp,fmt2,tag,p2) <= 0) goto err;
@@ -320,7 +273,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
320 os->length) <= 0) 273 os->length) <= 0)
321 goto end; 274 goto end;
322 } 275 }
323 ASN1_OCTET_STRING_free(os); 276 M_ASN1_OCTET_STRING_free(os);
324 os=NULL; 277 os=NULL;
325 } 278 }
326 } 279 }
@@ -354,7 +307,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
354 if (BIO_write(bp,"BAD INTEGER",11) <= 0) 307 if (BIO_write(bp,"BAD INTEGER",11) <= 0)
355 goto end; 308 goto end;
356 } 309 }
357 ASN1_INTEGER_free(bs); 310 M_ASN1_INTEGER_free(bs);
358 } 311 }
359 else if (tag == V_ASN1_ENUMERATED) 312 else if (tag == V_ASN1_ENUMERATED)
360 { 313 {
@@ -386,7 +339,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
386 if (BIO_write(bp,"BAD ENUMERATED",11) <= 0) 339 if (BIO_write(bp,"BAD ENUMERATED",11) <= 0)
387 goto end; 340 goto end;
388 } 341 }
389 ASN1_ENUMERATED_free(bs); 342 M_ASN1_ENUMERATED_free(bs);
390 } 343 }
391 344
392 if (!nl) 345 if (!nl)
@@ -405,7 +358,28 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
405 ret=1; 358 ret=1;
406end: 359end:
407 if (o != NULL) ASN1_OBJECT_free(o); 360 if (o != NULL) ASN1_OBJECT_free(o);
408 if (os != NULL) ASN1_OCTET_STRING_free(os); 361 if (os != NULL) M_ASN1_OCTET_STRING_free(os);
409 *pp=p; 362 *pp=p;
410 return(ret); 363 return(ret);
411 } 364 }
365
366const char *ASN1_tag2str(int tag)
367{
368 const static char *tag2str[] = {
369 "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING", /* 0-4 */
370 "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL", /* 5-9 */
371 "ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>", /* 10-13 */
372 "<ASN1 14>", "<ASN1 15>", "SEQUENCE", "SET", /* 15-17 */
373 "NUMERICSTRING", "PRINTABLESTRING", "T61STRING", /* 18-20 */
374 "VIDEOTEXSTRING", "IA5STRING", "UTCTIME","GENERALIZEDTIME", /* 21-24 */
375 "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", /* 25-27 */
376 "UNIVERSALSTRING", "<ASN1 29>", "BMPSTRING" /* 28-30 */
377 };
378
379 if((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED))
380 tag &= ~0x100;
381
382 if(tag < 0 || tag > 30) return "(unknown)";
383 return tag2str[tag];
384}
385