sl@0: /* pcy_int.h */ sl@0: /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL sl@0: * project 2004. sl@0: */ sl@0: /* ==================================================================== sl@0: * Copyright (c) 2004 The OpenSSL Project. All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in sl@0: * the documentation and/or other materials provided with the sl@0: * distribution. sl@0: * sl@0: * 3. All advertising materials mentioning features or use of this sl@0: * software must display the following acknowledgment: sl@0: * "This product includes software developed by the OpenSSL Project sl@0: * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" sl@0: * sl@0: * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to sl@0: * endorse or promote products derived from this software without sl@0: * prior written permission. For written permission, please contact sl@0: * licensing@OpenSSL.org. sl@0: * sl@0: * 5. Products derived from this software may not be called "OpenSSL" sl@0: * nor may "OpenSSL" appear in their names without prior written sl@0: * permission of the OpenSSL Project. sl@0: * sl@0: * 6. Redistributions of any form whatsoever must retain the following sl@0: * acknowledgment: sl@0: * "This product includes software developed by the OpenSSL Project sl@0: * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY sl@0: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR sl@0: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR sl@0: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, sl@0: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT sl@0: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; sl@0: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, sl@0: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) sl@0: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED sl@0: * OF THE POSSIBILITY OF SUCH DAMAGE. sl@0: * ==================================================================== sl@0: * sl@0: * This product includes cryptographic software written by Eric Young sl@0: * (eay@cryptsoft.com). This product includes software written by Tim sl@0: * Hudson (tjh@cryptsoft.com). sl@0: * sl@0: */ sl@0: sl@0: DECLARE_STACK_OF(X509_POLICY_DATA) sl@0: DECLARE_STACK_OF(X509_POLICY_REF) sl@0: DECLARE_STACK_OF(X509_POLICY_NODE) sl@0: sl@0: typedef struct X509_POLICY_DATA_st X509_POLICY_DATA; sl@0: typedef struct X509_POLICY_REF_st X509_POLICY_REF; sl@0: sl@0: /* Internal structures */ sl@0: sl@0: /* This structure and the field names correspond to the Policy 'node' of sl@0: * RFC3280. NB this structure contains no pointers to parent or child sl@0: * data: X509_POLICY_NODE contains that. This means that the main policy data sl@0: * can be kept static and cached with the certificate. sl@0: */ sl@0: sl@0: struct X509_POLICY_DATA_st sl@0: { sl@0: unsigned int flags; sl@0: /* Policy OID and qualifiers for this data */ sl@0: ASN1_OBJECT *valid_policy; sl@0: STACK_OF(POLICYQUALINFO) *qualifier_set; sl@0: STACK_OF(ASN1_OBJECT) *expected_policy_set; sl@0: }; sl@0: sl@0: /* X509_POLICY_DATA flags values */ sl@0: sl@0: /* This flag indicates the structure has been mapped using a policy mapping sl@0: * extension. If policy mapping is not active its references get deleted. sl@0: */ sl@0: sl@0: #define POLICY_DATA_FLAG_MAPPED 0x1 sl@0: sl@0: /* This flag indicates the data doesn't correspond to a policy in Certificate sl@0: * Policies: it has been mapped to any policy. sl@0: */ sl@0: sl@0: #define POLICY_DATA_FLAG_MAPPED_ANY 0x2 sl@0: sl@0: /* AND with flags to see if any mapping has occurred */ sl@0: sl@0: #define POLICY_DATA_FLAG_MAP_MASK 0x3 sl@0: sl@0: /* qualifiers are shared and shouldn't be freed */ sl@0: sl@0: #define POLICY_DATA_FLAG_SHARED_QUALIFIERS 0x4 sl@0: sl@0: /* Parent node is an extra node and should be freed */ sl@0: sl@0: #define POLICY_DATA_FLAG_EXTRA_NODE 0x8 sl@0: sl@0: /* Corresponding CertificatePolicies is critical */ sl@0: sl@0: #define POLICY_DATA_FLAG_CRITICAL 0x10 sl@0: sl@0: /* This structure is an entry from a table of mapped policies which sl@0: * cross reference the policy it refers to. sl@0: */ sl@0: sl@0: struct X509_POLICY_REF_st sl@0: { sl@0: ASN1_OBJECT *subjectDomainPolicy; sl@0: const X509_POLICY_DATA *data; sl@0: }; sl@0: sl@0: /* This structure is cached with a certificate */ sl@0: sl@0: struct X509_POLICY_CACHE_st { sl@0: /* anyPolicy data or NULL if no anyPolicy */ sl@0: X509_POLICY_DATA *anyPolicy; sl@0: /* other policy data */ sl@0: STACK_OF(X509_POLICY_DATA) *data; sl@0: /* If policyMappings extension present a table of mapped policies */ sl@0: STACK_OF(X509_POLICY_REF) *maps; sl@0: /* If InhibitAnyPolicy present this is its value or -1 if absent. */ sl@0: long any_skip; sl@0: /* If policyConstraints and requireExplicitPolicy present this is its sl@0: * value or -1 if absent. sl@0: */ sl@0: long explicit_skip; sl@0: /* If policyConstraints and policyMapping present this is its sl@0: * value or -1 if absent. sl@0: */ sl@0: long map_skip; sl@0: }; sl@0: sl@0: /*#define POLICY_CACHE_FLAG_CRITICAL POLICY_DATA_FLAG_CRITICAL*/ sl@0: sl@0: /* This structure represents the relationship between nodes */ sl@0: sl@0: struct X509_POLICY_NODE_st sl@0: { sl@0: /* node data this refers to */ sl@0: const X509_POLICY_DATA *data; sl@0: /* Parent node */ sl@0: X509_POLICY_NODE *parent; sl@0: /* Number of child nodes */ sl@0: int nchild; sl@0: }; sl@0: sl@0: struct X509_POLICY_LEVEL_st sl@0: { sl@0: /* Cert for this level */ sl@0: X509 *cert; sl@0: /* nodes at this level */ sl@0: STACK_OF(X509_POLICY_NODE) *nodes; sl@0: /* anyPolicy node */ sl@0: X509_POLICY_NODE *anyPolicy; sl@0: /* Extra data */ sl@0: /*STACK_OF(X509_POLICY_DATA) *extra_data;*/ sl@0: unsigned int flags; sl@0: }; sl@0: sl@0: struct X509_POLICY_TREE_st sl@0: { sl@0: /* This is the tree 'level' data */ sl@0: X509_POLICY_LEVEL *levels; sl@0: int nlevel; sl@0: /* Extra policy data when additional nodes (not from the certificate) sl@0: * are required. sl@0: */ sl@0: STACK_OF(X509_POLICY_DATA) *extra_data; sl@0: /* This is the authority constained policy set */ sl@0: STACK_OF(X509_POLICY_NODE) *auth_policies; sl@0: STACK_OF(X509_POLICY_NODE) *user_policies; sl@0: unsigned int flags; sl@0: }; sl@0: sl@0: /* Set if anyPolicy present in user policies */ sl@0: #define POLICY_FLAG_ANY_POLICY 0x2 sl@0: sl@0: /* Useful macros */ sl@0: sl@0: #define node_data_critical(data) (data->flags & POLICY_DATA_FLAG_CRITICAL) sl@0: #define node_critical(node) node_data_critical(node->data) sl@0: sl@0: /* Internal functions */ sl@0: sl@0: IMPORT_C X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, ASN1_OBJECT *id, sl@0: int crit); sl@0: IMPORT_C void policy_data_free(X509_POLICY_DATA *data); sl@0: sl@0: IMPORT_C X509_POLICY_DATA *policy_cache_find_data(const X509_POLICY_CACHE *cache, sl@0: const ASN1_OBJECT *id); sl@0: IMPORT_C int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps); sl@0: sl@0: sl@0: IMPORT_C STACK_OF(X509_POLICY_NODE) *policy_node_cmp_new(void); sl@0: sl@0: void policy_cache_init(void); sl@0: sl@0: IMPORT_C void policy_cache_free(X509_POLICY_CACHE *cache); sl@0: sl@0: IMPORT_C X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level, sl@0: const ASN1_OBJECT *id); sl@0: sl@0: IMPORT_C X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk, sl@0: const ASN1_OBJECT *id); sl@0: sl@0: IMPORT_C X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level, sl@0: X509_POLICY_DATA *data, sl@0: X509_POLICY_NODE *parent, sl@0: X509_POLICY_TREE *tree); sl@0: IMPORT_C void policy_node_free(X509_POLICY_NODE *node); sl@0: sl@0: IMPORT_C const X509_POLICY_CACHE *policy_cache_set(X509 *x);