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.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/src/lib/libcrypto/asn1/asn1_par.c b/src/lib/libcrypto/asn1/asn1_par.c
index d1e9816bad..facfdd27fc 100644
--- a/src/lib/libcrypto/asn1/asn1_par.c
+++ b/src/lib/libcrypto/asn1/asn1_par.c
@@ -65,7 +65,7 @@
65static int asn1_print_info(BIO *bp, int tag, int xclass,int constructed, 65static int asn1_print_info(BIO *bp, int tag, int xclass,int constructed,
66 int indent); 66 int indent);
67static int asn1_parse2(BIO *bp, unsigned char **pp, long length, 67static int asn1_parse2(BIO *bp, unsigned char **pp, long length,
68 int offset, int depth, int indent); 68 int offset, int depth, int indent, int dump);
69static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed, 69static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
70 int indent) 70 int indent)
71 { 71 {
@@ -110,11 +110,16 @@ err:
110 110
111int ASN1_parse(BIO *bp, unsigned char *pp, long len, int indent) 111int ASN1_parse(BIO *bp, unsigned char *pp, long len, int indent)
112 { 112 {
113 return(asn1_parse2(bp,&pp,len,0,0,indent)); 113 return(asn1_parse2(bp,&pp,len,0,0,indent,0));
114 }
115
116int ASN1_parse_dump(BIO *bp, unsigned char *pp, long len, int indent, int dump)
117 {
118 return(asn1_parse2(bp,&pp,len,0,0,indent,dump));
114 } 119 }
115 120
116static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset, 121static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
117 int depth, int indent) 122 int depth, int indent, int dump)
118 { 123 {
119 unsigned char *p,*ep,*tot,*op,*opp; 124 unsigned char *p,*ep,*tot,*op,*opp;
120 long len; 125 long len;
@@ -123,7 +128,13 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
123 ASN1_OBJECT *o=NULL; 128 ASN1_OBJECT *o=NULL;
124 ASN1_OCTET_STRING *os=NULL; 129 ASN1_OCTET_STRING *os=NULL;
125 /* ASN1_BMPSTRING *bmp=NULL;*/ 130 /* ASN1_BMPSTRING *bmp=NULL;*/
131 int dump_indent;
126 132
133#if 0
134 dump_indent = indent;
135#else
136 dump_indent = 6; /* Because we know BIO_dump_indent() */
137#endif
127 p= *pp; 138 p= *pp;
128 tot=p+length; 139 tot=p+length;
129 op=p-1; 140 op=p-1;
@@ -178,7 +189,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
178 { 189 {
179 r=asn1_parse2(bp,&p,(long)(tot-p), 190 r=asn1_parse2(bp,&p,(long)(tot-p),
180 offset+(p - *pp),depth+1, 191 offset+(p - *pp),depth+1,
181 indent); 192 indent,dump);
182 if (r == 0) { ret=0; goto end; } 193 if (r == 0) { ret=0; goto end; }
183 if ((r == 2) || (p >= tot)) break; 194 if ((r == 2) || (p >= tot)) break;
184 } 195 }
@@ -188,7 +199,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
188 { 199 {
189 r=asn1_parse2(bp,&p,(long)len, 200 r=asn1_parse2(bp,&p,(long)len,
190 offset+(p - *pp),depth+1, 201 offset+(p - *pp),depth+1,
191 indent); 202 indent,dump);
192 if (r == 0) { ret=0; goto end; } 203 if (r == 0) { ret=0; goto end; }
193 } 204 }
194 } 205 }
@@ -273,6 +284,20 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
273 os->length) <= 0) 284 os->length) <= 0)
274 goto end; 285 goto end;
275 } 286 }
287 if (!printable && (os->length > 0)
288 && dump)
289 {
290 if (!nl)
291 {
292 if (BIO_write(bp,"\n",1) <= 0)
293 goto end;
294 }
295 if (BIO_dump_indent(bp,(char *)opp,
296 ((dump == -1 || dump > os->length)?os->length:dump),
297 dump_indent) <= 0)
298 goto end;
299 nl=1;
300 }
276 M_ASN1_OCTET_STRING_free(os); 301 M_ASN1_OCTET_STRING_free(os);
277 os=NULL; 302 os=NULL;
278 } 303 }
@@ -341,6 +366,19 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
341 } 366 }
342 M_ASN1_ENUMERATED_free(bs); 367 M_ASN1_ENUMERATED_free(bs);
343 } 368 }
369 else if (len > 0 && dump)
370 {
371 if (!nl)
372 {
373 if (BIO_write(bp,"\n",1) <= 0)
374 goto end;
375 }
376 if (BIO_dump_indent(bp,(char *)p,
377 ((dump == -1 || dump > len)?len:dump),
378 dump_indent) <= 0)
379 goto end;
380 nl=1;
381 }
344 382
345 if (!nl) 383 if (!nl)
346 { 384 {