Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: openssl/apps/asn1pars.c

Issue 9254031: Upgrade chrome's OpenSSL to same version Android ships with. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/openssl/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « openssl/apps/apps.c ('k') | openssl/apps/ca.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* apps/asn1pars.c */ 1 /* apps/asn1pars.c */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 int i,badops=0,offset=0,ret=1,j; 89 int i,badops=0,offset=0,ret=1,j;
90 unsigned int length=0; 90 unsigned int length=0;
91 long num,tmplen; 91 long num,tmplen;
92 BIO *in=NULL,*out=NULL,*b64=NULL, *derout = NULL; 92 BIO *in=NULL,*out=NULL,*b64=NULL, *derout = NULL;
93 int informat,indent=0, noout = 0, dump = 0; 93 int informat,indent=0, noout = 0, dump = 0;
94 char *infile=NULL,*str=NULL,*prog,*oidfile=NULL, *derfile=NULL; 94 char *infile=NULL,*str=NULL,*prog,*oidfile=NULL, *derfile=NULL;
95 char *genstr=NULL, *genconf=NULL; 95 char *genstr=NULL, *genconf=NULL;
96 unsigned char *tmpbuf; 96 unsigned char *tmpbuf;
97 const unsigned char *ctmpbuf; 97 const unsigned char *ctmpbuf;
98 BUF_MEM *buf=NULL; 98 BUF_MEM *buf=NULL;
99 » STACK *osk=NULL; 99 » STACK_OF(OPENSSL_STRING) *osk=NULL;
100 ASN1_TYPE *at=NULL; 100 ASN1_TYPE *at=NULL;
101 101
102 informat=FORMAT_PEM; 102 informat=FORMAT_PEM;
103 103
104 apps_startup(); 104 apps_startup();
105 105
106 if (bio_err == NULL) 106 if (bio_err == NULL)
107 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 107 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
108 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 108 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
109 109
110 if (!load_config(bio_err, NULL)) 110 if (!load_config(bio_err, NULL))
111 goto end; 111 goto end;
112 112
113 prog=argv[0]; 113 prog=argv[0];
114 argc--; 114 argc--;
115 argv++; 115 argv++;
116 » if ((osk=sk_new_null()) == NULL) 116 » if ((osk=sk_OPENSSL_STRING_new_null()) == NULL)
117 { 117 {
118 BIO_printf(bio_err,"Memory allocation failure\n"); 118 BIO_printf(bio_err,"Memory allocation failure\n");
119 goto end; 119 goto end;
120 } 120 }
121 while (argc >= 1) 121 while (argc >= 1)
122 { 122 {
123 if (strcmp(*argv,"-inform") == 0) 123 if (strcmp(*argv,"-inform") == 0)
124 { 124 {
125 if (--argc < 1) goto bad; 125 if (--argc < 1) goto bad;
126 informat=str2fmt(*(++argv)); 126 informat=str2fmt(*(++argv));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 else if (strcmp(*argv,"-dlimit") == 0) 163 else if (strcmp(*argv,"-dlimit") == 0)
164 { 164 {
165 if (--argc < 1) goto bad; 165 if (--argc < 1) goto bad;
166 dump= atoi(*(++argv)); 166 dump= atoi(*(++argv));
167 if (dump <= 0) goto bad; 167 if (dump <= 0) goto bad;
168 } 168 }
169 else if (strcmp(*argv,"-strparse") == 0) 169 else if (strcmp(*argv,"-strparse") == 0)
170 { 170 {
171 if (--argc < 1) goto bad; 171 if (--argc < 1) goto bad;
172 » » » sk_push(osk,*(++argv)); 172 » » » sk_OPENSSL_STRING_push(osk,*(++argv));
173 } 173 }
174 else if (strcmp(*argv,"-genstr") == 0) 174 else if (strcmp(*argv,"-genstr") == 0)
175 { 175 {
176 if (--argc < 1) goto bad; 176 if (--argc < 1) goto bad;
177 genstr= *(++argv); 177 genstr= *(++argv);
178 } 178 }
179 else if (strcmp(*argv,"-genconf") == 0) 179 else if (strcmp(*argv,"-genconf") == 0)
180 { 180 {
181 if (--argc < 1) goto bad; 181 if (--argc < 1) goto bad;
182 genconf= *(++argv); 182 genconf= *(++argv);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (!BUF_MEM_grow(buf,(int)num+BUFSIZ)) goto end; 295 if (!BUF_MEM_grow(buf,(int)num+BUFSIZ)) goto end;
296 i=BIO_read(in,&(buf->data[num]),BUFSIZ); 296 i=BIO_read(in,&(buf->data[num]),BUFSIZ);
297 if (i <= 0) break; 297 if (i <= 0) break;
298 num+=i; 298 num+=i;
299 } 299 }
300 } 300 }
301 str=buf->data; 301 str=buf->data;
302 302
303 /* If any structs to parse go through in sequence */ 303 /* If any structs to parse go through in sequence */
304 304
305 » if (sk_num(osk)) 305 » if (sk_OPENSSL_STRING_num(osk))
306 { 306 {
307 tmpbuf=(unsigned char *)str; 307 tmpbuf=(unsigned char *)str;
308 tmplen=num; 308 tmplen=num;
309 » » for (i=0; i<sk_num(osk); i++) 309 » » for (i=0; i<sk_OPENSSL_STRING_num(osk); i++)
310 { 310 {
311 ASN1_TYPE *atmp; 311 ASN1_TYPE *atmp;
312 int typ; 312 int typ;
313 » » » j=atoi(sk_value(osk,i)); 313 » » » j=atoi(sk_OPENSSL_STRING_value(osk,i));
314 if (j == 0) 314 if (j == 0)
315 { 315 {
316 » » » » BIO_printf(bio_err,"'%s' is an invalid number\n" ,sk_value(osk,i)); 316 » » » » BIO_printf(bio_err,"'%s' is an invalid number\n" ,sk_OPENSSL_STRING_value(osk,i));
317 continue; 317 continue;
318 } 318 }
319 tmpbuf+=j; 319 tmpbuf+=j;
320 tmplen-=j; 320 tmplen-=j;
321 atmp = at; 321 atmp = at;
322 ctmpbuf = tmpbuf; 322 ctmpbuf = tmpbuf;
323 at = d2i_ASN1_TYPE(NULL,&ctmpbuf,tmplen); 323 at = d2i_ASN1_TYPE(NULL,&ctmpbuf,tmplen);
324 ASN1_TYPE_free(atmp); 324 ASN1_TYPE_free(atmp);
325 if(!at) 325 if(!at)
326 { 326 {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 ret=0; 371 ret=0;
372 end: 372 end:
373 BIO_free(derout); 373 BIO_free(derout);
374 if (in != NULL) BIO_free(in); 374 if (in != NULL) BIO_free(in);
375 if (out != NULL) BIO_free_all(out); 375 if (out != NULL) BIO_free_all(out);
376 if (b64 != NULL) BIO_free(b64); 376 if (b64 != NULL) BIO_free(b64);
377 if (ret != 0) 377 if (ret != 0)
378 ERR_print_errors(bio_err); 378 ERR_print_errors(bio_err);
379 if (buf != NULL) BUF_MEM_free(buf); 379 if (buf != NULL) BUF_MEM_free(buf);
380 if (at != NULL) ASN1_TYPE_free(at); 380 if (at != NULL) ASN1_TYPE_free(at);
381 » if (osk != NULL) sk_free(osk); 381 » if (osk != NULL) sk_OPENSSL_STRING_free(osk);
382 OBJ_cleanup(); 382 OBJ_cleanup();
383 apps_shutdown(); 383 apps_shutdown();
384 OPENSSL_EXIT(ret); 384 OPENSSL_EXIT(ret);
385 } 385 }
386 386
387 static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf) 387 static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf)
388 { 388 {
389 CONF *cnf = NULL; 389 CONF *cnf = NULL;
390 int len; 390 int len;
391 long errline; 391 long errline;
392 unsigned char *p; 392 unsigned char *p;
393 ASN1_TYPE *atyp = NULL; 393 ASN1_TYPE *atyp = NULL;
394 394
395 if (genconf) 395 if (genconf)
396 { 396 {
397 cnf = NCONF_new(NULL); 397 cnf = NCONF_new(NULL);
398 if (!NCONF_load(cnf, genconf, &errline)) 398 if (!NCONF_load(cnf, genconf, &errline))
399 goto conferr; 399 goto conferr;
400 if (!genstr) 400 if (!genstr)
401 genstr = NCONF_get_string(cnf, "default", "asn1"); 401 genstr = NCONF_get_string(cnf, "default", "asn1");
402 if (!genstr) 402 if (!genstr)
403 { 403 {
404 BIO_printf(bio, "Can't find 'asn1' in '%s'\n", genconf); 404 BIO_printf(bio, "Can't find 'asn1' in '%s'\n", genconf);
405 goto err; 405 goto err;
406 } 406 }
407 } 407 }
408 408
409 atyp = ASN1_generate_nconf(genstr, cnf); 409 atyp = ASN1_generate_nconf(genstr, cnf);
410 NCONF_free(cnf); 410 NCONF_free(cnf);
411 cnf = NULL;
411 412
412 if (!atyp) 413 if (!atyp)
413 return -1; 414 return -1;
414 415
415 len = i2d_ASN1_TYPE(atyp, NULL); 416 len = i2d_ASN1_TYPE(atyp, NULL);
416 417
417 if (len <= 0) 418 if (len <= 0)
418 goto err; 419 goto err;
419 420
420 if (!BUF_MEM_grow(buf,len)) 421 if (!BUF_MEM_grow(buf,len))
(...skipping 14 matching lines...) Expand all
435 else 436 else
436 BIO_printf(bio, "Error loading config file '%s'\n", genconf); 437 BIO_printf(bio, "Error loading config file '%s'\n", genconf);
437 438
438 err: 439 err:
439 NCONF_free(cnf); 440 NCONF_free(cnf);
440 ASN1_TYPE_free(atyp); 441 ASN1_TYPE_free(atyp);
441 442
442 return -1; 443 return -1;
443 444
444 } 445 }
OLDNEW
« no previous file with comments | « openssl/apps/apps.c ('k') | openssl/apps/ca.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698