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

Side by Side Diff: openssl/crypto/asn1/asn1_gen.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/asn1_err.c ('k') | openssl/crypto/asn1/asn1_lib.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 /* asn1_gen.c */ 1 /* asn1_gen.c */
2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2002. 3 * project 2002.
4 */ 4 */
5 /* ==================================================================== 5 /* ====================================================================
6 * Copyright (c) 2002 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 2002 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 { 240 {
241 ASN1_put_object(&p, etmp->exp_constructed, etmp->exp_len, 241 ASN1_put_object(&p, etmp->exp_constructed, etmp->exp_len,
242 etmp->exp_tag, etmp->exp_class); 242 etmp->exp_tag, etmp->exp_class);
243 if (etmp->exp_pad) 243 if (etmp->exp_pad)
244 *p++ = 0; 244 *p++ = 0;
245 } 245 }
246 246
247 /* If IMPLICIT, output tag */ 247 /* If IMPLICIT, output tag */
248 248
249 if (asn1_tags.imp_tag != -1) 249 if (asn1_tags.imp_tag != -1)
250 {
251 if (asn1_tags.imp_class == V_ASN1_UNIVERSAL
252 && (asn1_tags.imp_tag == V_ASN1_SEQUENCE
253 || asn1_tags.imp_tag == V_ASN1_SET) )
254 hdr_constructed = V_ASN1_CONSTRUCTED;
250 ASN1_put_object(&p, hdr_constructed, hdr_len, 255 ASN1_put_object(&p, hdr_constructed, hdr_len,
251 asn1_tags.imp_tag, asn1_tags.imp_class); 256 asn1_tags.imp_tag, asn1_tags.imp_class);
257 }
252 258
253 /* Copy across original encoding */ 259 /* Copy across original encoding */
254 memcpy(p, cpy_start, cpy_len); 260 memcpy(p, cpy_start, cpy_len);
255 261
256 cp = new_der; 262 cp = new_der;
257 263
258 /* Obtain new ASN1_TYPE structure */ 264 /* Obtain new ASN1_TYPE structure */
259 ret = d2i_ASN1_TYPE(NULL, &cp, len); 265 ret = d2i_ASN1_TYPE(NULL, &cp, len);
260 266
261 err: 267 err:
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 *pclass = V_ASN1_CONTEXT_SPECIFIC; 440 *pclass = V_ASN1_CONTEXT_SPECIFIC;
435 441
436 return 1; 442 return 1;
437 443
438 } 444 }
439 445
440 /* Handle multiple types: SET and SEQUENCE */ 446 /* Handle multiple types: SET and SEQUENCE */
441 447
442 static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf) 448 static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf)
443 { 449 {
444 » ASN1_TYPE *ret = NULL, *typ = NULL; 450 » ASN1_TYPE *ret = NULL;
445 STACK_OF(ASN1_TYPE) *sk = NULL; 451 STACK_OF(ASN1_TYPE) *sk = NULL;
446 STACK_OF(CONF_VALUE) *sect = NULL; 452 STACK_OF(CONF_VALUE) *sect = NULL;
447 » unsigned char *der = NULL, *p; 453 » unsigned char *der = NULL;
448 int derlen; 454 int derlen;
449 » int i, is_set; 455 » int i;
450 sk = sk_ASN1_TYPE_new_null(); 456 sk = sk_ASN1_TYPE_new_null();
451 if (!sk) 457 if (!sk)
452 goto bad; 458 goto bad;
453 if (section) 459 if (section)
454 { 460 {
455 if (!cnf) 461 if (!cnf)
456 goto bad; 462 goto bad;
457 sect = X509V3_get_section(cnf, (char *)section); 463 sect = X509V3_get_section(cnf, (char *)section);
458 if (!sect) 464 if (!sect)
459 goto bad; 465 goto bad;
460 for (i = 0; i < sk_CONF_VALUE_num(sect); i++) 466 for (i = 0; i < sk_CONF_VALUE_num(sect); i++)
461 { 467 {
462 » » » typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->val ue, cnf); 468 » » » ASN1_TYPE *typ = ASN1_generate_v3(sk_CONF_VALUE_value(se ct, i)->value, cnf);
463 if (!typ) 469 if (!typ)
464 goto bad; 470 goto bad;
465 if (!sk_ASN1_TYPE_push(sk, typ)) 471 if (!sk_ASN1_TYPE_push(sk, typ))
466 goto bad; 472 goto bad;
467 typ = NULL;
468 } 473 }
469 } 474 }
470 475
471 /* Now we has a STACK of the components, convert to the correct form */ 476 /* Now we has a STACK of the components, convert to the correct form */
472 477
473 if (utype == V_ASN1_SET) 478 if (utype == V_ASN1_SET)
474 » » is_set = 1; 479 » » derlen = i2d_ASN1_SET_ANY(sk, &der);
475 else 480 else
476 » » is_set = 0; 481 » » derlen = i2d_ASN1_SEQUENCE_ANY(sk, &der);
477 482
478 483 » if (derlen < 0)
479 » derlen = i2d_ASN1_SET_OF_ASN1_TYPE(sk, NULL, i2d_ASN1_TYPE, utype,
480 » » » » » V_ASN1_UNIVERSAL, is_set);
481 » der = OPENSSL_malloc(derlen);
482 » if (!der)
483 goto bad; 484 goto bad;
484 p = der;
485 i2d_ASN1_SET_OF_ASN1_TYPE(sk, &p, i2d_ASN1_TYPE, utype,
486 V_ASN1_UNIVERSAL, is_set);
487 485
488 if (!(ret = ASN1_TYPE_new())) 486 if (!(ret = ASN1_TYPE_new()))
489 goto bad; 487 goto bad;
490 488
491 if (!(ret->value.asn1_string = ASN1_STRING_type_new(utype))) 489 if (!(ret->value.asn1_string = ASN1_STRING_type_new(utype)))
492 goto bad; 490 goto bad;
493 491
494 ret->type = utype; 492 ret->type = utype;
495 493
496 ret->value.asn1_string->data = der; 494 ret->value.asn1_string->data = der;
497 ret->value.asn1_string->length = derlen; 495 ret->value.asn1_string->length = derlen;
498 496
499 der = NULL; 497 der = NULL;
500 498
501 bad: 499 bad:
502 500
503 if (der) 501 if (der)
504 OPENSSL_free(der); 502 OPENSSL_free(der);
505 503
506 if (sk) 504 if (sk)
507 sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free); 505 sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
508 if (typ)
509 ASN1_TYPE_free(typ);
510 if (sect) 506 if (sect)
511 X509V3_section_free(cnf, sect); 507 X509V3_section_free(cnf, sect);
512 508
513 return ret; 509 return ret;
514 } 510 }
515 511
516 static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_cons tructed, int exp_pad, int imp_ok) 512 static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_cons tructed, int exp_pad, int imp_ok)
517 { 513 {
518 tag_exp_type *exp_tmp; 514 tag_exp_type *exp_tmp;
519 /* Can only have IMPLICIT if permitted */ 515 /* Can only have IMPLICIT if permitted */
(...skipping 29 matching lines...) Expand all
549 exp_tmp->exp_constructed = exp_constructed; 545 exp_tmp->exp_constructed = exp_constructed;
550 exp_tmp->exp_pad = exp_pad; 546 exp_tmp->exp_pad = exp_pad;
551 547
552 return 1; 548 return 1;
553 } 549 }
554 550
555 551
556 static int asn1_str2tag(const char *tagstr, int len) 552 static int asn1_str2tag(const char *tagstr, int len)
557 { 553 {
558 unsigned int i; 554 unsigned int i;
559 » static struct tag_name_st *tntmp, tnst [] = { 555 » static const struct tag_name_st *tntmp, tnst [] = {
560 ASN1_GEN_STR("BOOL", V_ASN1_BOOLEAN), 556 ASN1_GEN_STR("BOOL", V_ASN1_BOOLEAN),
561 ASN1_GEN_STR("BOOLEAN", V_ASN1_BOOLEAN), 557 ASN1_GEN_STR("BOOLEAN", V_ASN1_BOOLEAN),
562 ASN1_GEN_STR("NULL", V_ASN1_NULL), 558 ASN1_GEN_STR("NULL", V_ASN1_NULL),
563 ASN1_GEN_STR("INT", V_ASN1_INTEGER), 559 ASN1_GEN_STR("INT", V_ASN1_INTEGER),
564 ASN1_GEN_STR("INTEGER", V_ASN1_INTEGER), 560 ASN1_GEN_STR("INTEGER", V_ASN1_INTEGER),
565 ASN1_GEN_STR("ENUM", V_ASN1_ENUMERATED), 561 ASN1_GEN_STR("ENUM", V_ASN1_ENUMERATED),
566 ASN1_GEN_STR("ENUMERATED", V_ASN1_ENUMERATED), 562 ASN1_GEN_STR("ENUMERATED", V_ASN1_ENUMERATED),
567 ASN1_GEN_STR("OID", V_ASN1_OBJECT), 563 ASN1_GEN_STR("OID", V_ASN1_OBJECT),
568 ASN1_GEN_STR("OBJECT", V_ASN1_OBJECT), 564 ASN1_GEN_STR("OBJECT", V_ASN1_OBJECT),
569 ASN1_GEN_STR("UTCTIME", V_ASN1_UTCTIME), 565 ASN1_GEN_STR("UTCTIME", V_ASN1_UTCTIME),
(...skipping 14 matching lines...) Expand all
584 ASN1_GEN_STR("BMPSTRING", V_ASN1_BMPSTRING), 580 ASN1_GEN_STR("BMPSTRING", V_ASN1_BMPSTRING),
585 ASN1_GEN_STR("VISIBLESTRING", V_ASN1_VISIBLESTRING), 581 ASN1_GEN_STR("VISIBLESTRING", V_ASN1_VISIBLESTRING),
586 ASN1_GEN_STR("VISIBLE", V_ASN1_VISIBLESTRING), 582 ASN1_GEN_STR("VISIBLE", V_ASN1_VISIBLESTRING),
587 ASN1_GEN_STR("PRINTABLESTRING", V_ASN1_PRINTABLESTRING), 583 ASN1_GEN_STR("PRINTABLESTRING", V_ASN1_PRINTABLESTRING),
588 ASN1_GEN_STR("PRINTABLE", V_ASN1_PRINTABLESTRING), 584 ASN1_GEN_STR("PRINTABLE", V_ASN1_PRINTABLESTRING),
589 ASN1_GEN_STR("T61", V_ASN1_T61STRING), 585 ASN1_GEN_STR("T61", V_ASN1_T61STRING),
590 ASN1_GEN_STR("T61STRING", V_ASN1_T61STRING), 586 ASN1_GEN_STR("T61STRING", V_ASN1_T61STRING),
591 ASN1_GEN_STR("TELETEXSTRING", V_ASN1_T61STRING), 587 ASN1_GEN_STR("TELETEXSTRING", V_ASN1_T61STRING),
592 ASN1_GEN_STR("GeneralString", V_ASN1_GENERALSTRING), 588 ASN1_GEN_STR("GeneralString", V_ASN1_GENERALSTRING),
593 ASN1_GEN_STR("GENSTR", V_ASN1_GENERALSTRING), 589 ASN1_GEN_STR("GENSTR", V_ASN1_GENERALSTRING),
590 ASN1_GEN_STR("NUMERIC", V_ASN1_NUMERICSTRING),
591 ASN1_GEN_STR("NUMERICSTRING", V_ASN1_NUMERICSTRING),
594 592
595 /* Special cases */ 593 /* Special cases */
596 ASN1_GEN_STR("SEQUENCE", V_ASN1_SEQUENCE), 594 ASN1_GEN_STR("SEQUENCE", V_ASN1_SEQUENCE),
597 ASN1_GEN_STR("SEQ", V_ASN1_SEQUENCE), 595 ASN1_GEN_STR("SEQ", V_ASN1_SEQUENCE),
598 ASN1_GEN_STR("SET", V_ASN1_SET), 596 ASN1_GEN_STR("SET", V_ASN1_SET),
599 /* type modifiers */ 597 /* type modifiers */
600 /* Explicit tag */ 598 /* Explicit tag */
601 ASN1_GEN_STR("EXP", ASN1_GEN_FLAG_EXP), 599 ASN1_GEN_STR("EXP", ASN1_GEN_FLAG_EXP),
602 ASN1_GEN_STR("EXPLICIT", ASN1_GEN_FLAG_EXP), 600 ASN1_GEN_STR("EXPLICIT", ASN1_GEN_FLAG_EXP),
603 /* Implicit tag */ 601 /* Implicit tag */
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 break; 727 break;
730 728
731 case V_ASN1_BMPSTRING: 729 case V_ASN1_BMPSTRING:
732 case V_ASN1_PRINTABLESTRING: 730 case V_ASN1_PRINTABLESTRING:
733 case V_ASN1_IA5STRING: 731 case V_ASN1_IA5STRING:
734 case V_ASN1_T61STRING: 732 case V_ASN1_T61STRING:
735 case V_ASN1_UTF8STRING: 733 case V_ASN1_UTF8STRING:
736 case V_ASN1_VISIBLESTRING: 734 case V_ASN1_VISIBLESTRING:
737 case V_ASN1_UNIVERSALSTRING: 735 case V_ASN1_UNIVERSALSTRING:
738 case V_ASN1_GENERALSTRING: 736 case V_ASN1_GENERALSTRING:
737 case V_ASN1_NUMERICSTRING:
739 738
740 if (format == ASN1_GEN_FORMAT_ASCII) 739 if (format == ASN1_GEN_FORMAT_ASCII)
741 format = MBSTRING_ASC; 740 format = MBSTRING_ASC;
742 else if (format == ASN1_GEN_FORMAT_UTF8) 741 else if (format == ASN1_GEN_FORMAT_UTF8)
743 format = MBSTRING_UTF8; 742 format = MBSTRING_UTF8;
744 else 743 else
745 { 744 {
746 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_FORMAT); 745 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_FORMAT);
747 goto bad_form; 746 goto bad_form;
748 } 747 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 return 0; 845 return 0;
847 } 846 }
848 if (!ASN1_BIT_STRING_set_bit(bitstr, bitnum, 1)) 847 if (!ASN1_BIT_STRING_set_bit(bitstr, bitnum, 1))
849 { 848 {
850 ASN1err(ASN1_F_BITSTR_CB, ERR_R_MALLOC_FAILURE); 849 ASN1err(ASN1_F_BITSTR_CB, ERR_R_MALLOC_FAILURE);
851 return 0; 850 return 0;
852 } 851 }
853 return 1; 852 return 1;
854 } 853 }
855 854
OLDNEW
« no previous file with comments | « openssl/crypto/asn1/asn1_err.c ('k') | openssl/crypto/asn1/asn1_lib.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698