diff --git a/CHANGES b/CHANGES index 66db4d6f174419a72c9a6194bb7b69b5863fa03c..df6dbeb0b73015eddb21c2d9a813133a8d96bb88 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,11 @@ Changes between 0.9.2b and 0.9.3 + *) New option -out to asn1parse to allow the parsed structure to be + output to a file. This is most useful when combined with the -strparse + option to examine the output of things like OCTET STRINGS. + [Steve Henson] + *) Make SSL library a little more fool-proof by not requiring any longer that SSL_set_{accept,connect}_state be called before SSL_{accept,connect} may be used (SSL_set_..._state is omitted diff --git a/apps/asn1pars.c b/apps/asn1pars.c index a5e4bfcf5e8a54e26f664bd921304853f792223d..c7e9cf43d8695c630ca75d20b02bde1e5f539b52 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -85,9 +85,9 @@ int MAIN(int argc, char **argv) int i,badops=0,offset=0,ret=1,j; unsigned int length=0; long num,tmplen; - BIO *in=NULL,*out=NULL,*b64=NULL; + BIO *in=NULL,*out=NULL,*b64=NULL, *derout = NULL; int informat,indent=0; - char *infile=NULL,*str=NULL,*prog,*oidfile=NULL; + char *infile=NULL,*str=NULL,*prog,*oidfile=NULL, *derfile=NULL; unsigned char *tmpbuf; BUF_MEM *buf=NULL; STACK *osk=NULL; @@ -121,6 +121,11 @@ int MAIN(int argc, char **argv) if (--argc < 1) goto bad; infile= *(++argv); } + else if (strcmp(*argv,"-out") == 0) + { + if (--argc < 1) goto bad; + derfile= *(++argv); + } else if (strcmp(*argv,"-i") == 0) { indent=1; @@ -170,6 +175,7 @@ bad: BIO_printf(bio_err," -strparse offset\n"); BIO_printf(bio_err," a series of these can be used to 'dig' into multiple\n"); BIO_printf(bio_err," ASN1 blob wrappings\n"); + BIO_printf(bio_err," -out filename output DER encoding to file\n"); goto end; } @@ -206,6 +212,14 @@ bad: } } + if (derfile) { + if(!(derout = BIO_new_file(derfile, "wb"))) { + BIO_printf(bio_err,"problems opening %s\n",derfile); + ERR_print_errors(bio_err); + goto end; + } + } + if ((buf=BUF_MEM_new()) == NULL) goto end; if (!BUF_MEM_grow(buf,BUFSIZ*8)) goto end; /* Pre-allocate :-) */ @@ -239,6 +253,7 @@ bad: tmplen=num; for (i=0; i