diff options
Diffstat (limited to 'crypto/asn1')
-rw-r--r-- | crypto/asn1/asn1.h | 1 | ||||
-rw-r--r-- | crypto/asn1/asn1_par.c | 48 |
2 files changed, 44 insertions, 5 deletions
diff --git a/crypto/asn1/asn1.h b/crypto/asn1/asn1.h index 79df50a85b..e269644128 100644 --- a/crypto/asn1/asn1.h +++ b/crypto/asn1/asn1.h @@ -737,6 +737,7 @@ int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a); int ASN1_TIME_print(BIO *fp,ASN1_TIME *a); int ASN1_STRING_print(BIO *bp,ASN1_STRING *v); int ASN1_parse(BIO *bp,unsigned char *pp,long len,int indent); +int ASN1_parse_dump(BIO *bp,unsigned char *pp,long len,int indent,int dump); #endif const char *ASN1_tag2str(int tag); diff --git a/crypto/asn1/asn1_par.c b/crypto/asn1/asn1_par.c index d1e9816bad..dc868a4d87 100644 --- a/crypto/asn1/asn1_par.c +++ b/crypto/asn1/asn1_par.c @@ -65,7 +65,7 @@ static int asn1_print_info(BIO *bp, int tag, int xclass,int constructed, int indent); static int asn1_parse2(BIO *bp, unsigned char **pp, long length, - int offset, int depth, int indent); + int offset, int depth, int indent, int dump); static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed, int indent) { @@ -110,11 +110,16 @@ err: int ASN1_parse(BIO *bp, unsigned char *pp, long len, int indent) { - return(asn1_parse2(bp,&pp,len,0,0,indent)); + return(asn1_parse2(bp,&pp,len,0,0,indent,0)); + } + +int ASN1_parse_dump(BIO *bp, unsigned char *pp, long len, int indent, int dump) + { + return(asn1_parse2(bp,&pp,len,0,0,indent,dump)); } static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset, - int depth, int indent) + int depth, int indent, int dump) { unsigned char *p,*ep,*tot,*op,*opp; long len; @@ -123,7 +128,13 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset, ASN1_OBJECT *o=NULL; ASN1_OCTET_STRING *os=NULL; /* ASN1_BMPSTRING *bmp=NULL;*/ + int dump_indent; +#if 0 + dump_indent = indent; +#else + dump_indent = 6; /* Because we know BIO_dump_indent() */ +#endif p= *pp; tot=p+length; op=p-1; @@ -178,7 +189,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset, { r=asn1_parse2(bp,&p,(long)(tot-p), offset+(p - *pp),depth+1, - indent); + indent,dump); if (r == 0) { ret=0; goto end; } if ((r == 2) || (p >= tot)) break; } @@ -188,7 +199,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset, { r=asn1_parse2(bp,&p,(long)len, offset+(p - *pp),depth+1, - indent); + indent,dump); if (r == 0) { ret=0; goto end; } } } @@ -273,6 +284,20 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset, os->length) <= 0) goto end; } + if (!printable && (os->length > 0) + && dump) + { + if (!nl) + { + if (BIO_write(bp,"\n",1) <= 0) + goto end; + } + if (BIO_dump_indent(bp,opp, + ((dump == -1 || dump > os->length)?os->length:dump), + dump_indent) <= 0) + goto end; + nl=1; + } M_ASN1_OCTET_STRING_free(os); os=NULL; } @@ -341,6 +366,19 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset, } M_ASN1_ENUMERATED_free(bs); } + else if (len > 0 && dump) + { + if (!nl) + { + if (BIO_write(bp,"\n",1) <= 0) + goto end; + } + if (BIO_dump_indent(bp,p, + ((dump == -1 || dump > len)?len:dump), + dump_indent) <= 0) + goto end; + nl=1; + } if (!nl) { |