81 #define PROG asn1parse_main
83 int MAIN(
int,
char **);
85 static int do_generate(
BIO *bio,
char *genstr,
char *genconf,
BUF_MEM *buf);
87 int MAIN(
int argc,
char **argv)
89 int i,badops=0,offset=0,ret=1,j;
92 BIO *
in=NULL,*
out=NULL,*b64=NULL, *derout = NULL;
93 int informat,indent=0, noout = 0, dump = 0;
94 char *infile=NULL,*str=NULL,*prog,*oidfile=NULL, *derfile=NULL;
95 char *genstr=NULL, *genconf=NULL;
96 unsigned char *tmpbuf;
97 const unsigned char *ctmpbuf;
123 if (strcmp(*argv,
"-inform") == 0)
125 if (--argc < 1)
goto bad;
128 else if (strcmp(*argv,
"-in") == 0)
130 if (--argc < 1)
goto bad;
133 else if (strcmp(*argv,
"-out") == 0)
135 if (--argc < 1)
goto bad;
138 else if (strcmp(*argv,
"-i") == 0)
142 else if (strcmp(*argv,
"-noout") == 0) noout = 1;
143 else if (strcmp(*argv,
"-oid") == 0)
145 if (--argc < 1)
goto bad;
148 else if (strcmp(*argv,
"-offset") == 0)
150 if (--argc < 1)
goto bad;
151 offset= atoi(*(++argv));
153 else if (strcmp(*argv,
"-length") == 0)
155 if (--argc < 1)
goto bad;
156 length= atoi(*(++argv));
157 if (length == 0)
goto bad;
159 else if (strcmp(*argv,
"-dump") == 0)
163 else if (strcmp(*argv,
"-dlimit") == 0)
165 if (--argc < 1)
goto bad;
166 dump= atoi(*(++argv));
167 if (dump <= 0)
goto bad;
169 else if (strcmp(*argv,
"-strparse") == 0)
171 if (--argc < 1)
goto bad;
174 else if (strcmp(*argv,
"-genstr") == 0)
176 if (--argc < 1)
goto bad;
179 else if (strcmp(*argv,
"-genconf") == 0)
181 if (--argc < 1)
goto bad;
207 BIO_printf(
bio_err,
" -dlimit arg dump the first arg bytes of unknown data in hex form\n");
221 if ((in == NULL) || (out == NULL))
227 #ifdef OPENSSL_SYS_VMS
267 if (genstr || genconf)
269 num = do_generate(
bio_err, genstr, genconf, buf);
307 tmpbuf=(
unsigned char *)str;
323 at = d2i_ASN1_TYPE(NULL,&ctmpbuf,tmplen);
324 ASN1_TYPE_free(atmp);
356 if ((length == 0) || ((
long)length > num)) length=(
unsigned int)num;
358 if(
BIO_write(derout, str + offset, length) != (int)length) {
380 if (at != NULL) ASN1_TYPE_free(at);
387 static int do_generate(
BIO *bio,
char *genstr,
char *genconf,
BUF_MEM *buf)
404 BIO_printf(bio,
"Can't find 'asn1' in '%s'\n", genconf);
416 len = i2d_ASN1_TYPE(atyp, NULL);
424 p=(
unsigned char *)buf->
data;
426 i2d_ASN1_TYPE(atyp, &p);
428 ASN1_TYPE_free(atyp);
434 BIO_printf(bio,
"Error on line %ld of config file '%s'\n",
437 BIO_printf(bio,
"Error loading config file '%s'\n", genconf);
441 ASN1_TYPE_free(atyp);