third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h
Go to the documentation of this file.
1 /*
2  * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
3  * 2004.
4  */
5 /* ====================================================================
6  * Copyright (c) 2004 The OpenSSL Project. All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. All advertising materials mentioning features or use of this
21  * software must display the following acknowledgment:
22  * "This product includes software developed by the OpenSSL Project
23  * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24  *
25  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26  * endorse or promote products derived from this software without
27  * prior written permission. For written permission, please contact
28  * licensing@OpenSSL.org.
29  *
30  * 5. Products derived from this software may not be called "OpenSSL"
31  * nor may "OpenSSL" appear in their names without prior written
32  * permission of the OpenSSL Project.
33  *
34  * 6. Redistributions of any form whatsoever must retain the following
35  * acknowledgment:
36  * "This product includes software developed by the OpenSSL Project
37  * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38  *
39  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50  * OF THE POSSIBILITY OF SUCH DAMAGE.
51  * ====================================================================
52  *
53  * This product includes cryptographic software written by Eric Young
54  * (eay@cryptsoft.com). This product includes software written by Tim
55  * Hudson (tjh@cryptsoft.com).
56  *
57  */
58 
59 #ifndef OPENSSL_HEADER_X509V3_INTERNAL_H
60 #define OPENSSL_HEADER_X509V3_INTERNAL_H
61 
62 #include <openssl/base.h>
63 
64 #include <openssl/conf.h>
65 #include <openssl/stack.h>
66 #include <openssl/x509v3.h>
67 
68 #if defined(__cplusplus)
69 extern "C" {
70 #endif
71 
72 
73 // x509v3_bytes_to_hex encodes |len| bytes from |buffer| to hex and returns a
74 // newly-allocated NUL-terminated string containing the result, or NULL on
75 // allocation error.
76 //
77 // Note this function was historically named |hex_to_string| in OpenSSL, not
78 // |string_to_hex|.
79 char *x509v3_bytes_to_hex(const unsigned char *buffer, long len);
80 
81 // x509v3_hex_string_to_bytes decodes |str| in hex and returns a newly-allocated
82 // array containing the result, or NULL on error. On success, it sets |*len| to
83 // the length of the result. Colon separators between bytes in the input are
84 // allowed and ignored.
85 //
86 // Note this function was historically named |string_to_hex| in OpenSSL, not
87 // |hex_to_string|.
88 unsigned char *x509v3_hex_to_bytes(const char *str, long *len);
89 
90 // x509v3_name_cmp returns zero if |name| is equal to |cmp| or begins with |cmp|
91 // followed by '.'. Otherwise, it returns a non-zero number.
92 int x509v3_name_cmp(const char *name, const char *cmp);
93 
94 // x509v3_looks_like_dns_name returns one if |in| looks like a DNS name and zero
95 // otherwise.
96 OPENSSL_EXPORT int x509v3_looks_like_dns_name(const unsigned char *in,
97  size_t len);
98 
99 // x509v3_cache_extensions fills in a number of fields relating to X.509
100 // extensions in |x|. It returns one on success and zero if some extensions were
101 // invalid.
103 
104 // x509v3_a2i_ipadd decodes |ipasc| as an IPv4 or IPv6 address. IPv6 addresses
105 // use colon-separated syntax while IPv4 addresses use dotted decimal syntax. If
106 // it decodes an IPv4 address, it writes the result to the first four bytes of
107 // |ipout| and returns four. If it decodes an IPv6 address, it writes the result
108 // to all 16 bytes of |ipout| and returns 16. Otherwise, it returns zero.
109 int x509v3_a2i_ipadd(unsigned char ipout[16], const char *ipasc);
110 
111 // A |BIT_STRING_BITNAME| is used to contain a list of bit names.
112 typedef struct {
113  int bitnum;
114  const char *lname;
115  const char *sname;
117 
118 // x509V3_add_value_asn1_string appends a |CONF_VALUE| with the specified name
119 // and value to |*extlist|. if |*extlist| is NULL, it sets |*extlist| to a
120 // newly-allocated |STACK_OF(CONF_VALUE)| first. It returns one on success and
121 // zero on error.
122 int x509V3_add_value_asn1_string(const char *name, const ASN1_STRING *value,
123  STACK_OF(CONF_VALUE) **extlist);
124 
126 
128 
129 /* Internal structures */
130 
131 /*
132  * This structure and the field names correspond to the Policy 'node' of
133  * RFC 3280. NB this structure contains no pointers to parent or child data:
134  * X509_POLICY_NODE contains that. This means that the main policy data can
135  * be kept static and cached with the certificate.
136  */
137 
139  unsigned int flags;
140  /* Policy OID and qualifiers for this data */
142  STACK_OF(POLICYQUALINFO) *qualifier_set;
143  STACK_OF(ASN1_OBJECT) *expected_policy_set;
144 };
145 
146 /* X509_POLICY_DATA flags values */
147 
148 /*
149  * This flag indicates the structure has been mapped using a policy mapping
150  * extension. If policy mapping is not active its references get deleted.
151  */
152 
153 #define POLICY_DATA_FLAG_MAPPED 0x1
154 
155 /*
156  * This flag indicates the data doesn't correspond to a policy in Certificate
157  * Policies: it has been mapped to any policy.
158  */
159 
160 #define POLICY_DATA_FLAG_MAPPED_ANY 0x2
161 
162 /* AND with flags to see if any mapping has occurred */
163 
164 #define POLICY_DATA_FLAG_MAP_MASK 0x3
165 
166 /* qualifiers are shared and shouldn't be freed */
167 
168 #define POLICY_DATA_FLAG_SHARED_QUALIFIERS 0x4
169 
170 /* Parent node is an extra node and should be freed */
171 
172 #define POLICY_DATA_FLAG_EXTRA_NODE 0x8
173 
174 /* Corresponding CertificatePolicies is critical */
175 
176 #define POLICY_DATA_FLAG_CRITICAL 0x10
177 
178 /* This structure is cached with a certificate */
179 
181  /* anyPolicy data or NULL if no anyPolicy */
183  /* other policy data */
185  /* If InhibitAnyPolicy present this is its value or -1 if absent. */
186  long any_skip;
187  /*
188  * If policyConstraints and requireExplicitPolicy present this is its
189  * value or -1 if absent.
190  */
192  /*
193  * If policyConstraints and policyMapping present this is its value or -1
194  * if absent.
195  */
196  long map_skip;
197 };
198 
199 /*
200  * #define POLICY_CACHE_FLAG_CRITICAL POLICY_DATA_FLAG_CRITICAL
201  */
202 
203 /* This structure represents the relationship between nodes */
204 
206  /* node data this refers to */
208  /* Parent node */
210  /* Number of child nodes */
211  int nchild;
212 };
213 
215  /* Cert for this level */
217  /* nodes at this level */
218  STACK_OF(X509_POLICY_NODE) *nodes;
219  /* anyPolicy node */
221  /* Extra data */
222  /*
223  * STACK_OF(X509_POLICY_DATA) *extra_data;
224  */
225  unsigned int flags;
226 };
227 
229  /* This is the tree 'level' data */
231  int nlevel;
232  /*
233  * Extra policy data when additional nodes (not from the certificate) are
234  * required.
235  */
236  STACK_OF(X509_POLICY_DATA) *extra_data;
237  /* This is the authority constained policy set */
238  STACK_OF(X509_POLICY_NODE) *auth_policies;
239  STACK_OF(X509_POLICY_NODE) *user_policies;
240  unsigned int flags;
241 };
242 
243 /* Set if anyPolicy present in user policies */
244 #define POLICY_FLAG_ANY_POLICY 0x2
245 
246 /* Useful macros */
247 
248 #define node_data_critical(data) ((data)->flags & POLICY_DATA_FLAG_CRITICAL)
249 #define node_critical(node) node_data_critical((node)->data)
250 
251 /* Internal functions */
252 
254  int crit);
256 
258  const ASN1_OBJECT *id);
259 int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps);
260 
262 
263 void policy_cache_init(void);
264 
266 
268  const X509_POLICY_NODE *parent,
269  const ASN1_OBJECT *id);
270 
272  const ASN1_OBJECT *id);
273 
276  X509_POLICY_NODE *parent,
277  X509_POLICY_TREE *tree);
279 int policy_node_match(const X509_POLICY_LEVEL *lvl,
280  const X509_POLICY_NODE *node, const ASN1_OBJECT *oid);
281 
283 
284 
285 #if defined(__cplusplus)
286 } /* extern C */
287 #endif
288 
289 #endif /* OPENSSL_HEADER_X509V3_INTERNAL_H */
xds_interop_client.str
str
Definition: xds_interop_client.py:487
X509_POLICY_LEVEL_st
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:214
X509_POLICY_TREE_st::levels
X509_POLICY_LEVEL * levels
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:230
POLICYINFO_st
Definition: x509v3.h:284
X509_POLICY_CACHE_st::any_skip
long any_skip
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:186
BIT_STRING_BITNAME::lname
const char * lname
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:114
X509_POLICY_CACHE_st::anyPolicy
X509_POLICY_DATA * anyPolicy
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:182
X509_POLICY_LEVEL_st::flags
unsigned int flags
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:225
X509_POLICY_NODE_st
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:205
x509v3_bytes_to_hex
char * x509v3_bytes_to_hex(const unsigned char *buffer, long len)
Definition: v3_utl.c:476
x509v3.h
policy_cache_find_data
X509_POLICY_DATA * policy_cache_find_data(const X509_POLICY_CACHE *cache, const ASN1_OBJECT *id)
Definition: pcy_cache.c:260
setup.name
name
Definition: setup.py:542
policy_node_match
int policy_node_match(const X509_POLICY_LEVEL *lvl, const X509_POLICY_NODE *node, const ASN1_OBJECT *oid)
Definition: pcy_node.c:168
X509_POLICY_DATA_st::flags
unsigned int flags
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:139
BIT_STRING_BITNAME::bitnum
int bitnum
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:113
x509V3_add_value_asn1_string
int x509V3_add_value_asn1_string(const char *name, const ASN1_STRING *value, STACK_OF(CONF_VALUE) **extlist)
Definition: v3_utl.c:147
gen_build_yaml.struct
def struct(**kwargs)
Definition: test/core/end2end/gen_build_yaml.py:30
base.h
asn1_object_st
Definition: third_party/boringssl-with-bazel/src/crypto/asn1/internal.h:102
policy_data_free
void policy_data_free(X509_POLICY_DATA *data)
Definition: pcy_data.c:69
level_add_node
X509_POLICY_NODE * level_add_node(X509_POLICY_LEVEL *level, X509_POLICY_DATA *data, X509_POLICY_NODE *parent, X509_POLICY_TREE *tree)
Definition: pcy_node.c:110
X509_POLICY_TREE_st
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:228
policy_cache_set
const X509_POLICY_CACHE * policy_cache_set(X509 *x)
Definition: pcy_cache.c:240
X509_POLICY_NODE_st::data
const X509_POLICY_DATA * data
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:207
policy_cache_free
void policy_cache_free(X509_POLICY_CACHE *cache)
Definition: pcy_cache.c:221
in
const char * in
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:391
X509_POLICY_NODE_st::parent
X509_POLICY_NODE * parent
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:209
policy_data_new
X509_POLICY_DATA * policy_data_new(POLICYINFO *policy, const ASN1_OBJECT *id, int crit)
Definition: pcy_data.c:87
oid
uint8_t oid[9]
Definition: digest_extra.c:124
STACK_OF
STACK_OF(X509_POLICY_NODE) *policy_node_cmp_new(void)
Definition: pcy_lib.c:82
X509_POLICY_CACHE_st::explicit_skip
long explicit_skip
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:191
level_find_node
X509_POLICY_NODE * level_find_node(const X509_POLICY_LEVEL *level, const X509_POLICY_NODE *parent, const ASN1_OBJECT *id)
Definition: pcy_node.c:94
x509v3_a2i_ipadd
int x509v3_a2i_ipadd(unsigned char ipout[16], const char *ipasc)
Definition: v3_utl.c:1235
policy_cache_init
void policy_cache_init(void)
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
X509_POLICY_LEVEL_st::anyPolicy
X509_POLICY_NODE * anyPolicy
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:220
X509_POLICY_LEVEL_st::STACK_OF
STACK_OF(X509_POLICY_NODE) *nodes
X509_POLICY_LEVEL_st::cert
X509 * cert
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:216
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
x509v3_hex_to_bytes
unsigned char * x509v3_hex_to_bytes(const char *str, long *len)
Definition: v3_utl.c:499
x509v3_name_cmp
int x509v3_name_cmp(const char *name, const char *cmp)
Definition: v3_utl.c:559
buffer
char buffer[1024]
Definition: libuv/docs/code/idle-compute/main.c:8
conf.h
tests.google.protobuf.internal.message_test.cmp
cmp
Definition: bloaty/third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py:61
DEFINE_STACK_OF
#define DEFINE_STACK_OF(type)
Definition: stack.h:409
X509_POLICY_TREE_st::STACK_OF
STACK_OF(X509_POLICY_DATA) *extra_data
X509_POLICY_TREE_st::flags
unsigned int flags
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:240
POLICYQUALINFO_st
Definition: x509v3.h:273
X509_POLICY_DATA_st
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:138
value
const char * value
Definition: hpack_parser_table.cc:165
X509_POLICY_DATA_st::valid_policy
ASN1_OBJECT * valid_policy
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:141
x509v3_cache_extensions
int x509v3_cache_extensions(X509 *x)
Definition: v3_purp.c:415
policy_node_cmp_new
#define policy_node_cmp_new
Definition: boringssl_prefix_symbols.h:3351
x509_st
Definition: third_party/boringssl-with-bazel/src/crypto/x509/internal.h:139
policy_cache_set_mapping
int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps)
Definition: pcy_map.c:72
X509_POLICY_NODE_st::nchild
int nchild
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:211
tree_find_sk
X509_POLICY_NODE * tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk, const ASN1_OBJECT *id)
Definition: pcy_node.c:76
X509_POLICY_CACHE_st::map_skip
long map_skip
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:196
OPENSSL_EXPORT
#define OPENSSL_EXPORT
Definition: base.h:222
policy_node_free
void policy_node_free(X509_POLICY_NODE *node)
Definition: pcy_node.c:158
X509_POLICY_CACHE_st::STACK_OF
STACK_OF(X509_POLICY_DATA) *data
BIT_STRING_BITNAME::sname
const char * sname
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:115
client.level
level
Definition: examples/python/async_streaming/client.py:118
x509v3_looks_like_dns_name
OPENSSL_EXPORT int x509v3_looks_like_dns_name(const unsigned char *in, size_t len)
Definition: v3_utl.c:956
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
X509_POLICY_CACHE_st
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:180
BIT_STRING_BITNAME
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:112
X509_POLICY_TREE_st::nlevel
int nlevel
Definition: third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h:231
asn1_string_st
Definition: asn1.h:543
stack.h
conf_value_st
Definition: conf.h:82


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:07