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

Side by Side Diff: openssl/crypto/asn1/t_x509.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/crypto/asn1/t_spki.c ('k') | openssl/crypto/asn1/tasn_dec.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 /* crypto/asn1/t_x509.c */ 1 /* crypto/asn1/t_x509.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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) 104 int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
105 { 105 {
106 long l; 106 long l;
107 int ret=0,i; 107 int ret=0,i;
108 char *m=NULL,mlch = ' '; 108 char *m=NULL,mlch = ' ';
109 int nmindent = 0; 109 int nmindent = 0;
110 X509_CINF *ci; 110 X509_CINF *ci;
111 ASN1_INTEGER *bs; 111 ASN1_INTEGER *bs;
112 EVP_PKEY *pkey=NULL; 112 EVP_PKEY *pkey=NULL;
113 const char *neg; 113 const char *neg;
114 ASN1_STRING *str=NULL;
115 114
116 if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { 115 if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
117 mlch = '\n'; 116 mlch = '\n';
118 nmindent = 12; 117 nmindent = 12;
119 } 118 }
120 119
121 if(nmflags == X509_FLAG_COMPAT) 120 if(nmflags == X509_FLAG_COMPAT)
122 nmindent = 16; 121 nmindent = 16;
123 122
124 ci=x->cert_info; 123 ci=x->cert_info;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 if (BIO_puts(bp, "\n") <= 0) 207 if (BIO_puts(bp, "\n") <= 0)
209 goto err; 208 goto err;
210 209
211 pkey=X509_get_pubkey(x); 210 pkey=X509_get_pubkey(x);
212 if (pkey == NULL) 211 if (pkey == NULL)
213 { 212 {
214 BIO_printf(bp,"%12sUnable to load Public Key\n",""); 213 BIO_printf(bp,"%12sUnable to load Public Key\n","");
215 ERR_print_errors(bp); 214 ERR_print_errors(bp);
216 } 215 }
217 else 216 else
218 #ifndef OPENSSL_NO_RSA
219 if (pkey->type == EVP_PKEY_RSA)
220 { 217 {
221 » » » BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","", 218 » » » EVP_PKEY_print_public(bp, pkey, 16, NULL);
222 » » » BN_num_bits(pkey->pkey.rsa->n)); 219 » » » EVP_PKEY_free(pkey);
223 » » » RSA_print(bp,pkey->pkey.rsa,16);
224 } 220 }
225 else
226 #endif
227 #ifndef OPENSSL_NO_DSA
228 if (pkey->type == EVP_PKEY_DSA)
229 {
230 BIO_printf(bp,"%12sDSA Public Key:\n","");
231 DSA_print(bp,pkey->pkey.dsa,16);
232 }
233 else
234 #endif
235 #ifndef OPENSSL_NO_EC
236 if (pkey->type == EVP_PKEY_EC)
237 {
238 BIO_printf(bp, "%12sEC Public Key:\n","");
239 EC_KEY_print(bp, pkey->pkey.ec, 16);
240 }
241 else
242 #endif
243 BIO_printf(bp,"%12sUnknown Public Key:\n","");
244
245 EVP_PKEY_free(pkey);
246 } 221 }
247 222
248 if (!(cflag & X509_FLAG_NO_EXTENSIONS)) 223 if (!(cflag & X509_FLAG_NO_EXTENSIONS))
249 X509V3_extensions_print(bp, "X509v3 extensions", 224 X509V3_extensions_print(bp, "X509v3 extensions",
250 ci->extensions, cflag, 8); 225 ci->extensions, cflag, 8);
251 226
252 if(!(cflag & X509_FLAG_NO_SIGDUMP)) 227 if(!(cflag & X509_FLAG_NO_SIGDUMP))
253 { 228 {
254 if(X509_signature_print(bp, x->sig_alg, x->signature) <= 0) goto err; 229 if(X509_signature_print(bp, x->sig_alg, x->signature) <= 0) goto err;
255 } 230 }
256 if(!(cflag & X509_FLAG_NO_AUX)) 231 if(!(cflag & X509_FLAG_NO_AUX))
257 { 232 {
258 if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err; 233 if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err;
259 } 234 }
260 ret=1; 235 ret=1;
261 err: 236 err:
262 if (str != NULL) ASN1_STRING_free(str);
263 if (m != NULL) OPENSSL_free(m); 237 if (m != NULL) OPENSSL_free(m);
264 return(ret); 238 return(ret);
265 } 239 }
266 240
267 int X509_ocspid_print (BIO *bp, X509 *x) 241 int X509_ocspid_print (BIO *bp, X509 *x)
268 { 242 {
269 unsigned char *der=NULL ; 243 unsigned char *der=NULL ;
270 unsigned char *dertmp; 244 unsigned char *dertmp;
271 int derlen; 245 int derlen;
272 int i; 246 int i;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 { 296 {
323 if ((i%18) == 0) 297 if ((i%18) == 0)
324 if (BIO_write(bp,"\n ",9) <= 0) return 0; 298 if (BIO_write(bp,"\n ",9) <= 0) return 0;
325 if (BIO_printf(bp,"%02x%s",s[i], 299 if (BIO_printf(bp,"%02x%s",s[i],
326 ((i+1) == n)?"":":") <= 0) return 0; 300 ((i+1) == n)?"":":") <= 0) return 0;
327 } 301 }
328 if (BIO_write(bp,"\n",1) != 1) return 0; 302 if (BIO_write(bp,"\n",1) != 1) return 0;
329 return 1; 303 return 1;
330 } 304 }
331 305
332 int ASN1_STRING_print(BIO *bp, ASN1_STRING *v) 306 int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v)
333 { 307 {
334 int i,n; 308 int i,n;
335 » char buf[80],*p; 309 » char buf[80];
310 » const char *p;
336 311
337 if (v == NULL) return(0); 312 if (v == NULL) return(0);
338 n=0; 313 n=0;
339 » p=(char *)v->data; 314 » p=(const char *)v->data;
340 for (i=0; i<v->length; i++) 315 for (i=0; i<v->length; i++)
341 { 316 {
342 if ((p[i] > '~') || ((p[i] < ' ') && 317 if ((p[i] > '~') || ((p[i] < ' ') &&
343 (p[i] != '\n') && (p[i] != '\r'))) 318 (p[i] != '\n') && (p[i] != '\r')))
344 buf[n]='.'; 319 buf[n]='.';
345 else 320 else
346 buf[n]=p[i]; 321 buf[n]=p[i];
347 n++; 322 n++;
348 if (n >= 80) 323 if (n >= 80)
349 { 324 {
350 if (BIO_write(bp,buf,n) <= 0) 325 if (BIO_write(bp,buf,n) <= 0)
351 return(0); 326 return(0);
352 n=0; 327 n=0;
353 } 328 }
354 } 329 }
355 if (n > 0) 330 if (n > 0)
356 if (BIO_write(bp,buf,n) <= 0) 331 if (BIO_write(bp,buf,n) <= 0)
357 return(0); 332 return(0);
358 return(1); 333 return(1);
359 } 334 }
360 335
361 int ASN1_TIME_print(BIO *bp, ASN1_TIME *tm) 336 int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
362 { 337 {
363 if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm); 338 if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm);
364 if(tm->type == V_ASN1_GENERALIZEDTIME) 339 if(tm->type == V_ASN1_GENERALIZEDTIME)
365 return ASN1_GENERALIZEDTIME_print(bp, tm); 340 return ASN1_GENERALIZEDTIME_print(bp, tm);
366 BIO_write(bp,"Bad time value",14); 341 BIO_write(bp,"Bad time value",14);
367 return(0); 342 return(0);
368 } 343 }
369 344
370 static const char *mon[12]= 345 static const char *mon[12]=
371 { 346 {
372 "Jan","Feb","Mar","Apr","May","Jun", 347 "Jan","Feb","Mar","Apr","May","Jun",
373 "Jul","Aug","Sep","Oct","Nov","Dec" 348 "Jul","Aug","Sep","Oct","Nov","Dec"
374 }; 349 };
375 350
376 int ASN1_GENERALIZEDTIME_print(BIO *bp, ASN1_GENERALIZEDTIME *tm) 351 int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
377 { 352 {
378 char *v; 353 char *v;
379 int gmt=0; 354 int gmt=0;
380 int i; 355 int i;
381 int y=0,M=0,d=0,h=0,m=0,s=0; 356 int y=0,M=0,d=0,h=0,m=0,s=0;
382 char *f = NULL; 357 char *f = NULL;
383 int f_len = 0; 358 int f_len = 0;
384 359
385 i=tm->length; 360 i=tm->length;
386 v=(char *)tm->data; 361 v=(char *)tm->data;
(...skipping 27 matching lines...) Expand all
414 if (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s", 389 if (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s",
415 mon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0) 390 mon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0)
416 return(0); 391 return(0);
417 else 392 else
418 return(1); 393 return(1);
419 err: 394 err:
420 BIO_write(bp,"Bad time value",14); 395 BIO_write(bp,"Bad time value",14);
421 return(0); 396 return(0);
422 } 397 }
423 398
424 int ASN1_UTCTIME_print(BIO *bp, ASN1_UTCTIME *tm) 399 int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm)
425 { 400 {
426 » char *v; 401 » const char *v;
427 int gmt=0; 402 int gmt=0;
428 int i; 403 int i;
429 int y=0,M=0,d=0,h=0,m=0,s=0; 404 int y=0,M=0,d=0,h=0,m=0,s=0;
430 405
431 i=tm->length; 406 i=tm->length;
432 » v=(char *)tm->data; 407 » v=(const char *)tm->data;
433 408
434 if (i < 10) goto err; 409 if (i < 10) goto err;
435 if (v[i-1] == 'Z') gmt=1; 410 if (v[i-1] == 'Z') gmt=1;
436 for (i=0; i<10; i++) 411 for (i=0; i<10; i++)
437 if ((v[i] > '9') || (v[i] < '0')) goto err; 412 if ((v[i] > '9') || (v[i] < '0')) goto err;
438 y= (v[0]-'0')*10+(v[1]-'0'); 413 y= (v[0]-'0')*10+(v[1]-'0');
439 if (y < 50) y+=100; 414 if (y < 50) y+=100;
440 M= (v[2]-'0')*10+(v[3]-'0'); 415 M= (v[2]-'0')*10+(v[3]-'0');
441 if ((M > 12) || (M < 1)) goto err; 416 if ((M > 12) || (M < 1)) goto err;
442 d= (v[4]-'0')*10+(v[5]-'0'); 417 d= (v[4]-'0')*10+(v[5]-'0');
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 484
510 ret=1; 485 ret=1;
511 if (0) 486 if (0)
512 { 487 {
513 err: 488 err:
514 X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB); 489 X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB);
515 } 490 }
516 OPENSSL_free(b); 491 OPENSSL_free(b);
517 return(ret); 492 return(ret);
518 } 493 }
OLDNEW
« no previous file with comments | « openssl/crypto/asn1/t_spki.c ('k') | openssl/crypto/asn1/tasn_dec.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698