1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ssl/libcrypto/src/crypto/x509v3/pcy_lib.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,167 @@
1.4 +/* pcy_lib.c */
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 +
1.63 +#include "cryptlib.h"
1.64 +#include <openssl/x509.h>
1.65 +#include <openssl/x509v3.h>
1.66 +
1.67 +#include "pcy_int.h"
1.68 +
1.69 +/* accessor functions */
1.70 +
1.71 +/* X509_POLICY_TREE stuff */
1.72 +
1.73 +EXPORT_C int X509_policy_tree_level_count(const X509_POLICY_TREE *tree)
1.74 + {
1.75 + if (!tree)
1.76 + return 0;
1.77 + return tree->nlevel;
1.78 + }
1.79 +
1.80 +EXPORT_C X509_POLICY_LEVEL *
1.81 + X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i)
1.82 + {
1.83 + if (!tree || (i < 0) || (i >= tree->nlevel))
1.84 + return NULL;
1.85 + return tree->levels + i;
1.86 + }
1.87 +
1.88 +EXPORT_C STACK_OF(X509_POLICY_NODE) *
1.89 + X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree)
1.90 + {
1.91 + if (!tree)
1.92 + return NULL;
1.93 + return tree->auth_policies;
1.94 + }
1.95 +
1.96 +EXPORT_C STACK_OF(X509_POLICY_NODE) *
1.97 + X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree)
1.98 + {
1.99 + if (!tree)
1.100 + return NULL;
1.101 + if (tree->flags & POLICY_FLAG_ANY_POLICY)
1.102 + return tree->auth_policies;
1.103 + else
1.104 + return tree->user_policies;
1.105 + }
1.106 +
1.107 +/* X509_POLICY_LEVEL stuff */
1.108 +
1.109 +EXPORT_C int X509_policy_level_node_count(X509_POLICY_LEVEL *level)
1.110 + {
1.111 + int n;
1.112 + if (!level)
1.113 + return 0;
1.114 + if (level->anyPolicy)
1.115 + n = 1;
1.116 + else
1.117 + n = 0;
1.118 + if (level->nodes)
1.119 + n += sk_X509_POLICY_NODE_num(level->nodes);
1.120 + return n;
1.121 + }
1.122 +
1.123 +EXPORT_C X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i)
1.124 + {
1.125 + if (!level)
1.126 + return NULL;
1.127 + if (level->anyPolicy)
1.128 + {
1.129 + if (i == 0)
1.130 + return level->anyPolicy;
1.131 + i--;
1.132 + }
1.133 + return sk_X509_POLICY_NODE_value(level->nodes, i);
1.134 + }
1.135 +
1.136 +/* X509_POLICY_NODE stuff */
1.137 +
1.138 +EXPORT_C const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node)
1.139 + {
1.140 + if (!node)
1.141 + return NULL;
1.142 + return node->data->valid_policy;
1.143 + }
1.144 +
1.145 +#if 0
1.146 +EXPORT_C int X509_policy_node_get_critical(const X509_POLICY_NODE *node)
1.147 + {
1.148 + if (node_critical(node))
1.149 + return 1;
1.150 + return 0;
1.151 + }
1.152 +#endif
1.153 +
1.154 +EXPORT_C STACK_OF(POLICYQUALINFO) *
1.155 + X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node)
1.156 + {
1.157 + if (!node)
1.158 + return NULL;
1.159 + return node->data->qualifier_set;
1.160 + }
1.161 +
1.162 +EXPORT_C const X509_POLICY_NODE *
1.163 + X509_policy_node_get0_parent(const X509_POLICY_NODE *node)
1.164 + {
1.165 + if (!node)
1.166 + return NULL;
1.167 + return node->parent;
1.168 + }
1.169 +
1.170 +