65 static int asn1_print_info(
BIO *
bp,
int tag,
int xclass,
int constructed,
67 static int asn1_parse2(
BIO *
bp,
const unsigned char **
pp,
long length,
68 int offset,
int depth,
int indent,
int dump);
69 static int asn1_print_info(
BIO *
bp,
int tag,
int xclass,
int constructed,
72 static const char fmt[]=
"%-18s";
104 return(asn1_parse2(bp,&pp,len,0,0,indent,0));
109 return(asn1_parse2(bp,&pp,len,0,0,indent,dump));
112 static int asn1_parse2(
BIO *bp,
const unsigned char **
pp,
long length,
int offset,
113 int depth,
int indent,
int dump)
115 const unsigned char *
p,*ep,*tot,*op,*opp;
117 int tag,xclass,ret=0;
125 dump_indent = indent;
132 while ((p < tot) && (op < p))
141 if (
BIO_write(bp,
"Error in encoding\n",18) <= 0)
149 if (
BIO_printf(bp,
"%5ld:",(
long)offset+(
long)(op- *pp))
152 if (j != (V_ASN1_CONSTRUCTED | 1))
155 depth,(
long)hl,len) <= 0)
161 depth,(
long)hl) <= 0)
164 if (!asn1_print_info(bp,tag,xclass,j,(indent)?depth:0))
166 if (j & V_ASN1_CONSTRUCTED)
173 "length is greater than %ld\n",length);
177 if ((j == 0x21) && (len == 0))
181 r=asn1_parse2(bp,&p,(
long)(tot-p),
182 offset+(p - *pp),depth+1,
184 if (r == 0) { ret=0;
goto end; }
185 if ((r == 2) || (p >= tot))
break;
191 r=asn1_parse2(bp,&p,(
long)len,
192 offset+(p - *pp),depth+1,
194 if (r == 0) { ret=0;
goto end; }
197 else if (xclass != 0)
242 if (
BIO_write(bp,
"Bad boolean\n",12) <= 0)
256 os=d2i_ASN1_OCTET_STRING(NULL,&opp,len+hl);
257 if (os != NULL && os->
length > 0)
262 for (i=0; i<os->
length; i++)
264 if (( (opp[i] <
' ') &&
289 for (i=0; i<os->
length; i++)
306 ((dump == -1 || dump >
325 bs=d2i_ASN1_INTEGER(NULL,&opp,len+hl);
332 for (i=0; i<bs->
length; i++)
357 bs=d2i_ASN1_ENUMERATED(NULL,&opp,len+hl);
364 for (i=0; i<bs->
length; i++)
378 if (
BIO_write(bp,
"BAD ENUMERATED",11) <= 0)
383 else if (len > 0 && dump)
391 ((dump == -1 || dump > len)?len:dump),
420 static const char *
const tag2str[] = {
421 "EOC",
"BOOLEAN",
"INTEGER",
"BIT STRING",
"OCTET STRING",
422 "NULL",
"OBJECT",
"OBJECT DESCRIPTOR",
"EXTERNAL",
"REAL",
423 "ENUMERATED",
"<ASN1 11>",
"UTF8STRING",
"<ASN1 13>",
424 "<ASN1 14>",
"<ASN1 15>",
"SEQUENCE",
"SET",
425 "NUMERICSTRING",
"PRINTABLESTRING",
"T61STRING",
426 "VIDEOTEXSTRING",
"IA5STRING",
"UTCTIME",
"GENERALIZEDTIME",
427 "GRAPHICSTRING",
"VISIBLESTRING",
"GENERALSTRING",
428 "UNIVERSALSTRING",
"<ASN1 29>",
"BMPSTRING"
434 if(tag < 0 || tag > 30)
return "(unknown)";