Add RFC 3779 support, contributed by ARIN.
This commit is contained in:
parent
be3b770d8f
commit
4636341b05
18 changed files with 2458 additions and 4 deletions
3
CHANGES
3
CHANGES
|
@ -4,6 +4,9 @@
|
|||
|
||||
Changes between 0.9.8d and 0.9.8e [XX xxx XXXX]
|
||||
|
||||
*) Add RFC 3779 support.
|
||||
[Rob Austein for ARIN, Ben Laurie]
|
||||
|
||||
*) Load error codes if they are not already present instead of using a
|
||||
static variable. This allows them to be cleanly unloaded and reloaded.
|
||||
Improve header file function name parsing.
|
||||
|
|
|
@ -568,6 +568,7 @@ my $threads=0;
|
|||
my $no_shared=0; # but "no-shared" is default
|
||||
my $zlib=1; # but "no-zlib" is default
|
||||
my $no_krb5=0; # but "no-krb5" is implied unless "--with-krb5-..." is used
|
||||
my $rfc3779=1; # but "no-rfc3779" is default
|
||||
my $no_asm=0;
|
||||
my $no_dso=0;
|
||||
my $no_gmp=0;
|
||||
|
@ -604,6 +605,7 @@ my %disabled = ( # "what" => "comment"
|
|||
"gmp" => "default",
|
||||
"mdc2" => "default",
|
||||
"rc5" => "default",
|
||||
"rfc3779" => "default",
|
||||
"shared" => "default",
|
||||
"zlib" => "default",
|
||||
"zlib-dynamic" => "default"
|
||||
|
@ -883,6 +885,8 @@ foreach (sort (keys %disabled))
|
|||
{ $symlink = 0; }
|
||||
elsif (/^sse2$/)
|
||||
{ $no_sse2 = 1; }
|
||||
elsif (/^rfc3779$/)
|
||||
{ $rfc3779 = 0; }
|
||||
else
|
||||
{
|
||||
my ($ALGO, $algo);
|
||||
|
@ -1120,6 +1124,11 @@ if ($zlib)
|
|||
}
|
||||
}
|
||||
|
||||
if ($rfc3779)
|
||||
{
|
||||
$openssl_other_defines.="#define OPENSSL_RFC3779\n";
|
||||
}
|
||||
|
||||
# You will find shlib_mark1 and shlib_mark2 explained in Makefile.org
|
||||
my $shared_mark = "";
|
||||
if ($shared_target eq "")
|
||||
|
|
|
@ -1520,6 +1520,7 @@ err:
|
|||
if (x509) X509_free(x509);
|
||||
X509_CRL_free(crl);
|
||||
NCONF_free(conf);
|
||||
NCONF_free(extconf);
|
||||
OBJ_cleanup();
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
|
|
|
@ -94,6 +94,10 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
|
|||
ret->ex_pathlen = -1;
|
||||
ret->skid = NULL;
|
||||
ret->akid = NULL;
|
||||
#ifdef OPENSSL_RFC3779
|
||||
ret->rfc3779_addr = NULL;
|
||||
ret->rfc3779_asid = NULL;
|
||||
#endif
|
||||
ret->aux = NULL;
|
||||
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509, ret, &ret->ex_data);
|
||||
break;
|
||||
|
@ -109,6 +113,10 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
|
|||
ASN1_OCTET_STRING_free(ret->skid);
|
||||
AUTHORITY_KEYID_free(ret->akid);
|
||||
policy_cache_free(ret->policy_cache);
|
||||
#ifdef OPENSSL_RFC3779
|
||||
sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free);
|
||||
ASIdentifiers_free(ret->rfc3779_asid);
|
||||
#endif
|
||||
|
||||
if (ret->name != NULL) OPENSSL_free(ret->name);
|
||||
break;
|
||||
|
|
|
@ -234,6 +234,30 @@ STACK_OF(type) \
|
|||
#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st))
|
||||
#define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st))
|
||||
|
||||
#ifdef OPENSSL_RFC3779
|
||||
#define sk_ASIdOrRange_new(st) SKM_sk_new(ASIdOrRange, (st))
|
||||
#define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange)
|
||||
#define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st))
|
||||
#define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st))
|
||||
#define sk_ASIdOrRange_value(st, i) SKM_sk_value(ASIdOrRange, (st), (i))
|
||||
#define sk_ASIdOrRange_set(st, i, val) SKM_sk_set(ASIdOrRange, (st), (i), (val))
|
||||
#define sk_ASIdOrRange_zero(st) SKM_sk_zero(ASIdOrRange, (st))
|
||||
#define sk_ASIdOrRange_push(st, val) SKM_sk_push(ASIdOrRange, (st), (val))
|
||||
#define sk_ASIdOrRange_unshift(st, val) SKM_sk_unshift(ASIdOrRange, (st), (val))
|
||||
#define sk_ASIdOrRange_find(st, val) SKM_sk_find(ASIdOrRange, (st), (val))
|
||||
#define sk_ASIdOrRange_find_ex(st, val) SKM_sk_find_ex(ASIdOrRange, (st), (val))
|
||||
#define sk_ASIdOrRange_delete(st, i) SKM_sk_delete(ASIdOrRange, (st), (i))
|
||||
#define sk_ASIdOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASIdOrRange, (st), (ptr))
|
||||
#define sk_ASIdOrRange_insert(st, val, i) SKM_sk_insert(ASIdOrRange, (st), (val), (i))
|
||||
#define sk_ASIdOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASIdOrRange, (st), (cmp))
|
||||
#define sk_ASIdOrRange_dup(st) SKM_sk_dup(ASIdOrRange, st)
|
||||
#define sk_ASIdOrRange_pop_free(st, free_func) SKM_sk_pop_free(ASIdOrRange, (st), (free_func))
|
||||
#define sk_ASIdOrRange_shift(st) SKM_sk_shift(ASIdOrRange, (st))
|
||||
#define sk_ASIdOrRange_pop(st) SKM_sk_pop(ASIdOrRange, (st))
|
||||
#define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st))
|
||||
#define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st))
|
||||
#endif /* def OPENSSL_RFC3779 */
|
||||
|
||||
#define sk_ASN1_GENERALSTRING_new(st) SKM_sk_new(ASN1_GENERALSTRING, (st))
|
||||
#define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING)
|
||||
#define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st))
|
||||
|
@ -608,6 +632,52 @@ STACK_OF(type) \
|
|||
#define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st))
|
||||
#define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st))
|
||||
|
||||
#ifdef OPENSSL_RFC3779
|
||||
#define sk_IPAddressFamily_new(st) SKM_sk_new(IPAddressFamily, (st))
|
||||
#define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily)
|
||||
#define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st))
|
||||
#define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st))
|
||||
#define sk_IPAddressFamily_value(st, i) SKM_sk_value(IPAddressFamily, (st), (i))
|
||||
#define sk_IPAddressFamily_set(st, i, val) SKM_sk_set(IPAddressFamily, (st), (i), (val))
|
||||
#define sk_IPAddressFamily_zero(st) SKM_sk_zero(IPAddressFamily, (st))
|
||||
#define sk_IPAddressFamily_push(st, val) SKM_sk_push(IPAddressFamily, (st), (val))
|
||||
#define sk_IPAddressFamily_unshift(st, val) SKM_sk_unshift(IPAddressFamily, (st), (val))
|
||||
#define sk_IPAddressFamily_find(st, val) SKM_sk_find(IPAddressFamily, (st), (val))
|
||||
#define sk_IPAddressFamily_find_ex(st, val) SKM_sk_find_ex(IPAddressFamily, (st), (val))
|
||||
#define sk_IPAddressFamily_delete(st, i) SKM_sk_delete(IPAddressFamily, (st), (i))
|
||||
#define sk_IPAddressFamily_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressFamily, (st), (ptr))
|
||||
#define sk_IPAddressFamily_insert(st, val, i) SKM_sk_insert(IPAddressFamily, (st), (val), (i))
|
||||
#define sk_IPAddressFamily_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressFamily, (st), (cmp))
|
||||
#define sk_IPAddressFamily_dup(st) SKM_sk_dup(IPAddressFamily, st)
|
||||
#define sk_IPAddressFamily_pop_free(st, free_func) SKM_sk_pop_free(IPAddressFamily, (st), (free_func))
|
||||
#define sk_IPAddressFamily_shift(st) SKM_sk_shift(IPAddressFamily, (st))
|
||||
#define sk_IPAddressFamily_pop(st) SKM_sk_pop(IPAddressFamily, (st))
|
||||
#define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st))
|
||||
#define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st))
|
||||
|
||||
#define sk_IPAddressOrRange_new(st) SKM_sk_new(IPAddressOrRange, (st))
|
||||
#define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange)
|
||||
#define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st))
|
||||
#define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st))
|
||||
#define sk_IPAddressOrRange_value(st, i) SKM_sk_value(IPAddressOrRange, (st), (i))
|
||||
#define sk_IPAddressOrRange_set(st, i, val) SKM_sk_set(IPAddressOrRange, (st), (i), (val))
|
||||
#define sk_IPAddressOrRange_zero(st) SKM_sk_zero(IPAddressOrRange, (st))
|
||||
#define sk_IPAddressOrRange_push(st, val) SKM_sk_push(IPAddressOrRange, (st), (val))
|
||||
#define sk_IPAddressOrRange_unshift(st, val) SKM_sk_unshift(IPAddressOrRange, (st), (val))
|
||||
#define sk_IPAddressOrRange_find(st, val) SKM_sk_find(IPAddressOrRange, (st), (val))
|
||||
#define sk_IPAddressOrRange_find_ex(st, val) SKM_sk_find_ex(IPAddressOrRange, (st), (val))
|
||||
#define sk_IPAddressOrRange_delete(st, i) SKM_sk_delete(IPAddressOrRange, (st), (i))
|
||||
#define sk_IPAddressOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressOrRange, (st), (ptr))
|
||||
#define sk_IPAddressOrRange_insert(st, val, i) SKM_sk_insert(IPAddressOrRange, (st), (val), (i))
|
||||
#define sk_IPAddressOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressOrRange, (st), (cmp))
|
||||
#define sk_IPAddressOrRange_dup(st) SKM_sk_dup(IPAddressOrRange, st)
|
||||
#define sk_IPAddressOrRange_pop_free(st, free_func) SKM_sk_pop_free(IPAddressOrRange, (st), (free_func))
|
||||
#define sk_IPAddressOrRange_shift(st) SKM_sk_shift(IPAddressOrRange, (st))
|
||||
#define sk_IPAddressOrRange_pop(st) SKM_sk_pop(IPAddressOrRange, (st))
|
||||
#define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st))
|
||||
#define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st))
|
||||
#endif /* def OPENSSL_RFC3779 */
|
||||
|
||||
#define sk_KRB5_APREQBODY_new(st) SKM_sk_new(KRB5_APREQBODY, (st))
|
||||
#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY)
|
||||
#define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st))
|
||||
|
|
|
@ -288,6 +288,10 @@ struct x509_st
|
|||
ASN1_OCTET_STRING *skid;
|
||||
struct AUTHORITY_KEYID_st *akid;
|
||||
X509_POLICY_CACHE *policy_cache;
|
||||
#ifdef OPENSSL_RFC3779
|
||||
STACK_OF(IPAddressFamily) *rfc3779_addr;
|
||||
struct ASIdentifiers_st *rfc3779_asid;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SHA
|
||||
unsigned char sha1_hash[SHA_DIGEST_LENGTH];
|
||||
#endif
|
||||
|
|
|
@ -162,6 +162,8 @@ const char *X509_verify_cert_error_string(long n)
|
|||
return("invalid or inconsistent certificate policy extension");
|
||||
case X509_V_ERR_NO_EXPLICIT_POLICY:
|
||||
return("no explicit policy");
|
||||
case X509_V_ERR_UNNESTED_RESOURCE:
|
||||
return("RFC 3779 resource not subset of parent's resources");
|
||||
default:
|
||||
BIO_snprintf(buf,sizeof buf,"error number %ld",n);
|
||||
return(buf);
|
||||
|
|
|
@ -312,6 +312,14 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
|
|||
ok=internal_verify(ctx);
|
||||
if(!ok) goto end;
|
||||
|
||||
#ifdef OPENSSL_RFC3779
|
||||
/* RFC 3779 path validation, now that CRL check has been done */
|
||||
ok = v3_asid_validate_path(ctx);
|
||||
if (!ok) goto end;
|
||||
ok = v3_addr_validate_path(ctx);
|
||||
if (!ok) goto end;
|
||||
#endif
|
||||
|
||||
/* If we get this far evaluate policies */
|
||||
if (!bad_chain && (ctx->param->flags & X509_V_FLAG_POLICY_CHECK))
|
||||
ok = ctx->check_policy(ctx);
|
||||
|
|
|
@ -331,6 +331,7 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
|
|||
#define X509_V_ERR_INVALID_POLICY_EXTENSION 42
|
||||
#define X509_V_ERR_NO_EXPLICIT_POLICY 43
|
||||
|
||||
#define X509_V_ERR_UNNESTED_RESOURCE 44
|
||||
|
||||
/* The application is not happy */
|
||||
#define X509_V_ERR_APPLICATION_VERIFICATION 50
|
||||
|
|
|
@ -21,12 +21,14 @@ LIBSRC= v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c v3_lib.c \
|
|||
v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c v3_pku.c \
|
||||
v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.c \
|
||||
v3_ocsp.c v3_akeya.c v3_pmaps.c v3_pcons.c v3_ncons.c v3_pcia.c v3_pci.c \
|
||||
pcy_cache.c pcy_node.c pcy_data.c pcy_map.c pcy_tree.c pcy_lib.c
|
||||
pcy_cache.c pcy_node.c pcy_data.c pcy_map.c pcy_tree.c pcy_lib.c \
|
||||
v3_asid.c v3_addr.c
|
||||
LIBOBJ= v3_bcons.o v3_bitst.o v3_conf.o v3_extku.o v3_ia5.o v3_lib.o \
|
||||
v3_prn.o v3_utl.o v3err.o v3_genn.o v3_alt.o v3_skey.o v3_akey.o v3_pku.o \
|
||||
v3_int.o v3_enum.o v3_sxnet.o v3_cpols.o v3_crld.o v3_purp.o v3_info.o \
|
||||
v3_ocsp.o v3_akeya.o v3_pmaps.o v3_pcons.o v3_ncons.o v3_pcia.o v3_pci.o \
|
||||
pcy_cache.o pcy_node.o pcy_data.o pcy_map.o pcy_tree.o pcy_lib.o
|
||||
pcy_cache.o pcy_node.o pcy_data.o pcy_map.o pcy_tree.o pcy_lib.o \
|
||||
v3_asid.o v3_addr.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
|
@ -166,6 +168,20 @@ pcy_tree.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
|||
pcy_tree.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
pcy_tree.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
|
||||
pcy_tree.o: ../cryptlib.h pcy_int.h pcy_tree.c
|
||||
v3_addr.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
v3_addr.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
|
||||
v3_addr.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
|
||||
v3_addr.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
v3_addr.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
v3_addr.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
|
||||
v3_addr.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
v3_addr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
v3_addr.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
v3_addr.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
v3_addr.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
v3_addr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
v3_addr.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
v3_addr.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_addr.c
|
||||
v3_akey.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
v3_akey.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
|
||||
v3_akey.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
|
||||
|
@ -208,6 +224,21 @@ v3_alt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
|||
v3_alt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
v3_alt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
v3_alt.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_alt.c
|
||||
v3_asid.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
v3_asid.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
|
||||
v3_asid.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
|
||||
v3_asid.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
|
||||
v3_asid.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
v3_asid.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
v3_asid.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
v3_asid.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
v3_asid.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
v3_asid.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
v3_asid.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
v3_asid.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
v3_asid.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
v3_asid.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
|
||||
v3_asid.o: ../cryptlib.h v3_asid.c
|
||||
v3_bcons.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
v3_bcons.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
|
||||
v3_bcons.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
|
||||
|
|
|
@ -67,6 +67,9 @@ extern X509V3_EXT_METHOD v3_ocsp_crlid, v3_ocsp_nocheck, v3_ocsp_serviceloc;
|
|||
extern X509V3_EXT_METHOD v3_crl_hold, v3_pci;
|
||||
extern X509V3_EXT_METHOD v3_policy_mappings, v3_policy_constraints;
|
||||
extern X509V3_EXT_METHOD v3_name_constraints, v3_inhibit_anyp;
|
||||
#ifdef OPENSSL_RFC3779
|
||||
extern X509V3_EXT_METHOD v3_addr, v3_asid;
|
||||
#endif
|
||||
|
||||
/* This table will be searched using OBJ_bsearch so it *must* kept in
|
||||
* order of the ext_nid values.
|
||||
|
@ -99,6 +102,10 @@ static X509V3_EXT_METHOD *standard_exts[] = {
|
|||
#endif
|
||||
&v3_sxnet,
|
||||
&v3_info,
|
||||
#ifdef OPENSSL_RFC3779
|
||||
&v3_addr,
|
||||
&v3_asid,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_OCSP
|
||||
&v3_ocsp_nonce,
|
||||
&v3_ocsp_crlid,
|
||||
|
|
|
@ -628,6 +628,16 @@ int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
|
|||
/* Tree OK: continue */
|
||||
|
||||
case 1:
|
||||
if (!tree)
|
||||
/*
|
||||
* tree_init() returns success and a null tree
|
||||
* if it's just looking at a trust anchor.
|
||||
* I'm not sure that returning success here is
|
||||
* correct, but I'm sure that reporting this
|
||||
* as an internal error which our caller
|
||||
* interprets as a malloc failure is wrong.
|
||||
*/
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
1279
crypto/x509v3/v3_addr.c
Normal file
1279
crypto/x509v3/v3_addr.c
Normal file
File diff suppressed because it is too large
Load diff
842
crypto/x509v3/v3_asid.c
Normal file
842
crypto/x509v3/v3_asid.c
Normal file
|
@ -0,0 +1,842 @@
|
|||
/*
|
||||
* Contributed to the OpenSSL Project by the American Registry for
|
||||
* Internet Numbers ("ARIN").
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*/
|
||||
|
||||
/*
|
||||
* Implementation of RFC 3779 section 3.2.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/asn1t.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/bn.h>
|
||||
|
||||
#ifdef OPENSSL_RFC3779
|
||||
|
||||
/*
|
||||
* OpenSSL ASN.1 template translation of RFC 3779 3.2.3.
|
||||
*/
|
||||
|
||||
ASN1_SEQUENCE(ASRange) = {
|
||||
ASN1_SIMPLE(ASRange, min, ASN1_INTEGER),
|
||||
ASN1_SIMPLE(ASRange, max, ASN1_INTEGER)
|
||||
} ASN1_SEQUENCE_END(ASRange)
|
||||
|
||||
ASN1_CHOICE(ASIdOrRange) = {
|
||||
ASN1_SIMPLE(ASIdOrRange, u.id, ASN1_INTEGER),
|
||||
ASN1_SIMPLE(ASIdOrRange, u.range, ASRange)
|
||||
} ASN1_CHOICE_END(ASIdOrRange)
|
||||
|
||||
ASN1_CHOICE(ASIdentifierChoice) = {
|
||||
ASN1_SIMPLE(ASIdentifierChoice, u.inherit, ASN1_NULL),
|
||||
ASN1_SEQUENCE_OF(ASIdentifierChoice, u.asIdsOrRanges, ASIdOrRange)
|
||||
} ASN1_CHOICE_END(ASIdentifierChoice)
|
||||
|
||||
ASN1_SEQUENCE(ASIdentifiers) = {
|
||||
ASN1_EXP_OPT(ASIdentifiers, asnum, ASIdentifierChoice, 0),
|
||||
ASN1_EXP_OPT(ASIdentifiers, rdi, ASIdentifierChoice, 1)
|
||||
} ASN1_SEQUENCE_END(ASIdentifiers)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ASRange)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ASIdOrRange)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ASIdentifierChoice)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ASIdentifiers)
|
||||
|
||||
/*
|
||||
* i2r method for an ASIdentifierChoice.
|
||||
*/
|
||||
static int i2r_ASIdentifierChoice(BIO *out,
|
||||
ASIdentifierChoice *choice,
|
||||
int indent,
|
||||
const char *msg)
|
||||
{
|
||||
int i;
|
||||
char *s;
|
||||
if (choice == NULL)
|
||||
return 1;
|
||||
BIO_printf(out, "%*s%s:\n", indent, "", msg);
|
||||
switch (choice->type) {
|
||||
case ASIdentifierChoice_inherit:
|
||||
BIO_printf(out, "%*sinherit\n", indent + 2, "");
|
||||
break;
|
||||
case ASIdentifierChoice_asIdsOrRanges:
|
||||
for (i = 0; i < sk_ASIdOrRange_num(choice->u.asIdsOrRanges); i++) {
|
||||
ASIdOrRange *aor = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
|
||||
switch (aor->type) {
|
||||
case ASIdOrRange_id:
|
||||
if ((s = i2s_ASN1_INTEGER(NULL, aor->u.id)) == NULL)
|
||||
return 0;
|
||||
BIO_printf(out, "%*s%s\n", indent + 2, "", s);
|
||||
OPENSSL_free(s);
|
||||
break;
|
||||
case ASIdOrRange_range:
|
||||
if ((s = i2s_ASN1_INTEGER(NULL, aor->u.range->min)) == NULL)
|
||||
return 0;
|
||||
BIO_printf(out, "%*s%s-", indent + 2, "", s);
|
||||
OPENSSL_free(s);
|
||||
if ((s = i2s_ASN1_INTEGER(NULL, aor->u.range->max)) == NULL)
|
||||
return 0;
|
||||
BIO_printf(out, "%s\n", s);
|
||||
OPENSSL_free(s);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* i2r method for an ASIdentifier extension.
|
||||
*/
|
||||
static int i2r_ASIdentifiers(X509V3_EXT_METHOD *method,
|
||||
void *ext,
|
||||
BIO *out,
|
||||
int indent)
|
||||
{
|
||||
ASIdentifiers *asid = ext;
|
||||
return (i2r_ASIdentifierChoice(out, asid->asnum, indent,
|
||||
"Autonomous System Numbers") &&
|
||||
i2r_ASIdentifierChoice(out, asid->rdi, indent,
|
||||
"Routing Domain Identifiers"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Sort comparision function for a sequence of ASIdOrRange elements.
|
||||
*/
|
||||
static int ASIdOrRange_cmp(const ASIdOrRange * const *a_,
|
||||
const ASIdOrRange * const *b_)
|
||||
{
|
||||
const ASIdOrRange *a = *a_, *b = *b_;
|
||||
|
||||
assert((a->type == ASIdOrRange_id && a->u.id != NULL) ||
|
||||
(a->type == ASIdOrRange_range && a->u.range != NULL &&
|
||||
a->u.range->min != NULL && a->u.range->max != NULL));
|
||||
|
||||
assert((b->type == ASIdOrRange_id && b->u.id != NULL) ||
|
||||
(b->type == ASIdOrRange_range && b->u.range != NULL &&
|
||||
b->u.range->min != NULL && b->u.range->max != NULL));
|
||||
|
||||
if (a->type == ASIdOrRange_id && b->type == ASIdOrRange_id)
|
||||
return ASN1_INTEGER_cmp(a->u.id, b->u.id);
|
||||
|
||||
if (a->type == ASIdOrRange_range && b->type == ASIdOrRange_range) {
|
||||
int r = ASN1_INTEGER_cmp(a->u.range->min, b->u.range->min);
|
||||
return r != 0 ? r : ASN1_INTEGER_cmp(a->u.range->max, b->u.range->max);
|
||||
}
|
||||
|
||||
if (a->type == ASIdOrRange_id)
|
||||
return ASN1_INTEGER_cmp(a->u.id, b->u.range->min);
|
||||
else
|
||||
return ASN1_INTEGER_cmp(a->u.range->min, b->u.id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add an inherit element.
|
||||
*/
|
||||
int v3_asid_add_inherit(ASIdentifiers *asid, int which)
|
||||
{
|
||||
ASIdentifierChoice **choice;
|
||||
if (asid == NULL)
|
||||
return 0;
|
||||
switch (which) {
|
||||
case V3_ASID_ASNUM:
|
||||
choice = &asid->asnum;
|
||||
break;
|
||||
case V3_ASID_RDI:
|
||||
choice = &asid->rdi;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if (*choice == NULL) {
|
||||
if ((*choice = ASIdentifierChoice_new()) == NULL)
|
||||
return 0;
|
||||
assert((*choice)->u.inherit == NULL);
|
||||
if (((*choice)->u.inherit = ASN1_NULL_new()) == NULL)
|
||||
return 0;
|
||||
(*choice)->type = ASIdentifierChoice_inherit;
|
||||
}
|
||||
return (*choice)->type == ASIdentifierChoice_inherit;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add an ID or range to an ASIdentifierChoice.
|
||||
*/
|
||||
int v3_asid_add_id_or_range(ASIdentifiers *asid,
|
||||
int which,
|
||||
ASN1_INTEGER *min,
|
||||
ASN1_INTEGER *max)
|
||||
{
|
||||
ASIdentifierChoice **choice;
|
||||
ASIdOrRange *aor;
|
||||
if (asid == NULL)
|
||||
return 0;
|
||||
switch (which) {
|
||||
case V3_ASID_ASNUM:
|
||||
choice = &asid->asnum;
|
||||
break;
|
||||
case V3_ASID_RDI:
|
||||
choice = &asid->rdi;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if (*choice != NULL && (*choice)->type == ASIdentifierChoice_inherit)
|
||||
return 0;
|
||||
if (*choice == NULL) {
|
||||
if ((*choice = ASIdentifierChoice_new()) == NULL)
|
||||
return 0;
|
||||
assert((*choice)->u.asIdsOrRanges == NULL);
|
||||
(*choice)->u.asIdsOrRanges = sk_ASIdOrRange_new(ASIdOrRange_cmp);
|
||||
if ((*choice)->u.asIdsOrRanges == NULL)
|
||||
return 0;
|
||||
(*choice)->type = ASIdentifierChoice_asIdsOrRanges;
|
||||
}
|
||||
if ((aor = ASIdOrRange_new()) == NULL)
|
||||
return 0;
|
||||
if (max == NULL) {
|
||||
aor->type = ASIdOrRange_id;
|
||||
aor->u.id = min;
|
||||
} else {
|
||||
aor->type = ASIdOrRange_range;
|
||||
if ((aor->u.range = ASRange_new()) == NULL)
|
||||
goto err;
|
||||
ASN1_INTEGER_free(aor->u.range->min);
|
||||
aor->u.range->min = min;
|
||||
ASN1_INTEGER_free(aor->u.range->max);
|
||||
aor->u.range->max = max;
|
||||
}
|
||||
if (!(sk_ASIdOrRange_push((*choice)->u.asIdsOrRanges, aor)))
|
||||
goto err;
|
||||
return 1;
|
||||
|
||||
err:
|
||||
ASIdOrRange_free(aor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract min and max values from an ASIdOrRange.
|
||||
*/
|
||||
static void extract_min_max(ASIdOrRange *aor,
|
||||
ASN1_INTEGER **min,
|
||||
ASN1_INTEGER **max)
|
||||
{
|
||||
assert(aor != NULL && min != NULL && max != NULL);
|
||||
switch (aor->type) {
|
||||
case ASIdOrRange_id:
|
||||
*min = aor->u.id;
|
||||
*max = aor->u.id;
|
||||
return;
|
||||
case ASIdOrRange_range:
|
||||
*min = aor->u.range->min;
|
||||
*max = aor->u.range->max;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check whether an ASIdentifierChoice is in canonical form.
|
||||
*/
|
||||
static int ASIdentifierChoice_is_canonical(ASIdentifierChoice *choice)
|
||||
{
|
||||
ASN1_INTEGER *a_max_plus_one = NULL;
|
||||
BIGNUM *bn = NULL;
|
||||
int i, ret = 0;
|
||||
|
||||
/*
|
||||
* Empty element or inheritance is canonical.
|
||||
*/
|
||||
if (choice == NULL || choice->type == ASIdentifierChoice_inherit)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* If not a list, or if empty list, it's broken.
|
||||
*/
|
||||
if (choice->type != ASIdentifierChoice_asIdsOrRanges ||
|
||||
sk_ASIdOrRange_num(choice->u.asIdsOrRanges) == 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* It's a list, check it.
|
||||
*/
|
||||
for (i = 0; i < sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1; i++) {
|
||||
ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
|
||||
ASIdOrRange *b = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i + 1);
|
||||
ASN1_INTEGER *a_min, *a_max, *b_min, *b_max;
|
||||
|
||||
extract_min_max(a, &a_min, &a_max);
|
||||
extract_min_max(b, &b_min, &b_max);
|
||||
|
||||
/*
|
||||
* Punt misordered list, overlapping start, or inverted range.
|
||||
*/
|
||||
if (ASN1_INTEGER_cmp(a_min, b_min) >= 0 ||
|
||||
ASN1_INTEGER_cmp(a_min, a_max) > 0 ||
|
||||
ASN1_INTEGER_cmp(b_min, b_max) > 0)
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* Calculate a_max + 1 to check for adjacency.
|
||||
*/
|
||||
if ((bn == NULL && (bn = BN_new()) == NULL) ||
|
||||
ASN1_INTEGER_to_BN(a_max, bn) == NULL ||
|
||||
!BN_add_word(bn, 1) ||
|
||||
(a_max_plus_one = BN_to_ASN1_INTEGER(bn, a_max_plus_one)) == NULL) {
|
||||
X509V3err(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Punt if adjacent or overlapping.
|
||||
*/
|
||||
if (ASN1_INTEGER_cmp(a_max_plus_one, b_min) >= 0)
|
||||
goto done;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
done:
|
||||
ASN1_INTEGER_free(a_max_plus_one);
|
||||
BN_free(bn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check whether an ASIdentifier extension is in canonical form.
|
||||
*/
|
||||
int v3_asid_is_canonical(ASIdentifiers *asid)
|
||||
{
|
||||
return (asid == NULL ||
|
||||
(ASIdentifierChoice_is_canonical(asid->asnum) ||
|
||||
ASIdentifierChoice_is_canonical(asid->rdi)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Whack an ASIdentifierChoice into canonical form.
|
||||
*/
|
||||
static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
|
||||
{
|
||||
ASN1_INTEGER *a_max_plus_one = NULL;
|
||||
BIGNUM *bn = NULL;
|
||||
int i, ret = 0;
|
||||
|
||||
/*
|
||||
* Nothing to do for empty element or inheritance.
|
||||
*/
|
||||
if (choice == NULL || choice->type == ASIdentifierChoice_inherit)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* We have a list. Sort it.
|
||||
*/
|
||||
assert(choice->type == ASIdentifierChoice_asIdsOrRanges);
|
||||
sk_ASIdOrRange_sort(choice->u.asIdsOrRanges);
|
||||
|
||||
/*
|
||||
* Now check for errors and suboptimal encoding, rejecting the
|
||||
* former and fixing the latter.
|
||||
*/
|
||||
for (i = 0; i < sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1; i++) {
|
||||
ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
|
||||
ASIdOrRange *b = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i + 1);
|
||||
ASN1_INTEGER *a_min, *a_max, *b_min, *b_max;
|
||||
|
||||
extract_min_max(a, &a_min, &a_max);
|
||||
extract_min_max(b, &b_min, &b_max);
|
||||
|
||||
/*
|
||||
* Make sure we're properly sorted (paranoia).
|
||||
*/
|
||||
assert(ASN1_INTEGER_cmp(a_min, b_min) <= 0);
|
||||
|
||||
/*
|
||||
* Check for overlaps.
|
||||
*/
|
||||
if (ASN1_INTEGER_cmp(a_max, b_min) >= 0) {
|
||||
X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
|
||||
X509V3_R_EXTENSION_VALUE_ERROR);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate a_max + 1 to check for adjacency.
|
||||
*/
|
||||
if ((bn == NULL && (bn = BN_new()) == NULL) ||
|
||||
ASN1_INTEGER_to_BN(a_max, bn) == NULL ||
|
||||
!BN_add_word(bn, 1) ||
|
||||
(a_max_plus_one = BN_to_ASN1_INTEGER(bn, a_max_plus_one)) == NULL) {
|
||||
X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, ERR_R_MALLOC_FAILURE);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* If a and b are adjacent, merge them.
|
||||
*/
|
||||
if (ASN1_INTEGER_cmp(a_max_plus_one, b_min) == 0) {
|
||||
ASRange *r;
|
||||
switch (a->type) {
|
||||
case ASIdOrRange_id:
|
||||
if ((r = OPENSSL_malloc(sizeof(ASRange))) == NULL) {
|
||||
X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto done;
|
||||
}
|
||||
r->min = a_min;
|
||||
r->max = b_max;
|
||||
a->type = ASIdOrRange_range;
|
||||
a->u.range = r;
|
||||
break;
|
||||
case ASIdOrRange_range:
|
||||
ASN1_INTEGER_free(a->u.range->max);
|
||||
a->u.range->max = b_max;
|
||||
break;
|
||||
}
|
||||
switch (b->type) {
|
||||
case ASIdOrRange_id:
|
||||
b->u.id = NULL;
|
||||
break;
|
||||
case ASIdOrRange_range:
|
||||
b->u.range->max = NULL;
|
||||
break;
|
||||
}
|
||||
ASIdOrRange_free(b);
|
||||
sk_ASIdOrRange_delete(choice->u.asIdsOrRanges, i + 1);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
assert(ASIdentifierChoice_is_canonical(choice)); /* Paranoia */
|
||||
|
||||
ret = 1;
|
||||
|
||||
done:
|
||||
ASN1_INTEGER_free(a_max_plus_one);
|
||||
BN_free(bn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Whack an ASIdentifier extension into canonical form.
|
||||
*/
|
||||
int v3_asid_canonize(ASIdentifiers *asid)
|
||||
{
|
||||
return (asid == NULL ||
|
||||
(ASIdentifierChoice_canonize(asid->asnum) &&
|
||||
ASIdentifierChoice_canonize(asid->rdi)));
|
||||
}
|
||||
|
||||
/*
|
||||
* v2i method for an ASIdentifier extension.
|
||||
*/
|
||||
static void *v2i_ASIdentifiers(struct v3_ext_method *method,
|
||||
struct v3_ext_ctx *ctx,
|
||||
STACK_OF(CONF_VALUE) *values)
|
||||
{
|
||||
ASIdentifiers *asid = NULL;
|
||||
int i;
|
||||
|
||||
if ((asid = ASIdentifiers_new()) == NULL) {
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < sk_CONF_VALUE_num(values); i++) {
|
||||
CONF_VALUE *val = sk_CONF_VALUE_value(values, i);
|
||||
ASN1_INTEGER *min = NULL, *max = NULL;
|
||||
int i1, i2, i3, is_range, which;
|
||||
|
||||
/*
|
||||
* Figure out whether this is an AS or an RDI.
|
||||
*/
|
||||
if ( !name_cmp(val->name, "AS")) {
|
||||
which = V3_ASID_ASNUM;
|
||||
} else if (!name_cmp(val->name, "RDI")) {
|
||||
which = V3_ASID_RDI;
|
||||
} else {
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, X509V3_R_EXTENSION_NAME_ERROR);
|
||||
X509V3_conf_err(val);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle inheritance.
|
||||
*/
|
||||
if (!strcmp(val->value, "inherit")) {
|
||||
if (v3_asid_add_inherit(asid, which))
|
||||
continue;
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, X509V3_R_INVALID_INHERITANCE);
|
||||
X509V3_conf_err(val);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Number, range, or mistake, pick it apart and figure out which.
|
||||
*/
|
||||
i1 = strspn(val->value, "0123456789");
|
||||
if (val->value[i1] == '\0') {
|
||||
is_range = 0;
|
||||
} else {
|
||||
is_range = 1;
|
||||
i2 = i1 + strspn(val->value + i1, " \t");
|
||||
if (val->value[i2] != '-') {
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, X509V3_R_INVALID_ASNUMBER);
|
||||
X509V3_conf_err(val);
|
||||
goto err;
|
||||
}
|
||||
i2++;
|
||||
i2 = i2 + strspn(val->value + i2, " \t");
|
||||
i3 = i2 + strspn(val->value + i2, "0123456789");
|
||||
if (val->value[i3] != '\0') {
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, X509V3_R_INVALID_ASRANGE);
|
||||
X509V3_conf_err(val);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Syntax is ok, read and add it.
|
||||
*/
|
||||
if (!is_range) {
|
||||
if (!X509V3_get_value_int(val, &min)) {
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
char *s = BUF_strdup(val->value);
|
||||
if (s == NULL) {
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
s[i1] = '\0';
|
||||
min = s2i_ASN1_INTEGER(NULL, s);
|
||||
max = s2i_ASN1_INTEGER(NULL, s + i2);
|
||||
OPENSSL_free(s);
|
||||
if (min == NULL || max == NULL) {
|
||||
ASN1_INTEGER_free(min);
|
||||
ASN1_INTEGER_free(max);
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!v3_asid_add_id_or_range(asid, which, min, max)) {
|
||||
ASN1_INTEGER_free(min);
|
||||
ASN1_INTEGER_free(max);
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Canonize the result, then we're done.
|
||||
*/
|
||||
if (!v3_asid_canonize(asid))
|
||||
goto err;
|
||||
return asid;
|
||||
|
||||
err:
|
||||
ASIdentifiers_free(asid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* OpenSSL dispatch.
|
||||
*/
|
||||
X509V3_EXT_METHOD v3_asid = {
|
||||
NID_sbgp_autonomousSysNum, /* nid */
|
||||
0, /* flags */
|
||||
ASN1_ITEM_ref(ASIdentifiers), /* template */
|
||||
0, 0, 0, 0, /* old functions, ignored */
|
||||
0, /* i2s */
|
||||
0, /* s2i */
|
||||
0, /* i2v */
|
||||
v2i_ASIdentifiers, /* v2i */
|
||||
i2r_ASIdentifiers, /* i2r */
|
||||
0, /* r2i */
|
||||
NULL /* extension-specific data */
|
||||
};
|
||||
|
||||
/*
|
||||
* Figure out whether extension uses inheritance.
|
||||
*/
|
||||
int v3_asid_inherits(ASIdentifiers *asid)
|
||||
{
|
||||
return (asid != NULL &&
|
||||
((asid->asnum != NULL &&
|
||||
asid->asnum->type == ASIdentifierChoice_inherit) ||
|
||||
(asid->rdi != NULL &&
|
||||
asid->rdi->type == ASIdentifierChoice_inherit)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Figure out whether parent contains child.
|
||||
*/
|
||||
static int asid_contains(ASIdOrRanges *parent, ASIdOrRanges *child)
|
||||
{
|
||||
ASN1_INTEGER *p_min, *p_max, *c_min, *c_max;
|
||||
int p, c;
|
||||
|
||||
if (child == NULL || parent == child)
|
||||
return 1;
|
||||
if (parent == NULL)
|
||||
return 0;
|
||||
|
||||
p = 0;
|
||||
for (c = 0; c < sk_ASIdOrRange_num(child); c++) {
|
||||
extract_min_max(sk_ASIdOrRange_value(child, c), &c_min, &c_max);
|
||||
for (;; p++) {
|
||||
if (p >= sk_ASIdOrRange_num(parent))
|
||||
return 0;
|
||||
extract_min_max(sk_ASIdOrRange_value(parent, p), &p_min, &p_max);
|
||||
if (ASN1_INTEGER_cmp(p_max, c_max) < 0)
|
||||
continue;
|
||||
if (ASN1_INTEGER_cmp(p_min, c_min) > 0)
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test whether a is a subet of b.
|
||||
*/
|
||||
int v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b)
|
||||
{
|
||||
return (a == NULL ||
|
||||
a == b ||
|
||||
(b != NULL &&
|
||||
!v3_asid_inherits(a) &&
|
||||
!v3_asid_inherits(b) &&
|
||||
asid_contains(b->asnum->u.asIdsOrRanges,
|
||||
a->asnum->u.asIdsOrRanges) &&
|
||||
asid_contains(b->rdi->u.asIdsOrRanges,
|
||||
a->rdi->u.asIdsOrRanges)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validation error handling via callback.
|
||||
*/
|
||||
#define validation_err(_err_) \
|
||||
do { \
|
||||
if (ctx != NULL) { \
|
||||
ctx->error = _err_; \
|
||||
ctx->error_depth = i; \
|
||||
ctx->current_cert = x; \
|
||||
ret = ctx->verify_cb(0, ctx); \
|
||||
} else { \
|
||||
ret = 0; \
|
||||
} \
|
||||
if (!ret) \
|
||||
goto done; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Core code for RFC 3779 3.3 path validation.
|
||||
*/
|
||||
static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
|
||||
STACK_OF(X509) *chain,
|
||||
ASIdentifiers *ext)
|
||||
{
|
||||
ASIdOrRanges *child_as = NULL, *child_rdi = NULL;
|
||||
int i, ret = 1, inherit_as = 0, inherit_rdi = 0;
|
||||
X509 *x = NULL;
|
||||
|
||||
assert(chain != NULL && sk_X509_num(chain) > 0);
|
||||
assert(ctx != NULL || ext != NULL);
|
||||
assert(ctx == NULL || ctx->verify_cb != NULL);
|
||||
|
||||
/*
|
||||
* Figure out where to start. If we don't have an extension to
|
||||
* check, we're done. Otherwise, check canonical form and
|
||||
* set up for walking up the chain.
|
||||
*/
|
||||
if (ext != NULL) {
|
||||
i = -1;
|
||||
} else {
|
||||
i = 0;
|
||||
x = sk_X509_value(chain, i);
|
||||
assert(x != NULL);
|
||||
if ((ext = x->rfc3779_asid) == NULL)
|
||||
goto done;
|
||||
}
|
||||
if (!v3_asid_is_canonical(ext))
|
||||
validation_err(X509_V_ERR_INVALID_EXTENSION);
|
||||
if (ext->asnum != NULL) {
|
||||
switch (ext->asnum->type) {
|
||||
case ASIdentifierChoice_inherit:
|
||||
inherit_as = 1;
|
||||
break;
|
||||
case ASIdentifierChoice_asIdsOrRanges:
|
||||
child_as = ext->asnum->u.asIdsOrRanges;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ext->rdi != NULL) {
|
||||
switch (ext->rdi->type) {
|
||||
case ASIdentifierChoice_inherit:
|
||||
inherit_rdi = 1;
|
||||
break;
|
||||
case ASIdentifierChoice_asIdsOrRanges:
|
||||
child_rdi = ext->rdi->u.asIdsOrRanges;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now walk up the chain. Extensions must be in canonical form, no
|
||||
* cert may list resources that its parent doesn't list.
|
||||
*/
|
||||
for (i++; i < sk_X509_num(chain); i++) {
|
||||
x = sk_X509_value(chain, i);
|
||||
assert(x != NULL);
|
||||
if (x->rfc3779_asid == NULL) {
|
||||
if (child_as != NULL || child_rdi != NULL)
|
||||
validation_err(X509_V_ERR_UNNESTED_RESOURCE);
|
||||
continue;
|
||||
}
|
||||
if (!v3_asid_is_canonical(x->rfc3779_asid))
|
||||
validation_err(X509_V_ERR_INVALID_EXTENSION);
|
||||
if (x->rfc3779_asid->asnum == NULL && child_as != NULL) {
|
||||
validation_err(X509_V_ERR_UNNESTED_RESOURCE);
|
||||
child_as = NULL;
|
||||
inherit_as = 0;
|
||||
}
|
||||
if (x->rfc3779_asid->asnum != NULL &&
|
||||
x->rfc3779_asid->asnum->type == ASIdentifierChoice_asIdsOrRanges) {
|
||||
if (inherit_as ||
|
||||
asid_contains(x->rfc3779_asid->asnum->u.asIdsOrRanges, child_as)) {
|
||||
child_as = x->rfc3779_asid->asnum->u.asIdsOrRanges;
|
||||
inherit_as = 0;
|
||||
} else {
|
||||
validation_err(X509_V_ERR_UNNESTED_RESOURCE);
|
||||
}
|
||||
}
|
||||
if (x->rfc3779_asid->rdi == NULL && child_rdi != NULL) {
|
||||
validation_err(X509_V_ERR_UNNESTED_RESOURCE);
|
||||
child_rdi = NULL;
|
||||
inherit_rdi = 0;
|
||||
}
|
||||
if (x->rfc3779_asid->rdi != NULL &&
|
||||
x->rfc3779_asid->rdi->type == ASIdentifierChoice_asIdsOrRanges) {
|
||||
if (inherit_rdi ||
|
||||
asid_contains(x->rfc3779_asid->rdi->u.asIdsOrRanges, child_rdi)) {
|
||||
child_rdi = x->rfc3779_asid->rdi->u.asIdsOrRanges;
|
||||
inherit_rdi = 0;
|
||||
} else {
|
||||
validation_err(X509_V_ERR_UNNESTED_RESOURCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Trust anchor can't inherit.
|
||||
*/
|
||||
if (x->rfc3779_asid != NULL) {
|
||||
if (x->rfc3779_asid->asnum != NULL &&
|
||||
x->rfc3779_asid->asnum->type == ASIdentifierChoice_inherit)
|
||||
validation_err(X509_V_ERR_UNNESTED_RESOURCE);
|
||||
if (x->rfc3779_asid->rdi != NULL &&
|
||||
x->rfc3779_asid->rdi->type == ASIdentifierChoice_inherit)
|
||||
validation_err(X509_V_ERR_UNNESTED_RESOURCE);
|
||||
}
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef validation_err
|
||||
|
||||
/*
|
||||
* RFC 3779 3.3 path validation -- called from X509_verify_cert().
|
||||
*/
|
||||
int v3_asid_validate_path(X509_STORE_CTX *ctx)
|
||||
{
|
||||
return v3_asid_validate_path_internal(ctx, ctx->chain, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* RFC 3779 3.3 path validation of an extension.
|
||||
* Test whether chain covers extension.
|
||||
*/
|
||||
int v3_asid_validate_resource_set(STACK_OF(X509) *chain,
|
||||
ASIdentifiers *ext,
|
||||
int allow_inheritance)
|
||||
{
|
||||
if (ext == NULL)
|
||||
return 1;
|
||||
if (chain == NULL || sk_X509_num(chain) == 0)
|
||||
return 0;
|
||||
if (!allow_inheritance && v3_asid_inherits(ext))
|
||||
return 0;
|
||||
return v3_asid_validate_path_internal(NULL, chain, ext);
|
||||
}
|
||||
|
||||
#endif /* OPENSSL_RFC3779 */
|
|
@ -285,7 +285,12 @@ int X509_supported_extension(X509_EXTENSION *ex)
|
|||
NID_key_usage, /* 83 */
|
||||
NID_subject_alt_name, /* 85 */
|
||||
NID_basic_constraints, /* 87 */
|
||||
NID_certificate_policies, /* 89 */
|
||||
NID_ext_key_usage, /* 126 */
|
||||
#ifdef OPENSSL_RFC3779
|
||||
NID_sbgp_ipAddrBlock, /* 290 */
|
||||
NID_sbgp_autonomousSysNum, /* 291 */
|
||||
#endif
|
||||
NID_proxyCertInfo /* 661 */
|
||||
};
|
||||
|
||||
|
@ -410,6 +415,11 @@ static void x509v3_cache_extensions(X509 *x)
|
|||
}
|
||||
x->skid =X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL);
|
||||
x->akid =X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL);
|
||||
#ifdef OPENSSL_RFC3779
|
||||
x->rfc3779_addr =X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, NULL, NULL);
|
||||
x->rfc3779_asid =X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum,
|
||||
NULL, NULL);
|
||||
#endif
|
||||
for (i = 0; i < X509_get_ext_count(x); i++)
|
||||
{
|
||||
ex = X509_get_ext(x, i);
|
||||
|
|
|
@ -71,7 +71,6 @@ static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens);
|
|||
static void str_free(void *str);
|
||||
static int append_ia5(STACK **sk, ASN1_IA5STRING *email);
|
||||
|
||||
static int a2i_ipadd(unsigned char *ipout, const char *ipasc);
|
||||
static int ipv4_from_asc(unsigned char *v4, const char *in);
|
||||
static int ipv6_from_asc(unsigned char *v6, const char *in);
|
||||
static int ipv6_cb(const char *elem, int len, void *usr);
|
||||
|
@ -615,7 +614,7 @@ ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc)
|
|||
}
|
||||
|
||||
|
||||
static int a2i_ipadd(unsigned char *ipout, const char *ipasc)
|
||||
int a2i_ipadd(unsigned char *ipout, const char *ipasc)
|
||||
{
|
||||
/* If string contains a ':' assume IPv6 */
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@
|
|||
|
||||
static ERR_STRING_DATA X509V3_str_functs[]=
|
||||
{
|
||||
{ERR_FUNC(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE), "ASIDENTIFIERCHOICE_CANONIZE"},
|
||||
{ERR_FUNC(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL), "ASIDENTIFIERCHOICE_IS_CANONICAL"},
|
||||
{ERR_FUNC(X509V3_F_COPY_EMAIL), "COPY_EMAIL"},
|
||||
{ERR_FUNC(X509V3_F_COPY_ISSUER), "COPY_ISSUER"},
|
||||
{ERR_FUNC(X509V3_F_DO_DIRNAME), "DO_DIRNAME"},
|
||||
|
@ -99,6 +101,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
|
|||
{ERR_FUNC(X509V3_F_SXNET_ADD_ID_ULONG), "SXNET_add_id_ulong"},
|
||||
{ERR_FUNC(X509V3_F_SXNET_GET_ID_ASC), "SXNET_get_id_asc"},
|
||||
{ERR_FUNC(X509V3_F_SXNET_GET_ID_ULONG), "SXNET_get_id_ulong"},
|
||||
{ERR_FUNC(X509V3_F_V2I_ASIDENTIFIERS), "V2I_ASIDENTIFIERS"},
|
||||
{ERR_FUNC(X509V3_F_V2I_ASN1_BIT_STRING), "v2i_ASN1_BIT_STRING"},
|
||||
{ERR_FUNC(X509V3_F_V2I_AUTHORITY_INFO_ACCESS), "V2I_AUTHORITY_INFO_ACCESS"},
|
||||
{ERR_FUNC(X509V3_F_V2I_AUTHORITY_KEYID), "V2I_AUTHORITY_KEYID"},
|
||||
|
@ -107,11 +110,13 @@ static ERR_STRING_DATA X509V3_str_functs[]=
|
|||
{ERR_FUNC(X509V3_F_V2I_EXTENDED_KEY_USAGE), "V2I_EXTENDED_KEY_USAGE"},
|
||||
{ERR_FUNC(X509V3_F_V2I_GENERAL_NAMES), "v2i_GENERAL_NAMES"},
|
||||
{ERR_FUNC(X509V3_F_V2I_GENERAL_NAME_EX), "v2i_GENERAL_NAME_ex"},
|
||||
{ERR_FUNC(X509V3_F_V2I_IPADDRBLOCKS), "V2I_IPADDRBLOCKS"},
|
||||
{ERR_FUNC(X509V3_F_V2I_ISSUER_ALT), "V2I_ISSUER_ALT"},
|
||||
{ERR_FUNC(X509V3_F_V2I_NAME_CONSTRAINTS), "V2I_NAME_CONSTRAINTS"},
|
||||
{ERR_FUNC(X509V3_F_V2I_POLICY_CONSTRAINTS), "V2I_POLICY_CONSTRAINTS"},
|
||||
{ERR_FUNC(X509V3_F_V2I_POLICY_MAPPINGS), "V2I_POLICY_MAPPINGS"},
|
||||
{ERR_FUNC(X509V3_F_V2I_SUBJECT_ALT), "V2I_SUBJECT_ALT"},
|
||||
{ERR_FUNC(X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL), "V3_ADDR_VALIDATE_PATH_INTERNAL"},
|
||||
{ERR_FUNC(X509V3_F_V3_GENERIC_EXTENSION), "V3_GENERIC_EXTENSION"},
|
||||
{ERR_FUNC(X509V3_F_X509V3_ADD1_I2D), "X509V3_add1_i2d"},
|
||||
{ERR_FUNC(X509V3_F_X509V3_ADD_VALUE), "X509V3_add_value"},
|
||||
|
@ -149,8 +154,12 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
|
|||
{ERR_REASON(X509V3_R_ILLEGAL_EMPTY_EXTENSION),"illegal empty extension"},
|
||||
{ERR_REASON(X509V3_R_ILLEGAL_HEX_DIGIT) ,"illegal hex digit"},
|
||||
{ERR_REASON(X509V3_R_INCORRECT_POLICY_SYNTAX_TAG),"incorrect policy syntax tag"},
|
||||
{ERR_REASON(X509V3_R_INVALID_ASNUMBER) ,"invalid asnumber"},
|
||||
{ERR_REASON(X509V3_R_INVALID_ASRANGE) ,"invalid asrange"},
|
||||
{ERR_REASON(X509V3_R_INVALID_BOOLEAN_STRING),"invalid boolean string"},
|
||||
{ERR_REASON(X509V3_R_INVALID_EXTENSION_STRING),"invalid extension string"},
|
||||
{ERR_REASON(X509V3_R_INVALID_INHERITANCE),"invalid inheritance"},
|
||||
{ERR_REASON(X509V3_R_INVALID_IPADDRESS) ,"invalid ipaddress"},
|
||||
{ERR_REASON(X509V3_R_INVALID_NAME) ,"invalid name"},
|
||||
{ERR_REASON(X509V3_R_INVALID_NULL_ARGUMENT),"invalid null argument"},
|
||||
{ERR_REASON(X509V3_R_INVALID_NULL_NAME) ,"invalid null name"},
|
||||
|
@ -162,6 +171,7 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
|
|||
{ERR_REASON(X509V3_R_INVALID_POLICY_IDENTIFIER),"invalid policy identifier"},
|
||||
{ERR_REASON(X509V3_R_INVALID_PROXY_POLICY_SETTING),"invalid proxy policy setting"},
|
||||
{ERR_REASON(X509V3_R_INVALID_PURPOSE) ,"invalid purpose"},
|
||||
{ERR_REASON(X509V3_R_INVALID_SAFI) ,"invalid safi"},
|
||||
{ERR_REASON(X509V3_R_INVALID_SECTION) ,"invalid section"},
|
||||
{ERR_REASON(X509V3_R_INVALID_SYNTAX) ,"invalid syntax"},
|
||||
{ERR_REASON(X509V3_R_ISSUER_DECODE_ERROR),"issuer decode error"},
|
||||
|
|
|
@ -620,11 +620,161 @@ void X509_email_free(STACK *sk);
|
|||
|
||||
ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);
|
||||
ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);
|
||||
int a2i_ipadd(unsigned char *ipout, const char *ipasc);
|
||||
int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk,
|
||||
unsigned long chtype);
|
||||
|
||||
void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);
|
||||
|
||||
#ifdef OPENSSL_RFC3779
|
||||
|
||||
typedef struct ASRange_st {
|
||||
ASN1_INTEGER *min, *max;
|
||||
} ASRange;
|
||||
|
||||
#define ASIdOrRange_id 0
|
||||
#define ASIdOrRange_range 1
|
||||
|
||||
typedef struct ASIdOrRange_st {
|
||||
int type;
|
||||
union {
|
||||
ASN1_INTEGER *id;
|
||||
ASRange *range;
|
||||
} u;
|
||||
} ASIdOrRange;
|
||||
|
||||
typedef STACK_OF(ASIdOrRange) ASIdOrRanges;
|
||||
DECLARE_STACK_OF(ASIdOrRange)
|
||||
|
||||
#define ASIdentifierChoice_inherit 0
|
||||
#define ASIdentifierChoice_asIdsOrRanges 1
|
||||
|
||||
typedef struct ASIdentifierChoice_st {
|
||||
int type;
|
||||
union {
|
||||
ASN1_NULL *inherit;
|
||||
ASIdOrRanges *asIdsOrRanges;
|
||||
} u;
|
||||
} ASIdentifierChoice;
|
||||
|
||||
typedef struct ASIdentifiers_st {
|
||||
ASIdentifierChoice *asnum, *rdi;
|
||||
} ASIdentifiers;
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(ASRange)
|
||||
DECLARE_ASN1_FUNCTIONS(ASIdOrRange)
|
||||
DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)
|
||||
DECLARE_ASN1_FUNCTIONS(ASIdentifiers)
|
||||
|
||||
|
||||
typedef struct IPAddressRange_st {
|
||||
ASN1_BIT_STRING *min, *max;
|
||||
} IPAddressRange;
|
||||
|
||||
#define IPAddressOrRange_addressPrefix 0
|
||||
#define IPAddressOrRange_addressRange 1
|
||||
|
||||
typedef struct IPAddressOrRange_st {
|
||||
int type;
|
||||
union {
|
||||
ASN1_BIT_STRING *addressPrefix;
|
||||
IPAddressRange *addressRange;
|
||||
} u;
|
||||
} IPAddressOrRange;
|
||||
|
||||
typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;
|
||||
DECLARE_STACK_OF(IPAddressOrRange)
|
||||
|
||||
#define IPAddressChoice_inherit 0
|
||||
#define IPAddressChoice_addressesOrRanges 1
|
||||
|
||||
typedef struct IPAddressChoice_st {
|
||||
int type;
|
||||
union {
|
||||
ASN1_NULL *inherit;
|
||||
IPAddressOrRanges *addressesOrRanges;
|
||||
} u;
|
||||
} IPAddressChoice;
|
||||
|
||||
typedef struct IPAddressFamily_st {
|
||||
ASN1_OCTET_STRING *addressFamily;
|
||||
IPAddressChoice *ipAddressChoice;
|
||||
} IPAddressFamily;
|
||||
|
||||
typedef STACK_OF(IPAddressFamily) IPAddrBlocks;
|
||||
DECLARE_STACK_OF(IPAddressFamily)
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(IPAddressRange)
|
||||
DECLARE_ASN1_FUNCTIONS(IPAddressOrRange)
|
||||
DECLARE_ASN1_FUNCTIONS(IPAddressChoice)
|
||||
DECLARE_ASN1_FUNCTIONS(IPAddressFamily)
|
||||
|
||||
/*
|
||||
* API tag for elements of the ASIdentifer SEQUENCE.
|
||||
*/
|
||||
#define V3_ASID_ASNUM 0
|
||||
#define V3_ASID_RDI 1
|
||||
|
||||
/*
|
||||
* AFI values, assigned by IANA. It'd be nice to make the AFI
|
||||
* handling code totally generic, but there are too many little things
|
||||
* that would need to be defined for other address families for it to
|
||||
* be worth the trouble.
|
||||
*/
|
||||
#define IANA_AFI_IPV4 1
|
||||
#define IANA_AFI_IPV6 2
|
||||
|
||||
/*
|
||||
* Utilities to construct and extract values from RFC3779 extensions,
|
||||
* since some of the encodings (particularly for IP address prefixes
|
||||
* and ranges) are a bit tedious to work with directly.
|
||||
*/
|
||||
int v3_asid_add_inherit(ASIdentifiers *asid, int which);
|
||||
int v3_asid_add_id_or_range(ASIdentifiers *asid, int which,
|
||||
ASN1_INTEGER *min, ASN1_INTEGER *max);
|
||||
int v3_addr_add_inherit(IPAddrBlocks *addr,
|
||||
const unsigned afi, const unsigned *safi);
|
||||
int v3_addr_add_prefix(IPAddrBlocks *addr,
|
||||
const unsigned afi, const unsigned *safi,
|
||||
unsigned char *a, const int prefixlen);
|
||||
int v3_addr_add_range(IPAddrBlocks *addr,
|
||||
const unsigned afi, const unsigned *safi,
|
||||
unsigned char *min, unsigned char *max);
|
||||
unsigned v3_addr_get_afi(const IPAddressFamily *f);
|
||||
int v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,
|
||||
unsigned char *min, unsigned char *max,
|
||||
const int length);
|
||||
|
||||
/*
|
||||
* Canonical forms.
|
||||
*/
|
||||
int v3_asid_is_canonical(ASIdentifiers *asid);
|
||||
int v3_addr_is_canonical(IPAddrBlocks *addr);
|
||||
int v3_asid_canonize(ASIdentifiers *asid);
|
||||
int v3_addr_canonize(IPAddrBlocks *addr);
|
||||
|
||||
/*
|
||||
* Tests for inheritance and containment.
|
||||
*/
|
||||
int v3_asid_inherits(ASIdentifiers *asid);
|
||||
int v3_addr_inherits(IPAddrBlocks *addr);
|
||||
int v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b);
|
||||
int v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b);
|
||||
|
||||
/*
|
||||
* Check whether RFC 3779 extensions nest properly in chains.
|
||||
*/
|
||||
int v3_asid_validate_path(X509_STORE_CTX *);
|
||||
int v3_addr_validate_path(X509_STORE_CTX *);
|
||||
int v3_asid_validate_resource_set(STACK_OF(X509) *chain,
|
||||
ASIdentifiers *ext,
|
||||
int allow_inheritance);
|
||||
int v3_addr_validate_resource_set(STACK_OF(X509) *chain,
|
||||
IPAddrBlocks *ext,
|
||||
int allow_inheritance);
|
||||
|
||||
#endif /* OPENSSL_RFC3779 */
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
|
@ -634,6 +784,8 @@ void ERR_load_X509V3_strings(void);
|
|||
/* Error codes for the X509V3 functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 156
|
||||
#define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 157
|
||||
#define X509V3_F_COPY_EMAIL 122
|
||||
#define X509V3_F_COPY_ISSUER 123
|
||||
#define X509V3_F_DO_DIRNAME 144
|
||||
|
@ -663,6 +815,7 @@ void ERR_load_X509V3_strings(void);
|
|||
#define X509V3_F_SXNET_ADD_ID_ULONG 127
|
||||
#define X509V3_F_SXNET_GET_ID_ASC 128
|
||||
#define X509V3_F_SXNET_GET_ID_ULONG 129
|
||||
#define X509V3_F_V2I_ASIDENTIFIERS 158
|
||||
#define X509V3_F_V2I_ASN1_BIT_STRING 101
|
||||
#define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139
|
||||
#define X509V3_F_V2I_AUTHORITY_KEYID 119
|
||||
|
@ -671,11 +824,13 @@ void ERR_load_X509V3_strings(void);
|
|||
#define X509V3_F_V2I_EXTENDED_KEY_USAGE 103
|
||||
#define X509V3_F_V2I_GENERAL_NAMES 118
|
||||
#define X509V3_F_V2I_GENERAL_NAME_EX 117
|
||||
#define X509V3_F_V2I_IPADDRBLOCKS 159
|
||||
#define X509V3_F_V2I_ISSUER_ALT 153
|
||||
#define X509V3_F_V2I_NAME_CONSTRAINTS 147
|
||||
#define X509V3_F_V2I_POLICY_CONSTRAINTS 146
|
||||
#define X509V3_F_V2I_POLICY_MAPPINGS 145
|
||||
#define X509V3_F_V2I_SUBJECT_ALT 154
|
||||
#define X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL 160
|
||||
#define X509V3_F_V3_GENERIC_EXTENSION 116
|
||||
#define X509V3_F_X509V3_ADD1_I2D 140
|
||||
#define X509V3_F_X509V3_ADD_VALUE 105
|
||||
|
@ -710,8 +865,12 @@ void ERR_load_X509V3_strings(void);
|
|||
#define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151
|
||||
#define X509V3_R_ILLEGAL_HEX_DIGIT 113
|
||||
#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152
|
||||
#define X509V3_R_INVALID_ASNUMBER 160
|
||||
#define X509V3_R_INVALID_ASRANGE 161
|
||||
#define X509V3_R_INVALID_BOOLEAN_STRING 104
|
||||
#define X509V3_R_INVALID_EXTENSION_STRING 105
|
||||
#define X509V3_R_INVALID_INHERITANCE 162
|
||||
#define X509V3_R_INVALID_IPADDRESS 163
|
||||
#define X509V3_R_INVALID_NAME 106
|
||||
#define X509V3_R_INVALID_NULL_ARGUMENT 107
|
||||
#define X509V3_R_INVALID_NULL_NAME 108
|
||||
|
@ -723,6 +882,7 @@ void ERR_load_X509V3_strings(void);
|
|||
#define X509V3_R_INVALID_POLICY_IDENTIFIER 134
|
||||
#define X509V3_R_INVALID_PROXY_POLICY_SETTING 153
|
||||
#define X509V3_R_INVALID_PURPOSE 146
|
||||
#define X509V3_R_INVALID_SAFI 164
|
||||
#define X509V3_R_INVALID_SECTION 135
|
||||
#define X509V3_R_INVALID_SYNTAX 143
|
||||
#define X509V3_R_ISSUER_DECODE_ERROR 126
|
||||
|
|
Loading…
Reference in a new issue