1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ssl/libcrypto/src/crypto/x509v3/pcy_int.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,223 @@
1.4 +/* pcy_int.h */
1.5 +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
1.6 + * project 2004.
1.7 + */
1.8 +/* ====================================================================
1.9 + * Copyright (c) 2004 The OpenSSL Project. All rights reserved.
1.10 + *
1.11 + * Redistribution and use in source and binary forms, with or without
1.12 + * modification, are permitted provided that the following conditions
1.13 + * are met:
1.14 + *
1.15 + * 1. Redistributions of source code must retain the above copyright
1.16 + * notice, this list of conditions and the following disclaimer.
1.17 + *
1.18 + * 2. Redistributions in binary form must reproduce the above copyright
1.19 + * notice, this list of conditions and the following disclaimer in
1.20 + * the documentation and/or other materials provided with the
1.21 + * distribution.
1.22 + *
1.23 + * 3. All advertising materials mentioning features or use of this
1.24 + * software must display the following acknowledgment:
1.25 + * "This product includes software developed by the OpenSSL Project
1.26 + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
1.27 + *
1.28 + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
1.29 + * endorse or promote products derived from this software without
1.30 + * prior written permission. For written permission, please contact
1.31 + * licensing@OpenSSL.org.
1.32 + *
1.33 + * 5. Products derived from this software may not be called "OpenSSL"
1.34 + * nor may "OpenSSL" appear in their names without prior written
1.35 + * permission of the OpenSSL Project.
1.36 + *
1.37 + * 6. Redistributions of any form whatsoever must retain the following
1.38 + * acknowledgment:
1.39 + * "This product includes software developed by the OpenSSL Project
1.40 + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
1.41 + *
1.42 + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
1.43 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.44 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1.45 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
1.46 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1.47 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1.48 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1.49 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.50 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1.51 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1.52 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
1.53 + * OF THE POSSIBILITY OF SUCH DAMAGE.
1.54 + * ====================================================================
1.55 + *
1.56 + * This product includes cryptographic software written by Eric Young
1.57 + * (eay@cryptsoft.com). This product includes software written by Tim
1.58 + * Hudson (tjh@cryptsoft.com).
1.59 + *
1.60 + */
1.61 +
1.62 +DECLARE_STACK_OF(X509_POLICY_DATA)
1.63 +DECLARE_STACK_OF(X509_POLICY_REF)
1.64 +DECLARE_STACK_OF(X509_POLICY_NODE)
1.65 +
1.66 +typedef struct X509_POLICY_DATA_st X509_POLICY_DATA;
1.67 +typedef struct X509_POLICY_REF_st X509_POLICY_REF;
1.68 +
1.69 +/* Internal structures */
1.70 +
1.71 +/* This structure and the field names correspond to the Policy 'node' of
1.72 + * RFC3280. NB this structure contains no pointers to parent or child
1.73 + * data: X509_POLICY_NODE contains that. This means that the main policy data
1.74 + * can be kept static and cached with the certificate.
1.75 + */
1.76 +
1.77 +struct X509_POLICY_DATA_st
1.78 + {
1.79 + unsigned int flags;
1.80 + /* Policy OID and qualifiers for this data */
1.81 + ASN1_OBJECT *valid_policy;
1.82 + STACK_OF(POLICYQUALINFO) *qualifier_set;
1.83 + STACK_OF(ASN1_OBJECT) *expected_policy_set;
1.84 + };
1.85 +
1.86 +/* X509_POLICY_DATA flags values */
1.87 +
1.88 +/* This flag indicates the structure has been mapped using a policy mapping
1.89 + * extension. If policy mapping is not active its references get deleted.
1.90 + */
1.91 +
1.92 +#define POLICY_DATA_FLAG_MAPPED 0x1
1.93 +
1.94 +/* This flag indicates the data doesn't correspond to a policy in Certificate
1.95 + * Policies: it has been mapped to any policy.
1.96 + */
1.97 +
1.98 +#define POLICY_DATA_FLAG_MAPPED_ANY 0x2
1.99 +
1.100 +/* AND with flags to see if any mapping has occurred */
1.101 +
1.102 +#define POLICY_DATA_FLAG_MAP_MASK 0x3
1.103 +
1.104 +/* qualifiers are shared and shouldn't be freed */
1.105 +
1.106 +#define POLICY_DATA_FLAG_SHARED_QUALIFIERS 0x4
1.107 +
1.108 +/* Parent node is an extra node and should be freed */
1.109 +
1.110 +#define POLICY_DATA_FLAG_EXTRA_NODE 0x8
1.111 +
1.112 +/* Corresponding CertificatePolicies is critical */
1.113 +
1.114 +#define POLICY_DATA_FLAG_CRITICAL 0x10
1.115 +
1.116 +/* This structure is an entry from a table of mapped policies which
1.117 + * cross reference the policy it refers to.
1.118 + */
1.119 +
1.120 +struct X509_POLICY_REF_st
1.121 + {
1.122 + ASN1_OBJECT *subjectDomainPolicy;
1.123 + const X509_POLICY_DATA *data;
1.124 + };
1.125 +
1.126 +/* This structure is cached with a certificate */
1.127 +
1.128 +struct X509_POLICY_CACHE_st {
1.129 + /* anyPolicy data or NULL if no anyPolicy */
1.130 + X509_POLICY_DATA *anyPolicy;
1.131 + /* other policy data */
1.132 + STACK_OF(X509_POLICY_DATA) *data;
1.133 + /* If policyMappings extension present a table of mapped policies */
1.134 + STACK_OF(X509_POLICY_REF) *maps;
1.135 + /* If InhibitAnyPolicy present this is its value or -1 if absent. */
1.136 + long any_skip;
1.137 + /* If policyConstraints and requireExplicitPolicy present this is its
1.138 + * value or -1 if absent.
1.139 + */
1.140 + long explicit_skip;
1.141 + /* If policyConstraints and policyMapping present this is its
1.142 + * value or -1 if absent.
1.143 + */
1.144 + long map_skip;
1.145 + };
1.146 +
1.147 +/*#define POLICY_CACHE_FLAG_CRITICAL POLICY_DATA_FLAG_CRITICAL*/
1.148 +
1.149 +/* This structure represents the relationship between nodes */
1.150 +
1.151 +struct X509_POLICY_NODE_st
1.152 + {
1.153 + /* node data this refers to */
1.154 + const X509_POLICY_DATA *data;
1.155 + /* Parent node */
1.156 + X509_POLICY_NODE *parent;
1.157 + /* Number of child nodes */
1.158 + int nchild;
1.159 + };
1.160 +
1.161 +struct X509_POLICY_LEVEL_st
1.162 + {
1.163 + /* Cert for this level */
1.164 + X509 *cert;
1.165 + /* nodes at this level */
1.166 + STACK_OF(X509_POLICY_NODE) *nodes;
1.167 + /* anyPolicy node */
1.168 + X509_POLICY_NODE *anyPolicy;
1.169 + /* Extra data */
1.170 + /*STACK_OF(X509_POLICY_DATA) *extra_data;*/
1.171 + unsigned int flags;
1.172 + };
1.173 +
1.174 +struct X509_POLICY_TREE_st
1.175 + {
1.176 + /* This is the tree 'level' data */
1.177 + X509_POLICY_LEVEL *levels;
1.178 + int nlevel;
1.179 + /* Extra policy data when additional nodes (not from the certificate)
1.180 + * are required.
1.181 + */
1.182 + STACK_OF(X509_POLICY_DATA) *extra_data;
1.183 + /* This is the authority constained policy set */
1.184 + STACK_OF(X509_POLICY_NODE) *auth_policies;
1.185 + STACK_OF(X509_POLICY_NODE) *user_policies;
1.186 + unsigned int flags;
1.187 + };
1.188 +
1.189 +/* Set if anyPolicy present in user policies */
1.190 +#define POLICY_FLAG_ANY_POLICY 0x2
1.191 +
1.192 +/* Useful macros */
1.193 +
1.194 +#define node_data_critical(data) (data->flags & POLICY_DATA_FLAG_CRITICAL)
1.195 +#define node_critical(node) node_data_critical(node->data)
1.196 +
1.197 +/* Internal functions */
1.198 +
1.199 +IMPORT_C X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, ASN1_OBJECT *id,
1.200 + int crit);
1.201 +IMPORT_C void policy_data_free(X509_POLICY_DATA *data);
1.202 +
1.203 +IMPORT_C X509_POLICY_DATA *policy_cache_find_data(const X509_POLICY_CACHE *cache,
1.204 + const ASN1_OBJECT *id);
1.205 +IMPORT_C int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps);
1.206 +
1.207 +
1.208 +IMPORT_C STACK_OF(X509_POLICY_NODE) *policy_node_cmp_new(void);
1.209 +
1.210 +void policy_cache_init(void);
1.211 +
1.212 +IMPORT_C void policy_cache_free(X509_POLICY_CACHE *cache);
1.213 +
1.214 +IMPORT_C X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level,
1.215 + const ASN1_OBJECT *id);
1.216 +
1.217 +IMPORT_C X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk,
1.218 + const ASN1_OBJECT *id);
1.219 +
1.220 +IMPORT_C X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
1.221 + X509_POLICY_DATA *data,
1.222 + X509_POLICY_NODE *parent,
1.223 + X509_POLICY_TREE *tree);
1.224 +IMPORT_C void policy_node_free(X509_POLICY_NODE *node);
1.225 +
1.226 +IMPORT_C const X509_POLICY_CACHE *policy_cache_set(X509 *x);