2 * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 * Implementation of RFC 3779 section 3.2.
17 #include "internal/cryptlib.h"
18 #include <openssl/conf.h>
19 #include <openssl/asn1.h>
20 #include <openssl/asn1t.h>
21 #include <openssl/x509v3.h>
22 #include <openssl/x509.h>
23 #include "crypto/x509.h"
24 #include <openssl/bn.h>
27 #ifndef OPENSSL_NO_RFC3779
30 * OpenSSL ASN.1 template translation of RFC 3779 3.2.3.
33 ASN1_SEQUENCE(ASRange) = {
34 ASN1_SIMPLE(ASRange, min, ASN1_INTEGER),
35 ASN1_SIMPLE(ASRange, max, ASN1_INTEGER)
36 } ASN1_SEQUENCE_END(ASRange)
38 ASN1_CHOICE(ASIdOrRange) = {
39 ASN1_SIMPLE(ASIdOrRange, u.id, ASN1_INTEGER),
40 ASN1_SIMPLE(ASIdOrRange, u.range, ASRange)
41 } ASN1_CHOICE_END(ASIdOrRange)
43 ASN1_CHOICE(ASIdentifierChoice) = {
44 ASN1_SIMPLE(ASIdentifierChoice, u.inherit, ASN1_NULL),
45 ASN1_SEQUENCE_OF(ASIdentifierChoice, u.asIdsOrRanges, ASIdOrRange)
46 } ASN1_CHOICE_END(ASIdentifierChoice)
48 ASN1_SEQUENCE(ASIdentifiers) = {
49 ASN1_EXP_OPT(ASIdentifiers, asnum, ASIdentifierChoice, 0),
50 ASN1_EXP_OPT(ASIdentifiers, rdi, ASIdentifierChoice, 1)
51 } ASN1_SEQUENCE_END(ASIdentifiers)
53 IMPLEMENT_ASN1_FUNCTIONS(ASRange)
54 IMPLEMENT_ASN1_FUNCTIONS(ASIdOrRange)
55 IMPLEMENT_ASN1_FUNCTIONS(ASIdentifierChoice)
56 IMPLEMENT_ASN1_FUNCTIONS(ASIdentifiers)
58 DEFINE_STACK_OF(ASIdOrRange)
59 DEFINE_STACK_OF(CONF_VALUE)
63 * i2r method for an ASIdentifierChoice.
65 static int i2r_ASIdentifierChoice(BIO *out,
66 ASIdentifierChoice *choice,
67 int indent, const char *msg)
73 BIO_printf(out, "%*s%s:\n", indent, "", msg);
74 switch (choice->type) {
75 case ASIdentifierChoice_inherit:
76 BIO_printf(out, "%*sinherit\n", indent + 2, "");
78 case ASIdentifierChoice_asIdsOrRanges:
79 for (i = 0; i < sk_ASIdOrRange_num(choice->u.asIdsOrRanges); i++) {
81 sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
84 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.id)) == NULL)
86 BIO_printf(out, "%*s%s\n", indent + 2, "", s);
89 case ASIdOrRange_range:
90 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.range->min)) == NULL)
92 BIO_printf(out, "%*s%s-", indent + 2, "", s);
94 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.range->max)) == NULL)
96 BIO_printf(out, "%s\n", s);
111 * i2r method for an ASIdentifier extension.
113 static int i2r_ASIdentifiers(const X509V3_EXT_METHOD *method,
114 void *ext, BIO *out, int indent)
116 ASIdentifiers *asid = ext;
117 return (i2r_ASIdentifierChoice(out, asid->asnum, indent,
118 "Autonomous System Numbers") &&
119 i2r_ASIdentifierChoice(out, asid->rdi, indent,
120 "Routing Domain Identifiers"));
124 * Sort comparison function for a sequence of ASIdOrRange elements.
126 static int ASIdOrRange_cmp(const ASIdOrRange *const *a_,
127 const ASIdOrRange *const *b_)
129 const ASIdOrRange *a = *a_, *b = *b_;
131 assert((a->type == ASIdOrRange_id && a->u.id != NULL) ||
132 (a->type == ASIdOrRange_range && a->u.range != NULL &&
133 a->u.range->min != NULL && a->u.range->max != NULL));
135 assert((b->type == ASIdOrRange_id && b->u.id != NULL) ||
136 (b->type == ASIdOrRange_range && b->u.range != NULL &&
137 b->u.range->min != NULL && b->u.range->max != NULL));
139 if (a->type == ASIdOrRange_id && b->type == ASIdOrRange_id)
140 return ASN1_INTEGER_cmp(a->u.id, b->u.id);
142 if (a->type == ASIdOrRange_range && b->type == ASIdOrRange_range) {
143 int r = ASN1_INTEGER_cmp(a->u.range->min, b->u.range->min);
144 return r != 0 ? r : ASN1_INTEGER_cmp(a->u.range->max,
148 if (a->type == ASIdOrRange_id)
149 return ASN1_INTEGER_cmp(a->u.id, b->u.range->min);
151 return ASN1_INTEGER_cmp(a->u.range->min, b->u.id);
155 * Add an inherit element.
157 int X509v3_asid_add_inherit(ASIdentifiers *asid, int which)
159 ASIdentifierChoice **choice;
164 choice = &asid->asnum;
172 if (*choice == NULL) {
173 if ((*choice = ASIdentifierChoice_new()) == NULL)
175 if (((*choice)->u.inherit = ASN1_NULL_new()) == NULL)
177 (*choice)->type = ASIdentifierChoice_inherit;
179 return (*choice)->type == ASIdentifierChoice_inherit;
183 * Add an ID or range to an ASIdentifierChoice.
185 int X509v3_asid_add_id_or_range(ASIdentifiers *asid,
186 int which, ASN1_INTEGER *min, ASN1_INTEGER *max)
188 ASIdentifierChoice **choice;
194 choice = &asid->asnum;
202 if (*choice != NULL && (*choice)->type == ASIdentifierChoice_inherit)
204 if (*choice == NULL) {
205 if ((*choice = ASIdentifierChoice_new()) == NULL)
207 (*choice)->u.asIdsOrRanges = sk_ASIdOrRange_new(ASIdOrRange_cmp);
208 if ((*choice)->u.asIdsOrRanges == NULL)
210 (*choice)->type = ASIdentifierChoice_asIdsOrRanges;
212 if ((aor = ASIdOrRange_new()) == NULL)
215 aor->type = ASIdOrRange_id;
218 aor->type = ASIdOrRange_range;
219 if ((aor->u.range = ASRange_new()) == NULL)
221 ASN1_INTEGER_free(aor->u.range->min);
222 aor->u.range->min = min;
223 ASN1_INTEGER_free(aor->u.range->max);
224 aor->u.range->max = max;
226 if (!(sk_ASIdOrRange_push((*choice)->u.asIdsOrRanges, aor)))
231 ASIdOrRange_free(aor);
236 * Extract min and max values from an ASIdOrRange.
238 static int extract_min_max(ASIdOrRange *aor,
239 ASN1_INTEGER **min, ASN1_INTEGER **max)
241 if (!ossl_assert(aor != NULL))
248 case ASIdOrRange_range:
249 *min = aor->u.range->min;
250 *max = aor->u.range->max;
258 * Check whether an ASIdentifierChoice is in canonical form.
260 static int ASIdentifierChoice_is_canonical(ASIdentifierChoice *choice)
262 ASN1_INTEGER *a_max_plus_one = NULL;
268 * Empty element or inheritance is canonical.
270 if (choice == NULL || choice->type == ASIdentifierChoice_inherit)
274 * If not a list, or if empty list, it's broken.
276 if (choice->type != ASIdentifierChoice_asIdsOrRanges ||
277 sk_ASIdOrRange_num(choice->u.asIdsOrRanges) == 0)
281 * It's a list, check it.
283 for (i = 0; i < sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1; i++) {
284 ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
285 ASIdOrRange *b = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i + 1);
286 ASN1_INTEGER *a_min = NULL, *a_max = NULL, *b_min = NULL, *b_max =
289 if (!extract_min_max(a, &a_min, &a_max)
290 || !extract_min_max(b, &b_min, &b_max))
294 * Punt misordered list, overlapping start, or inverted range.
296 if (ASN1_INTEGER_cmp(a_min, b_min) >= 0 ||
297 ASN1_INTEGER_cmp(a_min, a_max) > 0 ||
298 ASN1_INTEGER_cmp(b_min, b_max) > 0)
302 * Calculate a_max + 1 to check for adjacency.
304 if ((bn == NULL && (bn = BN_new()) == NULL) ||
305 ASN1_INTEGER_to_BN(a_max, bn) == NULL ||
306 !BN_add_word(bn, 1)) {
307 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL,
308 ERR_R_MALLOC_FAILURE);
312 if ((a_max_plus_one =
313 BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) {
314 a_max_plus_one = orig;
315 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL,
316 ERR_R_MALLOC_FAILURE);
321 * Punt if adjacent or overlapping.
323 if (ASN1_INTEGER_cmp(a_max_plus_one, b_min) >= 0)
328 * Check for inverted range.
330 i = sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1;
332 ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
333 ASN1_INTEGER *a_min, *a_max;
334 if (a != NULL && a->type == ASIdOrRange_range) {
335 if (!extract_min_max(a, &a_min, &a_max)
336 || ASN1_INTEGER_cmp(a_min, a_max) > 0)
344 ASN1_INTEGER_free(a_max_plus_one);
350 * Check whether an ASIdentifier extension is in canonical form.
352 int X509v3_asid_is_canonical(ASIdentifiers *asid)
354 return (asid == NULL ||
355 (ASIdentifierChoice_is_canonical(asid->asnum) &&
356 ASIdentifierChoice_is_canonical(asid->rdi)));
360 * Whack an ASIdentifierChoice into canonical form.
362 static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
364 ASN1_INTEGER *a_max_plus_one = NULL;
370 * Nothing to do for empty element or inheritance.
372 if (choice == NULL || choice->type == ASIdentifierChoice_inherit)
376 * If not a list, or if empty list, it's broken.
378 if (choice->type != ASIdentifierChoice_asIdsOrRanges ||
379 sk_ASIdOrRange_num(choice->u.asIdsOrRanges) == 0) {
380 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
381 X509V3_R_EXTENSION_VALUE_ERROR);
386 * We have a non-empty list. Sort it.
388 sk_ASIdOrRange_sort(choice->u.asIdsOrRanges);
391 * Now check for errors and suboptimal encoding, rejecting the
392 * former and fixing the latter.
394 for (i = 0; i < sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1; i++) {
395 ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
396 ASIdOrRange *b = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i + 1);
397 ASN1_INTEGER *a_min = NULL, *a_max = NULL, *b_min = NULL, *b_max =
400 if (!extract_min_max(a, &a_min, &a_max)
401 || !extract_min_max(b, &b_min, &b_max))
405 * Make sure we're properly sorted (paranoia).
407 if (!ossl_assert(ASN1_INTEGER_cmp(a_min, b_min) <= 0))
411 * Punt inverted ranges.
413 if (ASN1_INTEGER_cmp(a_min, a_max) > 0 ||
414 ASN1_INTEGER_cmp(b_min, b_max) > 0)
418 * Check for overlaps.
420 if (ASN1_INTEGER_cmp(a_max, b_min) >= 0) {
421 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
422 X509V3_R_EXTENSION_VALUE_ERROR);
427 * Calculate a_max + 1 to check for adjacency.
429 if ((bn == NULL && (bn = BN_new()) == NULL) ||
430 ASN1_INTEGER_to_BN(a_max, bn) == NULL ||
431 !BN_add_word(bn, 1)) {
432 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
433 ERR_R_MALLOC_FAILURE);
437 if ((a_max_plus_one =
438 BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) {
439 a_max_plus_one = orig;
440 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
441 ERR_R_MALLOC_FAILURE);
446 * If a and b are adjacent, merge them.
448 if (ASN1_INTEGER_cmp(a_max_plus_one, b_min) == 0) {
452 if ((r = OPENSSL_malloc(sizeof(*r))) == NULL) {
453 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
454 ERR_R_MALLOC_FAILURE);
459 a->type = ASIdOrRange_range;
462 case ASIdOrRange_range:
463 ASN1_INTEGER_free(a->u.range->max);
464 a->u.range->max = b_max;
471 case ASIdOrRange_range:
472 b->u.range->max = NULL;
476 (void)sk_ASIdOrRange_delete(choice->u.asIdsOrRanges, i + 1);
483 * Check for final inverted range.
485 i = sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1;
487 ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
488 ASN1_INTEGER *a_min, *a_max;
489 if (a != NULL && a->type == ASIdOrRange_range) {
490 if (!extract_min_max(a, &a_min, &a_max)
491 || ASN1_INTEGER_cmp(a_min, a_max) > 0)
497 if (!ossl_assert(ASIdentifierChoice_is_canonical(choice)))
503 ASN1_INTEGER_free(a_max_plus_one);
509 * Whack an ASIdentifier extension into canonical form.
511 int X509v3_asid_canonize(ASIdentifiers *asid)
513 return (asid == NULL ||
514 (ASIdentifierChoice_canonize(asid->asnum) &&
515 ASIdentifierChoice_canonize(asid->rdi)));
519 * v2i method for an ASIdentifier extension.
521 static void *v2i_ASIdentifiers(const struct v3_ext_method *method,
522 struct v3_ext_ctx *ctx,
523 STACK_OF(CONF_VALUE) *values)
525 ASN1_INTEGER *min = NULL, *max = NULL;
526 ASIdentifiers *asid = NULL;
529 if ((asid = ASIdentifiers_new()) == NULL) {
530 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
534 for (i = 0; i < sk_CONF_VALUE_num(values); i++) {
535 CONF_VALUE *val = sk_CONF_VALUE_value(values, i);
536 int i1 = 0, i2 = 0, i3 = 0, is_range = 0, which = 0;
539 * Figure out whether this is an AS or an RDI.
541 if (!v3_name_cmp(val->name, "AS")) {
542 which = V3_ASID_ASNUM;
543 } else if (!v3_name_cmp(val->name, "RDI")) {
546 X509V3err(X509V3_F_V2I_ASIDENTIFIERS,
547 X509V3_R_EXTENSION_NAME_ERROR);
548 X509V3_conf_err(val);
553 * Handle inheritance.
555 if (strcmp(val->value, "inherit") == 0) {
556 if (X509v3_asid_add_inherit(asid, which))
558 X509V3err(X509V3_F_V2I_ASIDENTIFIERS,
559 X509V3_R_INVALID_INHERITANCE);
560 X509V3_conf_err(val);
565 * Number, range, or mistake, pick it apart and figure out which.
567 i1 = strspn(val->value, "0123456789");
568 if (val->value[i1] == '\0') {
572 i2 = i1 + strspn(val->value + i1, " \t");
573 if (val->value[i2] != '-') {
574 X509V3err(X509V3_F_V2I_ASIDENTIFIERS,
575 X509V3_R_INVALID_ASNUMBER);
576 X509V3_conf_err(val);
580 i2 = i2 + strspn(val->value + i2, " \t");
581 i3 = i2 + strspn(val->value + i2, "0123456789");
582 if (val->value[i3] != '\0') {
583 X509V3err(X509V3_F_V2I_ASIDENTIFIERS,
584 X509V3_R_INVALID_ASRANGE);
585 X509V3_conf_err(val);
591 * Syntax is ok, read and add it.
594 if (!X509V3_get_value_int(val, &min)) {
595 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
599 char *s = OPENSSL_strdup(val->value);
601 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
605 min = s2i_ASN1_INTEGER(NULL, s);
606 max = s2i_ASN1_INTEGER(NULL, s + i2);
608 if (min == NULL || max == NULL) {
609 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
612 if (ASN1_INTEGER_cmp(min, max) > 0) {
613 X509V3err(X509V3_F_V2I_ASIDENTIFIERS,
614 X509V3_R_EXTENSION_VALUE_ERROR);
618 if (!X509v3_asid_add_id_or_range(asid, which, min, max)) {
619 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
626 * Canonize the result, then we're done.
628 if (!X509v3_asid_canonize(asid))
633 ASIdentifiers_free(asid);
634 ASN1_INTEGER_free(min);
635 ASN1_INTEGER_free(max);
642 const X509V3_EXT_METHOD v3_asid = {
643 NID_sbgp_autonomousSysNum, /* nid */
645 ASN1_ITEM_ref(ASIdentifiers), /* template */
646 0, 0, 0, 0, /* old functions, ignored */
650 v2i_ASIdentifiers, /* v2i */
651 i2r_ASIdentifiers, /* i2r */
653 NULL /* extension-specific data */
657 * Figure out whether extension uses inheritance.
659 int X509v3_asid_inherits(ASIdentifiers *asid)
661 return (asid != NULL &&
662 ((asid->asnum != NULL &&
663 asid->asnum->type == ASIdentifierChoice_inherit) ||
664 (asid->rdi != NULL &&
665 asid->rdi->type == ASIdentifierChoice_inherit)));
669 * Figure out whether parent contains child.
671 static int asid_contains(ASIdOrRanges *parent, ASIdOrRanges *child)
673 ASN1_INTEGER *p_min = NULL, *p_max = NULL, *c_min = NULL, *c_max = NULL;
676 if (child == NULL || parent == child)
682 for (c = 0; c < sk_ASIdOrRange_num(child); c++) {
683 if (!extract_min_max(sk_ASIdOrRange_value(child, c), &c_min, &c_max))
686 if (p >= sk_ASIdOrRange_num(parent))
688 if (!extract_min_max(sk_ASIdOrRange_value(parent, p), &p_min,
691 if (ASN1_INTEGER_cmp(p_max, c_max) < 0)
693 if (ASN1_INTEGER_cmp(p_min, c_min) > 0)
703 * Test whether a is a subset of b.
705 int X509v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b)
710 !X509v3_asid_inherits(a) &&
711 !X509v3_asid_inherits(b) &&
712 asid_contains(b->asnum->u.asIdsOrRanges,
713 a->asnum->u.asIdsOrRanges) &&
714 asid_contains(b->rdi->u.asIdsOrRanges,
715 a->rdi->u.asIdsOrRanges)));
719 * Validation error handling via callback.
721 #define validation_err(_err_) \
724 ctx->error = _err_; \
725 ctx->error_depth = i; \
726 ctx->current_cert = x; \
727 ret = ctx->verify_cb(0, ctx); \
736 * Core code for RFC 3779 3.3 path validation.
738 static int asid_validate_path_internal(X509_STORE_CTX *ctx,
739 STACK_OF(X509) *chain,
742 ASIdOrRanges *child_as = NULL, *child_rdi = NULL;
743 int i, ret = 1, inherit_as = 0, inherit_rdi = 0;
746 if (!ossl_assert(chain != NULL && sk_X509_num(chain) > 0)
747 || !ossl_assert(ctx != NULL || ext != NULL)
748 || !ossl_assert(ctx == NULL || ctx->verify_cb != NULL)) {
750 ctx->error = X509_V_ERR_UNSPECIFIED;
756 * Figure out where to start. If we don't have an extension to
757 * check, we're done. Otherwise, check canonical form and
758 * set up for walking up the chain.
765 x = sk_X509_value(chain, i);
766 if ((ext = x->rfc3779_asid) == NULL)
769 if (!X509v3_asid_is_canonical(ext))
770 validation_err(X509_V_ERR_INVALID_EXTENSION);
771 if (ext->asnum != NULL) {
772 switch (ext->asnum->type) {
773 case ASIdentifierChoice_inherit:
776 case ASIdentifierChoice_asIdsOrRanges:
777 child_as = ext->asnum->u.asIdsOrRanges;
781 if (ext->rdi != NULL) {
782 switch (ext->rdi->type) {
783 case ASIdentifierChoice_inherit:
786 case ASIdentifierChoice_asIdsOrRanges:
787 child_rdi = ext->rdi->u.asIdsOrRanges;
793 * Now walk up the chain. Extensions must be in canonical form, no
794 * cert may list resources that its parent doesn't list.
796 for (i++; i < sk_X509_num(chain); i++) {
797 x = sk_X509_value(chain, i);
798 if (!ossl_assert(x != NULL)) {
800 ctx->error = X509_V_ERR_UNSPECIFIED;
803 if (x->rfc3779_asid == NULL) {
804 if (child_as != NULL || child_rdi != NULL)
805 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
808 if (!X509v3_asid_is_canonical(x->rfc3779_asid))
809 validation_err(X509_V_ERR_INVALID_EXTENSION);
810 if (x->rfc3779_asid->asnum == NULL && child_as != NULL) {
811 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
815 if (x->rfc3779_asid->asnum != NULL &&
816 x->rfc3779_asid->asnum->type ==
817 ASIdentifierChoice_asIdsOrRanges) {
819 || asid_contains(x->rfc3779_asid->asnum->u.asIdsOrRanges,
821 child_as = x->rfc3779_asid->asnum->u.asIdsOrRanges;
824 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
827 if (x->rfc3779_asid->rdi == NULL && child_rdi != NULL) {
828 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
832 if (x->rfc3779_asid->rdi != NULL &&
833 x->rfc3779_asid->rdi->type == ASIdentifierChoice_asIdsOrRanges) {
835 asid_contains(x->rfc3779_asid->rdi->u.asIdsOrRanges,
837 child_rdi = x->rfc3779_asid->rdi->u.asIdsOrRanges;
840 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
846 * Trust anchor can't inherit.
848 if (!ossl_assert(x != NULL)) {
850 ctx->error = X509_V_ERR_UNSPECIFIED;
853 if (x->rfc3779_asid != NULL) {
854 if (x->rfc3779_asid->asnum != NULL &&
855 x->rfc3779_asid->asnum->type == ASIdentifierChoice_inherit)
856 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
857 if (x->rfc3779_asid->rdi != NULL &&
858 x->rfc3779_asid->rdi->type == ASIdentifierChoice_inherit)
859 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
866 #undef validation_err
869 * RFC 3779 3.3 path validation -- called from X509_verify_cert().
871 int X509v3_asid_validate_path(X509_STORE_CTX *ctx)
873 if (ctx->chain == NULL
874 || sk_X509_num(ctx->chain) == 0
875 || ctx->verify_cb == NULL) {
876 ctx->error = X509_V_ERR_UNSPECIFIED;
879 return asid_validate_path_internal(ctx, ctx->chain, NULL);
883 * RFC 3779 3.3 path validation of an extension.
884 * Test whether chain covers extension.
886 int X509v3_asid_validate_resource_set(STACK_OF(X509) *chain,
887 ASIdentifiers *ext, int allow_inheritance)
891 if (chain == NULL || sk_X509_num(chain) == 0)
893 if (!allow_inheritance && X509v3_asid_inherits(ext))
895 return asid_validate_path_internal(NULL, chain, ext);
898 #endif /* OPENSSL_NO_RFC3779 */