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

Side by Side Diff: openssl/crypto/x509v3/v3_purp.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/x509v3/v3_prn.c ('k') | openssl/crypto/x509v3/v3_utl.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 /* v3_purp.c */ 1 /* v3_purp.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 2001. 3 * project 2001.
4 */ 4 */
5 /* ==================================================================== 5 /* ====================================================================
6 * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2004 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 static void x509v3_cache_extensions(X509 *x); 64 static void x509v3_cache_extensions(X509 *x);
65 65
66 static int check_ssl_ca(const X509 *x); 66 static int check_ssl_ca(const X509 *x);
67 static int check_purpose_ssl_client(const X509_PURPOSE *xp, const X509 *x, int c a); 67 static int check_purpose_ssl_client(const X509_PURPOSE *xp, const X509 *x, int c a);
68 static int check_purpose_ssl_server(const X509_PURPOSE *xp, const X509 *x, int c a); 68 static int check_purpose_ssl_server(const X509_PURPOSE *xp, const X509 *x, int c a);
69 static int check_purpose_ns_ssl_server(const X509_PURPOSE *xp, const X509 *x, in t ca); 69 static int check_purpose_ns_ssl_server(const X509_PURPOSE *xp, const X509 *x, in t ca);
70 static int purpose_smime(const X509 *x, int ca); 70 static int purpose_smime(const X509 *x, int ca);
71 static int check_purpose_smime_sign(const X509_PURPOSE *xp, const X509 *x, int c a); 71 static int check_purpose_smime_sign(const X509_PURPOSE *xp, const X509 *x, int c a);
72 static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, in t ca); 72 static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, in t ca);
73 static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca) ; 73 static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca) ;
74 static int check_purpose_timestamp_sign(const X509_PURPOSE *xp, const X509 *x, i nt ca);
74 static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca); 75 static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca);
75 static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca); 76 static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca);
76 77
77 static int xp_cmp(const X509_PURPOSE * const *a, 78 static int xp_cmp(const X509_PURPOSE * const *a,
78 const X509_PURPOSE * const *b); 79 const X509_PURPOSE * const *b);
79 static void xptable_free(X509_PURPOSE *p); 80 static void xptable_free(X509_PURPOSE *p);
80 81
81 static X509_PURPOSE xstandard[] = { 82 static X509_PURPOSE xstandard[] = {
82 {X509_PURPOSE_SSL_CLIENT, X509_TRUST_SSL_CLIENT, 0, check_purpose_ssl_cl ient, "SSL client", "sslclient", NULL}, 83 {X509_PURPOSE_SSL_CLIENT, X509_TRUST_SSL_CLIENT, 0, check_purpose_ssl_cl ient, "SSL client", "sslclient", NULL},
83 {X509_PURPOSE_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ssl_se rver, "SSL server", "sslserver", NULL}, 84 {X509_PURPOSE_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ssl_se rver, "SSL server", "sslserver", NULL},
84 {X509_PURPOSE_NS_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ns_ ssl_server, "Netscape SSL server", "nssslserver", NULL}, 85 {X509_PURPOSE_NS_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ns_ ssl_server, "Netscape SSL server", "nssslserver", NULL},
85 {X509_PURPOSE_SMIME_SIGN, X509_TRUST_EMAIL, 0, check_purpose_smime_sign, "S/MIME signing", "smimesign", NULL}, 86 {X509_PURPOSE_SMIME_SIGN, X509_TRUST_EMAIL, 0, check_purpose_smime_sign, "S/MIME signing", "smimesign", NULL},
86 {X509_PURPOSE_SMIME_ENCRYPT, X509_TRUST_EMAIL, 0, check_purpose_smime_en crypt, "S/MIME encryption", "smimeencrypt", NULL}, 87 {X509_PURPOSE_SMIME_ENCRYPT, X509_TRUST_EMAIL, 0, check_purpose_smime_en crypt, "S/MIME encryption", "smimeencrypt", NULL},
87 {X509_PURPOSE_CRL_SIGN, X509_TRUST_COMPAT, 0, check_purpose_crl_sign, "C RL signing", "crlsign", NULL}, 88 {X509_PURPOSE_CRL_SIGN, X509_TRUST_COMPAT, 0, check_purpose_crl_sign, "C RL signing", "crlsign", NULL},
88 {X509_PURPOSE_ANY, X509_TRUST_DEFAULT, 0, no_check, "Any Purpose", "any" , NULL}, 89 {X509_PURPOSE_ANY, X509_TRUST_DEFAULT, 0, no_check, "Any Purpose", "any" , NULL},
89 {X509_PURPOSE_OCSP_HELPER, X509_TRUST_COMPAT, 0, ocsp_helper, "OCSP help er", "ocsphelper", NULL}, 90 {X509_PURPOSE_OCSP_HELPER, X509_TRUST_COMPAT, 0, ocsp_helper, "OCSP help er", "ocsphelper", NULL},
91 {X509_PURPOSE_TIMESTAMP_SIGN, X509_TRUST_TSA, 0, check_purpose_timestamp _sign, "Time Stamp signing", "timestampsign", NULL},
90 }; 92 };
91 93
92 #define X509_PURPOSE_COUNT (sizeof(xstandard)/sizeof(X509_PURPOSE)) 94 #define X509_PURPOSE_COUNT (sizeof(xstandard)/sizeof(X509_PURPOSE))
93 95
94 IMPLEMENT_STACK_OF(X509_PURPOSE) 96 IMPLEMENT_STACK_OF(X509_PURPOSE)
95 97
96 static STACK_OF(X509_PURPOSE) *xptable = NULL; 98 static STACK_OF(X509_PURPOSE) *xptable = NULL;
97 99
98 static int xp_cmp(const X509_PURPOSE * const *a, 100 static int xp_cmp(const X509_PURPOSE * const *a,
99 const X509_PURPOSE * const *b) 101 const X509_PURPOSE * const *b)
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp) 260 char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp)
259 { 261 {
260 return xp->sname; 262 return xp->sname;
261 } 263 }
262 264
263 int X509_PURPOSE_get_trust(X509_PURPOSE *xp) 265 int X509_PURPOSE_get_trust(X509_PURPOSE *xp)
264 { 266 {
265 return xp->trust; 267 return xp->trust;
266 } 268 }
267 269
268 static int nid_cmp(int *a, int *b) 270 static int nid_cmp(const int *a, const int *b)
269 { 271 {
270 return *a - *b; 272 return *a - *b;
271 } 273 }
272 274
275 DECLARE_OBJ_BSEARCH_CMP_FN(int, int, nid);
276 IMPLEMENT_OBJ_BSEARCH_CMP_FN(int, int, nid);
277
273 int X509_supported_extension(X509_EXTENSION *ex) 278 int X509_supported_extension(X509_EXTENSION *ex)
274 { 279 {
275 /* This table is a list of the NIDs of supported extensions: 280 /* This table is a list of the NIDs of supported extensions:
276 * that is those which are used by the verify process. If 281 * that is those which are used by the verify process. If
277 * an extension is critical and doesn't appear in this list 282 * an extension is critical and doesn't appear in this list
278 * then the verify process will normally reject the certificate. 283 * then the verify process will normally reject the certificate.
279 * The list must be kept in numerical order because it will be 284 * The list must be kept in numerical order because it will be
280 * searched using bsearch. 285 * searched using bsearch.
281 */ 286 */
282 287
283 » static int supported_nids[] = { 288 » static const int supported_nids[] = {
284 NID_netscape_cert_type, /* 71 */ 289 NID_netscape_cert_type, /* 71 */
285 NID_key_usage, /* 83 */ 290 NID_key_usage, /* 83 */
286 NID_subject_alt_name, /* 85 */ 291 NID_subject_alt_name, /* 85 */
287 NID_basic_constraints, /* 87 */ 292 NID_basic_constraints, /* 87 */
288 NID_certificate_policies, /* 89 */ 293 NID_certificate_policies, /* 89 */
289 NID_ext_key_usage, /* 126 */ 294 NID_ext_key_usage, /* 126 */
290 #ifndef OPENSSL_NO_RFC3779 295 #ifndef OPENSSL_NO_RFC3779
291 NID_sbgp_ipAddrBlock, /* 290 */ 296 NID_sbgp_ipAddrBlock, /* 290 */
292 NID_sbgp_autonomousSysNum, /* 291 */ 297 NID_sbgp_autonomousSysNum, /* 291 */
293 #endif 298 #endif
294 NID_policy_constraints, /* 401 */ 299 NID_policy_constraints, /* 401 */
295 » » NID_proxyCertInfo,» /* 661 */ 300 » » NID_proxyCertInfo,» /* 663 */
301 » » NID_name_constraints,» /* 666 */
302 » » NID_policy_mappings,» /* 747 */
296 NID_inhibit_any_policy /* 748 */ 303 NID_inhibit_any_policy /* 748 */
297 }; 304 };
298 305
299 » int ex_nid; 306 » int ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex));
300
301 » ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex));
302 307
303 if (ex_nid == NID_undef) 308 if (ex_nid == NID_undef)
304 return 0; 309 return 0;
305 310
306 » if (OBJ_bsearch((char *)&ex_nid, (char *)supported_nids, 311 » if (OBJ_bsearch_nid(&ex_nid, supported_nids,
307 » » sizeof(supported_nids)/sizeof(int), sizeof(int), 312 » » » sizeof(supported_nids)/sizeof(int)))
308 » » (int (*)(const void *, const void *))nid_cmp))
309 return 1; 313 return 1;
310 return 0; 314 return 0;
311 } 315 }
312 316
317 static void setup_dp(X509 *x, DIST_POINT *dp)
318 » {
319 » X509_NAME *iname = NULL;
320 » int i;
321 » if (dp->reasons)
322 » » {
323 » » if (dp->reasons->length > 0)
324 » » » dp->dp_reasons = dp->reasons->data[0];
325 » » if (dp->reasons->length > 1)
326 » » » dp->dp_reasons |= (dp->reasons->data[1] << 8);
327 » » dp->dp_reasons &= CRLDP_ALL_REASONS;
328 » » }
329 » else
330 » » dp->dp_reasons = CRLDP_ALL_REASONS;
331 » if (!dp->distpoint || (dp->distpoint->type != 1))
332 » » return;
333 » for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++)
334 » » {
335 » » GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i);
336 » » if (gen->type == GEN_DIRNAME)
337 » » » {
338 » » » iname = gen->d.directoryName;
339 » » » break;
340 » » » }
341 » » }
342 » if (!iname)
343 » » iname = X509_get_issuer_name(x);
344
345 » DIST_POINT_set_dpname(dp->distpoint, iname);
346
347 » }
348
349 static void setup_crldp(X509 *x)
350 » {
351 » int i;
352 » x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, NULL, NULL);
353 » for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++)
354 » » setup_dp(x, sk_DIST_POINT_value(x->crldp, i));
355 » }
313 356
314 static void x509v3_cache_extensions(X509 *x) 357 static void x509v3_cache_extensions(X509 *x)
315 { 358 {
316 BASIC_CONSTRAINTS *bs; 359 BASIC_CONSTRAINTS *bs;
317 PROXY_CERT_INFO_EXTENSION *pci; 360 PROXY_CERT_INFO_EXTENSION *pci;
318 ASN1_BIT_STRING *usage; 361 ASN1_BIT_STRING *usage;
319 ASN1_BIT_STRING *ns; 362 ASN1_BIT_STRING *ns;
320 EXTENDED_KEY_USAGE *extusage; 363 EXTENDED_KEY_USAGE *extusage;
321 X509_EXTENSION *ex; 364 X509_EXTENSION *ex;
322 365
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 453 }
411 454
412 if((ns=X509_get_ext_d2i(x, NID_netscape_cert_type, NULL, NULL))) { 455 if((ns=X509_get_ext_d2i(x, NID_netscape_cert_type, NULL, NULL))) {
413 if(ns->length > 0) x->ex_nscert = ns->data[0]; 456 if(ns->length > 0) x->ex_nscert = ns->data[0];
414 else x->ex_nscert = 0; 457 else x->ex_nscert = 0;
415 x->ex_flags |= EXFLAG_NSCERT; 458 x->ex_flags |= EXFLAG_NSCERT;
416 ASN1_BIT_STRING_free(ns); 459 ASN1_BIT_STRING_free(ns);
417 } 460 }
418 x->skid =X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL); 461 x->skid =X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL);
419 x->akid =X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL); 462 x->akid =X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL);
463 x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL);
464 x->nc = X509_get_ext_d2i(x, NID_name_constraints, &i, NULL);
465 if (!x->nc && (i != -1))
466 x->ex_flags |= EXFLAG_INVALID;
467 setup_crldp(x);
468
420 #ifndef OPENSSL_NO_RFC3779 469 #ifndef OPENSSL_NO_RFC3779
421 » x->rfc3779_addr =X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, NULL, NULL); 470 » x->rfc3779_addr =X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, NULL, NULL);
422 » x->rfc3779_asid =X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum, 471 » x->rfc3779_asid =X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum,
423 » » » » » NULL, NULL); 472 » » » » » NULL, NULL);
424 #endif 473 #endif
425 for (i = 0; i < X509_get_ext_count(x); i++) 474 for (i = 0; i < X509_get_ext_count(x); i++)
426 { 475 {
427 ex = X509_get_ext(x, i); 476 ex = X509_get_ext(x, i);
428 if (!X509_EXTENSION_get_critical(ex)) 477 if (!X509_EXTENSION_get_critical(ex))
429 continue; 478 continue;
479 if (OBJ_obj2nid(X509_EXTENSION_get_object(ex))
480 == NID_freshest_crl)
481 x->ex_flags |= EXFLAG_FRESHEST;
430 if (!X509_supported_extension(ex)) 482 if (!X509_supported_extension(ex))
431 { 483 {
432 x->ex_flags |= EXFLAG_CRITICAL; 484 x->ex_flags |= EXFLAG_CRITICAL;
433 break; 485 break;
434 } 486 }
435 } 487 }
436 x->ex_flags |= EXFLAG_SET; 488 x->ex_flags |= EXFLAG_SET;
437 } 489 }
438 490
439 /* CA checks common to all purposes 491 /* CA checks common to all purposes
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 639
588 static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca) 640 static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca)
589 { 641 {
590 /* Must be a valid CA. Should we really support the "I don't know" 642 /* Must be a valid CA. Should we really support the "I don't know"
591 value (2)? */ 643 value (2)? */
592 if(ca) return check_ca(x); 644 if(ca) return check_ca(x);
593 /* leaf certificate is checked in OCSP_verify() */ 645 /* leaf certificate is checked in OCSP_verify() */
594 return 1; 646 return 1;
595 } 647 }
596 648
649 static int check_purpose_timestamp_sign(const X509_PURPOSE *xp, const X509 *x,
650 int ca)
651 {
652 int i_ext;
653
654 /* If ca is true we must return if this is a valid CA certificate. */
655 if (ca) return check_ca(x);
656
657 /*
658 * Check the optional key usage field:
659 * if Key Usage is present, it must be one of digitalSignature
660 * and/or nonRepudiation (other values are not consistent and shall
661 * be rejected).
662 */
663 if ((x->ex_flags & EXFLAG_KUSAGE)
664 && ((x->ex_kusage & ~(KU_NON_REPUDIATION | KU_DIGITAL_SIGNATURE)) ||
665 !(x->ex_kusage & (KU_NON_REPUDIATION | KU_DIGITAL_SIGNATURE))))
666 return 0;
667
668 /* Only time stamp key usage is permitted and it's required. */
669 if (!(x->ex_flags & EXFLAG_XKUSAGE) || x->ex_xkusage != XKU_TIMESTAMP)
670 return 0;
671
672 /* Extended Key Usage MUST be critical */
673 i_ext = X509_get_ext_by_NID((X509 *) x, NID_ext_key_usage, 0);
674 if (i_ext >= 0)
675 {
676 X509_EXTENSION *ext = X509_get_ext((X509 *) x, i_ext);
677 if (!X509_EXTENSION_get_critical(ext))
678 return 0;
679 }
680
681 return 1;
682 }
683
597 static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca) 684 static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca)
598 { 685 {
599 return 1; 686 return 1;
600 } 687 }
601 688
602 /* Various checks to see if one certificate issued the second. 689 /* Various checks to see if one certificate issued the second.
603 * This can be used to prune a set of possible issuer certificates 690 * This can be used to prune a set of possible issuer certificates
604 * which have been looked up using some simple method such as by 691 * which have been looked up using some simple method such as by
605 * subject name. 692 * subject name.
606 * These are: 693 * These are:
607 * 1. Check issuer_name(subject) == subject_name(issuer) 694 * 1. Check issuer_name(subject) == subject_name(issuer)
608 * 2. If akid(subject) exists check it matches issuer 695 * 2. If akid(subject) exists check it matches issuer
609 * 3. If key_usage(issuer) exists check it supports certificate signing 696 * 3. If key_usage(issuer) exists check it supports certificate signing
610 * returns 0 for OK, positive for reason for mismatch, reasons match 697 * returns 0 for OK, positive for reason for mismatch, reasons match
611 * codes for X509_verify_cert() 698 * codes for X509_verify_cert()
612 */ 699 */
613 700
614 int X509_check_issued(X509 *issuer, X509 *subject) 701 int X509_check_issued(X509 *issuer, X509 *subject)
615 { 702 {
616 if(X509_NAME_cmp(X509_get_subject_name(issuer), 703 if(X509_NAME_cmp(X509_get_subject_name(issuer),
617 X509_get_issuer_name(subject))) 704 X509_get_issuer_name(subject)))
618 return X509_V_ERR_SUBJECT_ISSUER_MISMATCH; 705 return X509_V_ERR_SUBJECT_ISSUER_MISMATCH;
619 x509v3_cache_extensions(issuer); 706 x509v3_cache_extensions(issuer);
620 x509v3_cache_extensions(subject); 707 x509v3_cache_extensions(subject);
621 » if(subject->akid) { 708
622 » » /* Check key ids (if present) */ 709 » if(subject->akid)
623 » » if(subject->akid->keyid && issuer->skid && 710 » » {
624 » » ASN1_OCTET_STRING_cmp(subject->akid->keyid, issuer->skid) ) 711 » » int ret = X509_check_akid(issuer, subject->akid);
625 » » » » return X509_V_ERR_AKID_SKID_MISMATCH; 712 » » if (ret != X509_V_OK)
626 » » /* Check serial number */ 713 » » » return ret;
627 » » if(subject->akid->serial &&
628 » » » ASN1_INTEGER_cmp(X509_get_serialNumber(issuer),
629 » » » » » » subject->akid->serial))
630 » » » » return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
631 » » /* Check issuer name */
632 » » if(subject->akid->issuer) {
633 » » » /* Ugh, for some peculiar reason AKID includes
634 » » » * SEQUENCE OF GeneralName. So look for a DirName.
635 » » » * There may be more than one but we only take any
636 » » » * notice of the first.
637 » » » */
638 » » » GENERAL_NAMES *gens;
639 » » » GENERAL_NAME *gen;
640 » » » X509_NAME *nm = NULL;
641 » » » int i;
642 » » » gens = subject->akid->issuer;
643 » » » for(i = 0; i < sk_GENERAL_NAME_num(gens); i++) {
644 » » » » gen = sk_GENERAL_NAME_value(gens, i);
645 » » » » if(gen->type == GEN_DIRNAME) {
646 » » » » » nm = gen->d.dirn;
647 » » » » » break;
648 » » » » }
649 » » » }
650 » » » if(nm && X509_NAME_cmp(nm, X509_get_issuer_name(issuer)) )
651 » » » » return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
652 } 714 }
653 » } 715
654 if(subject->ex_flags & EXFLAG_PROXY) 716 if(subject->ex_flags & EXFLAG_PROXY)
655 { 717 {
656 if(ku_reject(issuer, KU_DIGITAL_SIGNATURE)) 718 if(ku_reject(issuer, KU_DIGITAL_SIGNATURE))
657 return X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE; 719 return X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE;
658 } 720 }
659 else if(ku_reject(issuer, KU_KEY_CERT_SIGN)) 721 else if(ku_reject(issuer, KU_KEY_CERT_SIGN))
660 return X509_V_ERR_KEYUSAGE_NO_CERTSIGN; 722 return X509_V_ERR_KEYUSAGE_NO_CERTSIGN;
661 return X509_V_OK; 723 return X509_V_OK;
662 } 724 }
663 725
726 int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid)
727 {
728
729 if(!akid)
730 return X509_V_OK;
731
732 /* Check key ids (if present) */
733 if(akid->keyid && issuer->skid &&
734 ASN1_OCTET_STRING_cmp(akid->keyid, issuer->skid) )
735 return X509_V_ERR_AKID_SKID_MISMATCH;
736 /* Check serial number */
737 if(akid->serial &&
738 ASN1_INTEGER_cmp(X509_get_serialNumber(issuer), akid->serial))
739 return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
740 /* Check issuer name */
741 if(akid->issuer)
742 {
743 /* Ugh, for some peculiar reason AKID includes
744 * SEQUENCE OF GeneralName. So look for a DirName.
745 * There may be more than one but we only take any
746 * notice of the first.
747 */
748 GENERAL_NAMES *gens;
749 GENERAL_NAME *gen;
750 X509_NAME *nm = NULL;
751 int i;
752 gens = akid->issuer;
753 for(i = 0; i < sk_GENERAL_NAME_num(gens); i++)
754 {
755 gen = sk_GENERAL_NAME_value(gens, i);
756 if(gen->type == GEN_DIRNAME)
757 {
758 nm = gen->d.dirn;
759 break;
760 }
761 }
762 if(nm && X509_NAME_cmp(nm, X509_get_issuer_name(issuer)))
763 return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
764 }
765 return X509_V_OK;
766 }
767
OLDNEW
« no previous file with comments | « openssl/crypto/x509v3/v3_prn.c ('k') | openssl/crypto/x509v3/v3_utl.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698