X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=apps%2Fasn1pars.c;h=8f178db851eb4d6b1d3b847f35c2d68cde379dd1;hb=c4c2c61e8ca8986de4636f9c63ae18a2c4e270ef;hp=8c9837ef81ca8d01fe84e66c36c2186afb410eb5;hpb=651d0aff98d28e2db146afa1790e9e22f3ef22db;p=openssl.git diff --git a/apps/asn1pars.c b/apps/asn1pars.c index 8c9837ef81..8f178db851 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -64,32 +64,32 @@ #include #include #include "apps.h" -#include "err.h" -#include "evp.h" -#include "x509.h" -#include "pem.h" +#include +#include +#include +#include /* -inform arg - input format - default PEM (DER or PEM) * -in arg - input file - default stdin * -i - indent the details by depth * -offset - where in the file to start * -length - how many bytes to use - * -oid file - extra oid decription file + * -oid file - extra oid description file */ #undef PROG #define PROG asn1parse_main -int MAIN(argc, argv) -int argc; -char **argv; +int MAIN(int, char **); + +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; - int informat,indent=0; - char *infile=NULL,*str=NULL,*prog,*oidfile=NULL; + BIO *in=NULL,*out=NULL,*b64=NULL, *derout = NULL; + int informat,indent=0, noout = 0, dump = 0; + char *infile=NULL,*str=NULL,*prog,*oidfile=NULL, *derfile=NULL; unsigned char *tmpbuf; BUF_MEM *buf=NULL; STACK *osk=NULL; @@ -103,12 +103,15 @@ char **argv; if ((bio_err=BIO_new(BIO_s_file())) != NULL) BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); + if (!load_config(bio_err, NULL)) + goto end; + prog=argv[0]; argc--; argv++; if ((osk=sk_new_null()) == NULL) { - BIO_printf(bio_err,"Malloc failure\n"); + BIO_printf(bio_err,"Memory allocation failure\n"); goto end; } while (argc >= 1) @@ -123,10 +126,16 @@ 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; } + else if (strcmp(*argv,"-noout") == 0) noout = 1; else if (strcmp(*argv,"-oid") == 0) { if (--argc < 1) goto bad; @@ -143,6 +152,16 @@ char **argv; length= atoi(*(++argv)); if (length == 0) goto bad; } + else if (strcmp(*argv,"-dump") == 0) + { + dump= -1; + } + else if (strcmp(*argv,"-dlimit") == 0) + { + if (--argc < 1) goto bad; + dump= atoi(*(++argv)); + if (dump <= 0) goto bad; + } else if (strcmp(*argv,"-strparse") == 0) { if (--argc < 1) goto bad; @@ -164,10 +183,14 @@ bad: BIO_printf(bio_err,"%s [options]