]>
Commit | Line | Data |
---|---|---|
0f113f3e | 1 | /* |
21dcbebc | 2 | * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. |
9aeaf1b4 | 3 | * |
21dcbebc RS |
4 | * Licensed under the OpenSSL license (the "License"). You may not use |
5 | * this file except in compliance with the License. You can obtain a copy | |
6 | * in the file LICENSE in the source distribution or at | |
7 | * https://www.openssl.org/source/license.html | |
58964a49 | 8 | */ |
21dcbebc | 9 | |
9aeaf1b4 | 10 | #ifndef HEADER_X509V3_H |
0f113f3e | 11 | # define HEADER_X509V3_H |
9aeaf1b4 | 12 | |
0f113f3e MC |
13 | # include <openssl/bio.h> |
14 | # include <openssl/x509.h> | |
15 | # include <openssl/conf.h> | |
9aeaf1b4 | 16 | |
82271cee RL |
17 | #ifdef __cplusplus |
18 | extern "C" { | |
19 | #endif | |
20 | ||
0f113f3e | 21 | # ifdef OPENSSL_SYS_WIN32 |
83e4e03e | 22 | /* Under Win32 these are defined in wincrypt.h */ |
0f113f3e | 23 | # undef X509_NAME |
0f113f3e MC |
24 | # undef X509_EXTENSIONS |
25 | # endif | |
83e4e03e | 26 | |
9aeaf1b4 DSH |
27 | /* Forward reference */ |
28 | struct v3_ext_method; | |
29 | struct v3_ext_ctx; | |
30 | ||
31 | /* Useful typedefs */ | |
32 | ||
0f113f3e MC |
33 | typedef void *(*X509V3_EXT_NEW)(void); |
34 | typedef void (*X509V3_EXT_FREE) (void *); | |
35 | typedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long); | |
36 | typedef int (*X509V3_EXT_I2D) (void *, unsigned char **); | |
babb3798 | 37 | typedef STACK_OF(CONF_VALUE) * |
0f113f3e MC |
38 | (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext, |
39 | STACK_OF(CONF_VALUE) *extlist); | |
40 | typedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method, | |
41 | struct v3_ext_ctx *ctx, | |
42 | STACK_OF(CONF_VALUE) *values); | |
43 | typedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method, | |
44 | void *ext); | |
45 | typedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method, | |
46 | struct v3_ext_ctx *ctx, const char *str); | |
47 | typedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext, | |
48 | BIO *out, int indent); | |
49 | typedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method, | |
50 | struct v3_ext_ctx *ctx, const char *str); | |
9aeaf1b4 DSH |
51 | |
52 | /* V3 extension structure */ | |
53 | ||
54 | struct v3_ext_method { | |
0f113f3e MC |
55 | int ext_nid; |
56 | int ext_flags; | |
2aff7727 | 57 | /* If this is set the following four fields are ignored */ |
0f113f3e | 58 | ASN1_ITEM_EXP *it; |
2aff7727 | 59 | /* Old style ASN1 calls */ |
0f113f3e MC |
60 | X509V3_EXT_NEW ext_new; |
61 | X509V3_EXT_FREE ext_free; | |
62 | X509V3_EXT_D2I d2i; | |
63 | X509V3_EXT_I2D i2d; | |
9aeaf1b4 | 64 | /* The following pair is used for string extensions */ |
0f113f3e MC |
65 | X509V3_EXT_I2S i2s; |
66 | X509V3_EXT_S2I s2i; | |
9aeaf1b4 | 67 | /* The following pair is used for multi-valued extensions */ |
0f113f3e MC |
68 | X509V3_EXT_I2V i2v; |
69 | X509V3_EXT_V2I v2i; | |
79a474e8 | 70 | /* The following are used for raw extensions */ |
0f113f3e MC |
71 | X509V3_EXT_I2R i2r; |
72 | X509V3_EXT_R2I r2i; | |
73 | void *usr_data; /* Any extension specific data */ | |
9aeaf1b4 DSH |
74 | }; |
75 | ||
1d48dd00 | 76 | typedef struct X509V3_CONF_METHOD_st { |
0f113f3e MC |
77 | char *(*get_string) (void *db, char *section, char *value); |
78 | STACK_OF(CONF_VALUE) *(*get_section) (void *db, char *section); | |
79 | void (*free_string) (void *db, char *string); | |
80 | void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section); | |
1d48dd00 | 81 | } X509V3_CONF_METHOD; |
175b0942 | 82 | |
9aeaf1b4 | 83 | /* Context specific info */ |
f317aa4c | 84 | struct v3_ext_ctx { |
0f113f3e MC |
85 | # define CTX_TEST 0x1 |
86 | # define X509V3_CTX_REPLACE 0x2 | |
87 | int flags; | |
88 | X509 *issuer_cert; | |
89 | X509 *subject_cert; | |
90 | X509_REQ *subject_req; | |
91 | X509_CRL *crl; | |
92 | X509V3_CONF_METHOD *db_meth; | |
93 | void *db; | |
9aeaf1b4 DSH |
94 | /* Maybe more here */ |
95 | }; | |
96 | ||
97 | typedef struct v3_ext_method X509V3_EXT_METHOD; | |
9aeaf1b4 | 98 | |
85885715 | 99 | DEFINE_STACK_OF(X509V3_EXT_METHOD) |
0d3b0afe | 100 | |
9aeaf1b4 | 101 | /* ext_flags values */ |
0f113f3e MC |
102 | # define X509V3_EXT_DYNAMIC 0x1 |
103 | # define X509V3_EXT_CTX_DEP 0x2 | |
104 | # define X509V3_EXT_MULTILINE 0x4 | |
9aeaf1b4 | 105 | |
c74f1eb9 DSH |
106 | typedef BIT_STRING_BITNAME ENUMERATED_NAMES; |
107 | ||
0490a86d | 108 | typedef struct BASIC_CONSTRAINTS_st { |
0f113f3e MC |
109 | int ca; |
110 | ASN1_INTEGER *pathlen; | |
9aeaf1b4 DSH |
111 | } BASIC_CONSTRAINTS; |
112 | ||
0490a86d | 113 | typedef struct PKEY_USAGE_PERIOD_st { |
0f113f3e MC |
114 | ASN1_GENERALIZEDTIME *notBefore; |
115 | ASN1_GENERALIZEDTIME *notAfter; | |
0be9747b DSH |
116 | } PKEY_USAGE_PERIOD; |
117 | ||
a716d727 | 118 | typedef struct otherName_st { |
0f113f3e MC |
119 | ASN1_OBJECT *type_id; |
120 | ASN1_TYPE *value; | |
a716d727 DSH |
121 | } OTHERNAME; |
122 | ||
9d6b1ce6 | 123 | typedef struct EDIPartyName_st { |
0f113f3e MC |
124 | ASN1_STRING *nameAssigner; |
125 | ASN1_STRING *partyName; | |
9d6b1ce6 DSH |
126 | } EDIPARTYNAME; |
127 | ||
0490a86d | 128 | typedef struct GENERAL_NAME_st { |
0f113f3e MC |
129 | # define GEN_OTHERNAME 0 |
130 | # define GEN_EMAIL 1 | |
131 | # define GEN_DNS 2 | |
132 | # define GEN_X400 3 | |
133 | # define GEN_DIRNAME 4 | |
134 | # define GEN_EDIPARTY 5 | |
135 | # define GEN_URI 6 | |
136 | # define GEN_IPADD 7 | |
137 | # define GEN_RID 8 | |
138 | int type; | |
139 | union { | |
140 | char *ptr; | |
141 | OTHERNAME *otherName; /* otherName */ | |
142 | ASN1_IA5STRING *rfc822Name; | |
143 | ASN1_IA5STRING *dNSName; | |
144 | ASN1_TYPE *x400Address; | |
145 | X509_NAME *directoryName; | |
146 | EDIPARTYNAME *ediPartyName; | |
147 | ASN1_IA5STRING *uniformResourceIdentifier; | |
148 | ASN1_OCTET_STRING *iPAddress; | |
149 | ASN1_OBJECT *registeredID; | |
150 | /* Old names */ | |
151 | ASN1_OCTET_STRING *ip; /* iPAddress */ | |
152 | X509_NAME *dirn; /* dirn */ | |
153 | ASN1_IA5STRING *ia5; /* rfc822Name, dNSName, | |
154 | * uniformResourceIdentifier */ | |
155 | ASN1_OBJECT *rid; /* registeredID */ | |
156 | ASN1_TYPE *other; /* x400Address */ | |
157 | } d; | |
142fcca8 DSH |
158 | } GENERAL_NAME; |
159 | ||
6d3724d3 | 160 | typedef struct ACCESS_DESCRIPTION_st { |
0f113f3e MC |
161 | ASN1_OBJECT *method; |
162 | GENERAL_NAME *location; | |
6d3724d3 DSH |
163 | } ACCESS_DESCRIPTION; |
164 | ||
9d6b1ce6 DSH |
165 | typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; |
166 | ||
167 | typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; | |
168 | ||
ba67253d RS |
169 | typedef STACK_OF(ASN1_INTEGER) TLS_FEATURE; |
170 | ||
85885715 | 171 | DEFINE_STACK_OF(GENERAL_NAME) |
4a640fb6 | 172 | typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; |
85885715 | 173 | DEFINE_STACK_OF(GENERAL_NAMES) |
f5fedc04 | 174 | |
85885715 | 175 | DEFINE_STACK_OF(ACCESS_DESCRIPTION) |
6d3724d3 | 176 | |
d943e372 | 177 | typedef struct DIST_POINT_NAME_st { |
0f113f3e MC |
178 | int type; |
179 | union { | |
180 | GENERAL_NAMES *fullname; | |
181 | STACK_OF(X509_NAME_ENTRY) *relativename; | |
182 | } name; | |
3e727a3b | 183 | /* If relativename then this contains the full distribution point name */ |
0f113f3e | 184 | X509_NAME *dpname; |
d943e372 | 185 | } DIST_POINT_NAME; |
4b96839f | 186 | /* All existing reasons */ |
0f113f3e MC |
187 | # define CRLDP_ALL_REASONS 0x807f |
188 | ||
189 | # define CRL_REASON_NONE -1 | |
190 | # define CRL_REASON_UNSPECIFIED 0 | |
191 | # define CRL_REASON_KEY_COMPROMISE 1 | |
192 | # define CRL_REASON_CA_COMPROMISE 2 | |
193 | # define CRL_REASON_AFFILIATION_CHANGED 3 | |
194 | # define CRL_REASON_SUPERSEDED 4 | |
195 | # define CRL_REASON_CESSATION_OF_OPERATION 5 | |
196 | # define CRL_REASON_CERTIFICATE_HOLD 6 | |
197 | # define CRL_REASON_REMOVE_FROM_CRL 8 | |
198 | # define CRL_REASON_PRIVILEGE_WITHDRAWN 9 | |
199 | # define CRL_REASON_AA_COMPROMISE 10 | |
d43c4497 | 200 | |
edc54021 | 201 | struct DIST_POINT_st { |
0f113f3e MC |
202 | DIST_POINT_NAME *distpoint; |
203 | ASN1_BIT_STRING *reasons; | |
204 | GENERAL_NAMES *CRLissuer; | |
205 | int dp_reasons; | |
edc54021 | 206 | }; |
d943e372 | 207 | |
9d6b1ce6 DSH |
208 | typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; |
209 | ||
85885715 | 210 | DEFINE_STACK_OF(DIST_POINT) |
d943e372 | 211 | |
edc54021 | 212 | struct AUTHORITY_KEYID_st { |
0f113f3e MC |
213 | ASN1_OCTET_STRING *keyid; |
214 | GENERAL_NAMES *issuer; | |
215 | ASN1_INTEGER *serial; | |
edc54021 | 216 | }; |
f5fedc04 | 217 | |
785cdf20 | 218 | /* Strong extranet structures */ |
142fcca8 | 219 | |
0490a86d | 220 | typedef struct SXNET_ID_st { |
0f113f3e MC |
221 | ASN1_INTEGER *zone; |
222 | ASN1_OCTET_STRING *user; | |
785cdf20 | 223 | } SXNETID; |
142fcca8 | 224 | |
85885715 | 225 | DEFINE_STACK_OF(SXNETID) |
cfdcfede BL |
226 | |
227 | typedef struct SXNET_st { | |
0f113f3e MC |
228 | ASN1_INTEGER *version; |
229 | STACK_OF(SXNETID) *ids; | |
cfdcfede BL |
230 | } SXNET; |
231 | ||
c83e523d | 232 | typedef struct NOTICEREF_st { |
0f113f3e MC |
233 | ASN1_STRING *organization; |
234 | STACK_OF(ASN1_INTEGER) *noticenos; | |
c83e523d DSH |
235 | } NOTICEREF; |
236 | ||
237 | typedef struct USERNOTICE_st { | |
0f113f3e MC |
238 | NOTICEREF *noticeref; |
239 | ASN1_STRING *exptext; | |
c83e523d DSH |
240 | } USERNOTICE; |
241 | ||
242 | typedef struct POLICYQUALINFO_st { | |
0f113f3e MC |
243 | ASN1_OBJECT *pqualid; |
244 | union { | |
245 | ASN1_IA5STRING *cpsuri; | |
246 | USERNOTICE *usernotice; | |
247 | ASN1_TYPE *other; | |
248 | } d; | |
c83e523d DSH |
249 | } POLICYQUALINFO; |
250 | ||
85885715 | 251 | DEFINE_STACK_OF(POLICYQUALINFO) |
c83e523d DSH |
252 | |
253 | typedef struct POLICYINFO_st { | |
0f113f3e MC |
254 | ASN1_OBJECT *policyid; |
255 | STACK_OF(POLICYQUALINFO) *qualifiers; | |
c83e523d DSH |
256 | } POLICYINFO; |
257 | ||
9d6b1ce6 DSH |
258 | typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; |
259 | ||
85885715 | 260 | DEFINE_STACK_OF(POLICYINFO) |
c83e523d | 261 | |
a1d12dae | 262 | typedef struct POLICY_MAPPING_st { |
0f113f3e MC |
263 | ASN1_OBJECT *issuerDomainPolicy; |
264 | ASN1_OBJECT *subjectDomainPolicy; | |
a1d12dae DSH |
265 | } POLICY_MAPPING; |
266 | ||
85885715 | 267 | DEFINE_STACK_OF(POLICY_MAPPING) |
a1d12dae DSH |
268 | |
269 | typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; | |
270 | ||
520b76ff | 271 | typedef struct GENERAL_SUBTREE_st { |
0f113f3e MC |
272 | GENERAL_NAME *base; |
273 | ASN1_INTEGER *minimum; | |
274 | ASN1_INTEGER *maximum; | |
520b76ff DSH |
275 | } GENERAL_SUBTREE; |
276 | ||
85885715 | 277 | DEFINE_STACK_OF(GENERAL_SUBTREE) |
520b76ff | 278 | |
e9746e03 | 279 | struct NAME_CONSTRAINTS_st { |
0f113f3e MC |
280 | STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; |
281 | STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; | |
e9746e03 | 282 | }; |
520b76ff | 283 | |
f80153e2 | 284 | typedef struct POLICY_CONSTRAINTS_st { |
0f113f3e MC |
285 | ASN1_INTEGER *requireExplicitPolicy; |
286 | ASN1_INTEGER *inhibitPolicyMapping; | |
f80153e2 DSH |
287 | } POLICY_CONSTRAINTS; |
288 | ||
6951c23a | 289 | /* Proxy certificate structures, see RFC 3820 */ |
0f113f3e MC |
290 | typedef struct PROXY_POLICY_st { |
291 | ASN1_OBJECT *policyLanguage; | |
292 | ASN1_OCTET_STRING *policy; | |
293 | } PROXY_POLICY; | |
294 | ||
295 | typedef struct PROXY_CERT_INFO_EXTENSION_st { | |
296 | ASN1_INTEGER *pcPathLengthConstraint; | |
297 | PROXY_POLICY *proxyPolicy; | |
298 | } PROXY_CERT_INFO_EXTENSION; | |
6951c23a RL |
299 | |
300 | DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) | |
301 | DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) | |
302 | ||
0f113f3e MC |
303 | struct ISSUING_DIST_POINT_st { |
304 | DIST_POINT_NAME *distpoint; | |
305 | int onlyuser; | |
306 | int onlyCA; | |
307 | ASN1_BIT_STRING *onlysomereasons; | |
308 | int indirectCRL; | |
309 | int onlyattr; | |
310 | }; | |
6951c23a | 311 | |
4d50a2b4 DSH |
312 | /* Values in idp_flags field */ |
313 | /* IDP present */ | |
0f113f3e | 314 | # define IDP_PRESENT 0x1 |
4d50a2b4 | 315 | /* IDP values inconsistent */ |
0f113f3e | 316 | # define IDP_INVALID 0x2 |
4d50a2b4 | 317 | /* onlyuser true */ |
0f113f3e | 318 | # define IDP_ONLYUSER 0x4 |
4d50a2b4 | 319 | /* onlyCA true */ |
0f113f3e | 320 | # define IDP_ONLYCA 0x8 |
4d50a2b4 | 321 | /* onlyattr true */ |
0f113f3e | 322 | # define IDP_ONLYATTR 0x10 |
4d50a2b4 | 323 | /* indirectCRL true */ |
0f113f3e | 324 | # define IDP_INDIRECT 0x20 |
4d50a2b4 | 325 | /* onlysomereasons present */ |
0f113f3e | 326 | # define IDP_REASONS 0x40 |
4d50a2b4 | 327 | |
0f113f3e | 328 | # define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \ |
9aeaf1b4 DSH |
329 | ",name:", val->name, ",value:", val->value); |
330 | ||
0f113f3e MC |
331 | # define X509V3_set_ctx_test(ctx) \ |
332 | X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) | |
333 | # define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; | |
41b731f2 | 334 | |
0f113f3e MC |
335 | # define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ |
336 | 0,0,0,0, \ | |
337 | 0,0, \ | |
338 | (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ | |
339 | (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ | |
340 | NULL, NULL, \ | |
341 | table} | |
9aeaf1b4 | 342 | |
0f113f3e MC |
343 | # define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ |
344 | 0,0,0,0, \ | |
345 | (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ | |
346 | (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ | |
347 | 0,0,0,0, \ | |
348 | NULL} | |
9aeaf1b4 | 349 | |
0f113f3e | 350 | # define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} |
673b102c DSH |
351 | |
352 | /* X509_PURPOSE stuff */ | |
353 | ||
0f113f3e MC |
354 | # define EXFLAG_BCONS 0x1 |
355 | # define EXFLAG_KUSAGE 0x2 | |
356 | # define EXFLAG_XKUSAGE 0x4 | |
357 | # define EXFLAG_NSCERT 0x8 | |
673b102c | 358 | |
0f113f3e | 359 | # define EXFLAG_CA 0x10 |
db50661f | 360 | /* Really self issued not necessarily self signed */ |
0f113f3e MC |
361 | # define EXFLAG_SI 0x20 |
362 | # define EXFLAG_V1 0x40 | |
363 | # define EXFLAG_INVALID 0x80 | |
364 | # define EXFLAG_SET 0x100 | |
365 | # define EXFLAG_CRITICAL 0x200 | |
366 | # define EXFLAG_PROXY 0x400 | |
367 | ||
368 | # define EXFLAG_INVALID_POLICY 0x800 | |
369 | # define EXFLAG_FRESHEST 0x1000 | |
b1efb716 | 370 | /* Self signed */ |
0f113f3e MC |
371 | # define EXFLAG_SS 0x2000 |
372 | ||
373 | # define KU_DIGITAL_SIGNATURE 0x0080 | |
374 | # define KU_NON_REPUDIATION 0x0040 | |
375 | # define KU_KEY_ENCIPHERMENT 0x0020 | |
376 | # define KU_DATA_ENCIPHERMENT 0x0010 | |
377 | # define KU_KEY_AGREEMENT 0x0008 | |
378 | # define KU_KEY_CERT_SIGN 0x0004 | |
379 | # define KU_CRL_SIGN 0x0002 | |
380 | # define KU_ENCIPHER_ONLY 0x0001 | |
381 | # define KU_DECIPHER_ONLY 0x8000 | |
382 | ||
383 | # define NS_SSL_CLIENT 0x80 | |
384 | # define NS_SSL_SERVER 0x40 | |
385 | # define NS_SMIME 0x20 | |
386 | # define NS_OBJSIGN 0x10 | |
387 | # define NS_SSL_CA 0x04 | |
388 | # define NS_SMIME_CA 0x02 | |
389 | # define NS_OBJSIGN_CA 0x01 | |
390 | # define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) | |
391 | ||
392 | # define XKU_SSL_SERVER 0x1 | |
393 | # define XKU_SSL_CLIENT 0x2 | |
394 | # define XKU_SMIME 0x4 | |
395 | # define XKU_CODE_SIGN 0x8 | |
396 | # define XKU_SGC 0x10 | |
397 | # define XKU_OCSP_SIGN 0x20 | |
398 | # define XKU_TIMESTAMP 0x40 | |
399 | # define XKU_DVCS 0x80 | |
400 | # define XKU_ANYEKU 0x100 | |
401 | ||
402 | # define X509_PURPOSE_DYNAMIC 0x1 | |
403 | # define X509_PURPOSE_DYNAMIC_NAME 0x2 | |
79875776 | 404 | |
673b102c | 405 | typedef struct x509_purpose_st { |
0f113f3e MC |
406 | int purpose; |
407 | int trust; /* Default trust ID */ | |
408 | int flags; | |
409 | int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int); | |
410 | char *name; | |
411 | char *sname; | |
412 | void *usr_data; | |
673b102c DSH |
413 | } X509_PURPOSE; |
414 | ||
0f113f3e MC |
415 | # define X509_PURPOSE_SSL_CLIENT 1 |
416 | # define X509_PURPOSE_SSL_SERVER 2 | |
417 | # define X509_PURPOSE_NS_SSL_SERVER 3 | |
418 | # define X509_PURPOSE_SMIME_SIGN 4 | |
419 | # define X509_PURPOSE_SMIME_ENCRYPT 5 | |
420 | # define X509_PURPOSE_CRL_SIGN 6 | |
421 | # define X509_PURPOSE_ANY 7 | |
422 | # define X509_PURPOSE_OCSP_HELPER 8 | |
423 | # define X509_PURPOSE_TIMESTAMP_SIGN 9 | |
673b102c | 424 | |
0f113f3e MC |
425 | # define X509_PURPOSE_MIN 1 |
426 | # define X509_PURPOSE_MAX 9 | |
dd413410 | 427 | |
8ca533e3 DSH |
428 | /* Flags for X509V3_EXT_print() */ |
429 | ||
0f113f3e | 430 | # define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) |
8ca533e3 | 431 | /* Return error for unknown extensions */ |
0f113f3e | 432 | # define X509V3_EXT_DEFAULT 0 |
8ca533e3 | 433 | /* Print error for unknown extensions */ |
0f113f3e | 434 | # define X509V3_EXT_ERROR_UNKNOWN (1L << 16) |
8ca533e3 | 435 | /* ASN1 parse unknown extensions */ |
0f113f3e | 436 | # define X509V3_EXT_PARSE_UNKNOWN (2L << 16) |
8ca533e3 | 437 | /* BIO_dump unknown extensions */ |
0f113f3e | 438 | # define X509V3_EXT_DUMP_UNKNOWN (3L << 16) |
8ca533e3 | 439 | |
57d2f217 DSH |
440 | /* Flags for X509V3_add1_i2d */ |
441 | ||
0f113f3e MC |
442 | # define X509V3_ADD_OP_MASK 0xfL |
443 | # define X509V3_ADD_DEFAULT 0L | |
444 | # define X509V3_ADD_APPEND 1L | |
445 | # define X509V3_ADD_REPLACE 2L | |
446 | # define X509V3_ADD_REPLACE_EXISTING 3L | |
447 | # define X509V3_ADD_KEEP_EXISTING 4L | |
448 | # define X509V3_ADD_DELETE 5L | |
449 | # define X509V3_ADD_SILENT 0x10 | |
57d2f217 | 450 | |
85885715 | 451 | DEFINE_STACK_OF(X509_PURPOSE) |
673b102c | 452 | |
2aff7727 | 453 | DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) |
9aeaf1b4 | 454 | |
9d6b1ce6 DSH |
455 | DECLARE_ASN1_FUNCTIONS(SXNET) |
456 | DECLARE_ASN1_FUNCTIONS(SXNETID) | |
785cdf20 | 457 | |
0f113f3e MC |
458 | int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); |
459 | int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, | |
460 | int userlen); | |
461 | int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, | |
462 | int userlen); | |
28a98809 DSH |
463 | |
464 | ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone); | |
465 | ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); | |
466 | ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); | |
467 | ||
9d6b1ce6 DSH |
468 | DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) |
469 | ||
470 | DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) | |
471 | ||
472 | DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) | |
c7235be6 UM |
473 | GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a); |
474 | int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b); | |
475 | ||
5d6383c8 | 476 | ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, |
0f113f3e MC |
477 | X509V3_CTX *ctx, |
478 | STACK_OF(CONF_VALUE) *nval); | |
5d6383c8 | 479 | STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, |
0f113f3e MC |
480 | ASN1_BIT_STRING *bits, |
481 | STACK_OF(CONF_VALUE) *extlist); | |
482 | char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5); | |
6452a139 | 483 | ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, |
13f74c66 | 484 | X509V3_CTX *ctx, const char *str); |
5d6383c8 | 485 | |
0f113f3e MC |
486 | STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, |
487 | GENERAL_NAME *gen, | |
488 | STACK_OF(CONF_VALUE) *ret); | |
2c15d426 | 489 | int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); |
175b0942 | 490 | |
9d6b1ce6 | 491 | DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) |
0be9747b | 492 | |
ba404b5e | 493 | STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, |
0f113f3e MC |
494 | GENERAL_NAMES *gen, |
495 | STACK_OF(CONF_VALUE) *extlist); | |
babb3798 | 496 | GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, |
0f113f3e | 497 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); |
142fcca8 | 498 | |
9d6b1ce6 DSH |
499 | DECLARE_ASN1_FUNCTIONS(OTHERNAME) |
500 | DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) | |
c7235be6 | 501 | int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b); |
a5cdb7d5 DSH |
502 | void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value); |
503 | void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype); | |
504 | int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, | |
0f113f3e MC |
505 | ASN1_OBJECT *oid, ASN1_TYPE *value); |
506 | int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, | |
507 | ASN1_OBJECT **poid, ASN1_TYPE **pvalue); | |
a716d727 | 508 | |
0f113f3e MC |
509 | char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, |
510 | ASN1_OCTET_STRING *ia5); | |
511 | ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, | |
512 | X509V3_CTX *ctx, char *str); | |
142fcca8 | 513 | |
9d6b1ce6 | 514 | DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) |
0f113f3e | 515 | int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION *a); |
6d3724d3 | 516 | |
ba67253d RS |
517 | DECLARE_ASN1_ALLOC_FUNCTIONS(TLS_FEATURE) |
518 | ||
9d6b1ce6 DSH |
519 | DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) |
520 | DECLARE_ASN1_FUNCTIONS(POLICYINFO) | |
521 | DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) | |
522 | DECLARE_ASN1_FUNCTIONS(USERNOTICE) | |
523 | DECLARE_ASN1_FUNCTIONS(NOTICEREF) | |
6d3724d3 | 524 | |
9d6b1ce6 DSH |
525 | DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) |
526 | DECLARE_ASN1_FUNCTIONS(DIST_POINT) | |
527 | DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) | |
8eb72175 | 528 | DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT) |
6d3724d3 | 529 | |
3e727a3b DSH |
530 | int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname); |
531 | ||
e9746e03 DSH |
532 | int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc); |
533 | ||
9d6b1ce6 DSH |
534 | DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) |
535 | DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) | |
6d3724d3 | 536 | |
a1d12dae | 537 | DECLARE_ASN1_ITEM(POLICY_MAPPING) |
ea3675b5 | 538 | DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) |
a1d12dae DSH |
539 | DECLARE_ASN1_ITEM(POLICY_MAPPINGS) |
540 | ||
520b76ff DSH |
541 | DECLARE_ASN1_ITEM(GENERAL_SUBTREE) |
542 | DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) | |
543 | ||
544 | DECLARE_ASN1_ITEM(NAME_CONSTRAINTS) | |
545 | DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) | |
546 | ||
f80153e2 DSH |
547 | DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) |
548 | DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) | |
549 | ||
be86c7fc | 550 | GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, |
0f113f3e MC |
551 | const X509V3_EXT_METHOD *method, |
552 | X509V3_CTX *ctx, int gen_type, char *value, | |
553 | int is_nc); | |
be86c7fc | 554 | |
0f113f3e MC |
555 | # ifdef HEADER_CONF_H |
556 | GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, | |
557 | X509V3_CTX *ctx, CONF_VALUE *cnf); | |
babb3798 | 558 | GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, |
0f113f3e MC |
559 | const X509V3_EXT_METHOD *method, |
560 | X509V3_CTX *ctx, CONF_VALUE *cnf, | |
561 | int is_nc); | |
9aeaf1b4 | 562 | void X509V3_conf_free(CONF_VALUE *val); |
b7a26e6d | 563 | |
0f113f3e MC |
564 | X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, |
565 | char *value); | |
566 | X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, | |
567 | char *value); | |
568 | int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, | |
569 | STACK_OF(X509_EXTENSION) **sk); | |
570 | int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, | |
571 | X509 *cert); | |
572 | int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, | |
573 | X509_REQ *req); | |
574 | int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, | |
575 | X509_CRL *crl); | |
576 | ||
577 | X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, | |
578 | X509V3_CTX *ctx, int ext_nid, | |
579 | char *value); | |
3c1d6bbc | 580 | X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, |
0f113f3e | 581 | char *name, char *value); |
3c1d6bbc | 582 | int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, |
0f113f3e | 583 | char *section, X509 *cert); |
3c1d6bbc | 584 | int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, |
0f113f3e | 585 | char *section, X509_REQ *req); |
3c1d6bbc | 586 | int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, |
0f113f3e | 587 | char *section, X509_CRL *crl); |
b7a26e6d | 588 | |
ba404b5e | 589 | int X509V3_add_value_bool_nf(char *name, int asn1_bool, |
0f113f3e | 590 | STACK_OF(CONF_VALUE) **extlist); |
9aeaf1b4 DSH |
591 | int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); |
592 | int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); | |
b7a26e6d | 593 | void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); |
3c1d6bbc | 594 | void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash); |
0f113f3e | 595 | # endif |
9aeaf1b4 | 596 | |
0f113f3e MC |
597 | char *X509V3_get_string(X509V3_CTX *ctx, char *name, char *section); |
598 | STACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, char *section); | |
41b731f2 | 599 | void X509V3_string_free(X509V3_CTX *ctx, char *str); |
0f113f3e | 600 | void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); |
1d48dd00 | 601 | void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, |
0f113f3e | 602 | X509_REQ *req, X509_CRL *crl, int flags); |
1d48dd00 | 603 | |
ba404b5e | 604 | int X509V3_add_value(const char *name, const char *value, |
0f113f3e | 605 | STACK_OF(CONF_VALUE) **extlist); |
61f5b6f3 | 606 | int X509V3_add_value_uchar(const char *name, const unsigned char *value, |
0f113f3e | 607 | STACK_OF(CONF_VALUE) **extlist); |
ba404b5e | 608 | int X509V3_add_value_bool(const char *name, int asn1_bool, |
0f113f3e | 609 | STACK_OF(CONF_VALUE) **extlist); |
ba404b5e | 610 | int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, |
0f113f3e MC |
611 | STACK_OF(CONF_VALUE) **extlist); |
612 | char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint); | |
2b91da96 | 613 | ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const char *value); |
0f113f3e MC |
614 | char *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); |
615 | char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, | |
616 | ASN1_ENUMERATED *aint); | |
9aeaf1b4 | 617 | int X509V3_EXT_add(X509V3_EXT_METHOD *ext); |
397f7038 | 618 | int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); |
9aeaf1b4 DSH |
619 | int X509V3_EXT_add_alias(int nid_to, int nid_from); |
620 | void X509V3_EXT_cleanup(void); | |
621 | ||
babb3798 BL |
622 | const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); |
623 | const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); | |
9aeaf1b4 | 624 | int X509V3_add_standard_extensions(void); |
535d79da | 625 | STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); |
f5fedc04 | 626 | void *X509V3_EXT_d2i(X509_EXTENSION *ext); |
0f113f3e MC |
627 | void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, |
628 | int *idx); | |
57d2f217 | 629 | |
c8b41850 | 630 | X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); |
0f113f3e MC |
631 | int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, |
632 | int crit, unsigned long flags); | |
9aeaf1b4 | 633 | |
14f051a0 RS |
634 | #if OPENSSL_API_COMPAT < 0x00101000L |
635 | /* The new declarations are in crypto.h, but the old ones were here. */ | |
636 | # define hex_to_string OPENSSL_buf2hexstr | |
637 | # define string_to_hex OPENSSL_hexstr2buf | |
638 | #endif | |
175b0942 | 639 | |
ba404b5e | 640 | void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, |
0f113f3e MC |
641 | int ml); |
642 | int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, | |
643 | int indent); | |
984d6c60 | 644 | #ifndef OPENSSL_NO_STDIO |
785cdf20 | 645 | int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); |
984d6c60 | 646 | #endif |
0f113f3e MC |
647 | int X509V3_extensions_print(BIO *out, char *title, |
648 | STACK_OF(X509_EXTENSION) *exts, | |
649 | unsigned long flag, int indent); | |
2c15d426 | 650 | |
30b415b0 | 651 | int X509_check_ca(X509 *x); |
673b102c | 652 | int X509_check_purpose(X509 *x, int id, int ca); |
f1558bb4 | 653 | int X509_supported_extension(X509_EXTENSION *ex); |
926a56bf | 654 | int X509_PURPOSE_set(int *p, int purpose); |
2f043896 | 655 | int X509_check_issued(X509 *issuer, X509 *subject); |
bc7535bc | 656 | int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid); |
063f1f0c DSH |
657 | |
658 | uint32_t X509_get_extension_flags(X509 *x); | |
659 | uint32_t X509_get_key_usage(X509 *x); | |
660 | uint32_t X509_get_extended_key_usage(X509 *x); | |
d19a50c9 | 661 | const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x); |
063f1f0c | 662 | |
d4cec6a1 | 663 | int X509_PURPOSE_get_count(void); |
0f113f3e | 664 | X509_PURPOSE *X509_PURPOSE_get0(int idx); |
d4cec6a1 DSH |
665 | int X509_PURPOSE_get_by_sname(char *sname); |
666 | int X509_PURPOSE_get_by_id(int id); | |
dd413410 | 667 | int X509_PURPOSE_add(int id, int trust, int flags, |
0f113f3e MC |
668 | int (*ck) (const X509_PURPOSE *, const X509 *, int), |
669 | char *name, char *sname, void *arg); | |
c7cb16a8 DSH |
670 | char *X509_PURPOSE_get0_name(X509_PURPOSE *xp); |
671 | char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp); | |
d4cec6a1 | 672 | int X509_PURPOSE_get_trust(X509_PURPOSE *xp); |
79875776 | 673 | void X509_PURPOSE_cleanup(void); |
673b102c | 674 | int X509_PURPOSE_get_id(X509_PURPOSE *); |
673b102c | 675 | |
c869da88 DSH |
676 | STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x); |
677 | STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x); | |
678 | void X509_email_free(STACK_OF(OPENSSL_STRING) *sk); | |
679 | STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x); | |
a70da5b3 DSH |
680 | /* Flags for X509_check_* functions */ |
681 | ||
0f113f3e MC |
682 | /* |
683 | * Always check subject name for host match even if subject alt names present | |
684 | */ | |
685 | # define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT 0x1 | |
397a8e74 | 686 | /* Disable wildcard matching for dnsName fields and common name. */ |
0f113f3e | 687 | # define X509_CHECK_FLAG_NO_WILDCARDS 0x2 |
397a8e74 | 688 | /* Wildcards must not match a partial label. */ |
0f113f3e | 689 | # define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4 |
397a8e74 | 690 | /* Allow (non-partial) wildcards to match multiple labels. */ |
0f113f3e | 691 | # define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8 |
a09e4d24 | 692 | /* Constraint verifier subdomain patterns to match a single labels. */ |
0f113f3e | 693 | # define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10 |
dd60efea VD |
694 | /* Never check the subject CN */ |
695 | # define X509_CHECK_FLAG_NEVER_CHECK_SUBJECT 0x20 | |
a09e4d24 VD |
696 | /* |
697 | * Match reference identifiers starting with "." to any sub-domain. | |
698 | * This is a non-public flag, turned on implicitly when the subject | |
699 | * reference identity is a DNS name. | |
700 | */ | |
0f113f3e | 701 | # define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000 |
a70da5b3 | 702 | |
297c67fc | 703 | int X509_check_host(X509 *x, const char *chk, size_t chklen, |
0f113f3e | 704 | unsigned int flags, char **peername); |
297c67fc | 705 | int X509_check_email(X509 *x, const char *chk, size_t chklen, |
0f113f3e | 706 | unsigned int flags); |
a70da5b3 | 707 | int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen, |
0f113f3e | 708 | unsigned int flags); |
a70da5b3 | 709 | int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags); |
a91dedca | 710 | |
4e5d3a7f | 711 | ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); |
520b76ff | 712 | ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); |
96ea4ae9 | 713 | int a2i_ipadd(unsigned char *ipout, const char *ipasc); |
a7b1eed5 | 714 | int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk, |
0f113f3e | 715 | unsigned long chtype); |
a91dedca | 716 | |
ecf13991 | 717 | void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); |
85885715 | 718 | DEFINE_STACK_OF(X509_POLICY_NODE) |
ecf13991 | 719 | |
47bbaa5b | 720 | #ifndef OPENSSL_NO_RFC3779 |
96ea4ae9 | 721 | typedef struct ASRange_st { |
0f113f3e | 722 | ASN1_INTEGER *min, *max; |
96ea4ae9 BL |
723 | } ASRange; |
724 | ||
c73ad690 RS |
725 | # define ASIdOrRange_id 0 |
726 | # define ASIdOrRange_range 1 | |
96ea4ae9 BL |
727 | |
728 | typedef struct ASIdOrRange_st { | |
0f113f3e MC |
729 | int type; |
730 | union { | |
731 | ASN1_INTEGER *id; | |
732 | ASRange *range; | |
733 | } u; | |
96ea4ae9 BL |
734 | } ASIdOrRange; |
735 | ||
736 | typedef STACK_OF(ASIdOrRange) ASIdOrRanges; | |
85885715 | 737 | DEFINE_STACK_OF(ASIdOrRange) |
96ea4ae9 | 738 | |
c73ad690 RS |
739 | # define ASIdentifierChoice_inherit 0 |
740 | # define ASIdentifierChoice_asIdsOrRanges 1 | |
96ea4ae9 BL |
741 | |
742 | typedef struct ASIdentifierChoice_st { | |
0f113f3e MC |
743 | int type; |
744 | union { | |
745 | ASN1_NULL *inherit; | |
746 | ASIdOrRanges *asIdsOrRanges; | |
747 | } u; | |
96ea4ae9 BL |
748 | } ASIdentifierChoice; |
749 | ||
750 | typedef struct ASIdentifiers_st { | |
0f113f3e | 751 | ASIdentifierChoice *asnum, *rdi; |
96ea4ae9 BL |
752 | } ASIdentifiers; |
753 | ||
754 | DECLARE_ASN1_FUNCTIONS(ASRange) | |
755 | DECLARE_ASN1_FUNCTIONS(ASIdOrRange) | |
756 | DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice) | |
757 | DECLARE_ASN1_FUNCTIONS(ASIdentifiers) | |
758 | ||
96ea4ae9 | 759 | typedef struct IPAddressRange_st { |
0f113f3e | 760 | ASN1_BIT_STRING *min, *max; |
96ea4ae9 BL |
761 | } IPAddressRange; |
762 | ||
c73ad690 RS |
763 | # define IPAddressOrRange_addressPrefix 0 |
764 | # define IPAddressOrRange_addressRange 1 | |
96ea4ae9 BL |
765 | |
766 | typedef struct IPAddressOrRange_st { | |
0f113f3e MC |
767 | int type; |
768 | union { | |
769 | ASN1_BIT_STRING *addressPrefix; | |
770 | IPAddressRange *addressRange; | |
771 | } u; | |
96ea4ae9 BL |
772 | } IPAddressOrRange; |
773 | ||
774 | typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges; | |
85885715 | 775 | DEFINE_STACK_OF(IPAddressOrRange) |
96ea4ae9 | 776 | |
c73ad690 RS |
777 | # define IPAddressChoice_inherit 0 |
778 | # define IPAddressChoice_addressesOrRanges 1 | |
96ea4ae9 BL |
779 | |
780 | typedef struct IPAddressChoice_st { | |
0f113f3e MC |
781 | int type; |
782 | union { | |
783 | ASN1_NULL *inherit; | |
784 | IPAddressOrRanges *addressesOrRanges; | |
785 | } u; | |
96ea4ae9 BL |
786 | } IPAddressChoice; |
787 | ||
788 | typedef struct IPAddressFamily_st { | |
0f113f3e MC |
789 | ASN1_OCTET_STRING *addressFamily; |
790 | IPAddressChoice *ipAddressChoice; | |
96ea4ae9 BL |
791 | } IPAddressFamily; |
792 | ||
793 | typedef STACK_OF(IPAddressFamily) IPAddrBlocks; | |
85885715 | 794 | DEFINE_STACK_OF(IPAddressFamily) |
96ea4ae9 BL |
795 | |
796 | DECLARE_ASN1_FUNCTIONS(IPAddressRange) | |
797 | DECLARE_ASN1_FUNCTIONS(IPAddressOrRange) | |
798 | DECLARE_ASN1_FUNCTIONS(IPAddressChoice) | |
799 | DECLARE_ASN1_FUNCTIONS(IPAddressFamily) | |
800 | ||
801 | /* | |
802 | * API tag for elements of the ASIdentifer SEQUENCE. | |
803 | */ | |
c73ad690 RS |
804 | # define V3_ASID_ASNUM 0 |
805 | # define V3_ASID_RDI 1 | |
96ea4ae9 BL |
806 | |
807 | /* | |
808 | * AFI values, assigned by IANA. It'd be nice to make the AFI | |
809 | * handling code totally generic, but there are too many little things | |
810 | * that would need to be defined for other address families for it to | |
811 | * be worth the trouble. | |
812 | */ | |
c73ad690 RS |
813 | # define IANA_AFI_IPV4 1 |
814 | # define IANA_AFI_IPV6 2 | |
96ea4ae9 BL |
815 | |
816 | /* | |
817 | * Utilities to construct and extract values from RFC3779 extensions, | |
818 | * since some of the encodings (particularly for IP address prefixes | |
819 | * and ranges) are a bit tedious to work with directly. | |
820 | */ | |
9021a5df RS |
821 | int X509v3_asid_add_inherit(ASIdentifiers *asid, int which); |
822 | int X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which, | |
823 | ASN1_INTEGER *min, ASN1_INTEGER *max); | |
824 | int X509v3_addr_add_inherit(IPAddrBlocks *addr, | |
825 | const unsigned afi, const unsigned *safi); | |
826 | int X509v3_addr_add_prefix(IPAddrBlocks *addr, | |
827 | const unsigned afi, const unsigned *safi, | |
828 | unsigned char *a, const int prefixlen); | |
829 | int X509v3_addr_add_range(IPAddrBlocks *addr, | |
830 | const unsigned afi, const unsigned *safi, | |
831 | unsigned char *min, unsigned char *max); | |
832 | unsigned X509v3_addr_get_afi(const IPAddressFamily *f); | |
833 | int X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, | |
834 | unsigned char *min, unsigned char *max, | |
835 | const int length); | |
96ea4ae9 BL |
836 | |
837 | /* | |
838 | * Canonical forms. | |
839 | */ | |
9021a5df RS |
840 | int X509v3_asid_is_canonical(ASIdentifiers *asid); |
841 | int X509v3_addr_is_canonical(IPAddrBlocks *addr); | |
842 | int X509v3_asid_canonize(ASIdentifiers *asid); | |
843 | int X509v3_addr_canonize(IPAddrBlocks *addr); | |
96ea4ae9 BL |
844 | |
845 | /* | |
846 | * Tests for inheritance and containment. | |
847 | */ | |
9021a5df RS |
848 | int X509v3_asid_inherits(ASIdentifiers *asid); |
849 | int X509v3_addr_inherits(IPAddrBlocks *addr); | |
850 | int X509v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b); | |
851 | int X509v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b); | |
96ea4ae9 BL |
852 | |
853 | /* | |
854 | * Check whether RFC 3779 extensions nest properly in chains. | |
855 | */ | |
9021a5df RS |
856 | int X509v3_asid_validate_path(X509_STORE_CTX *); |
857 | int X509v3_addr_validate_path(X509_STORE_CTX *); | |
858 | int X509v3_asid_validate_resource_set(STACK_OF(X509) *chain, | |
859 | ASIdentifiers *ext, | |
860 | int allow_inheritance); | |
861 | int X509v3_addr_validate_resource_set(STACK_OF(X509) *chain, | |
862 | IPAddrBlocks *ext, int allow_inheritance); | |
96ea4ae9 | 863 | |
47bbaa5b | 864 | #endif /* OPENSSL_NO_RFC3779 */ |
9021a5df | 865 | |
9aeaf1b4 | 866 | /* BEGIN ERROR CODES */ |
0f113f3e MC |
867 | /* |
868 | * The following lines are auto generated by the script mkerr.pl. Any changes | |
6d311938 DSH |
869 | * made after this point may be overwritten when the script is next run. |
870 | */ | |
0cd0a820 | 871 | |
926a56bf | 872 | void ERR_load_X509V3_strings(void); |
6d311938 | 873 | |
9aeaf1b4 DSH |
874 | /* Error codes for the X509V3 functions. */ |
875 | ||
876 | /* Function codes. */ | |
0f113f3e | 877 | # define X509V3_F_A2I_GENERAL_NAME 164 |
9021a5df | 878 | # define X509V3_F_ADDR_VALIDATE_PATH_INTERNAL 166 |
0f113f3e MC |
879 | # define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 161 |
880 | # define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 162 | |
881 | # define X509V3_F_COPY_EMAIL 122 | |
882 | # define X509V3_F_COPY_ISSUER 123 | |
883 | # define X509V3_F_DO_DIRNAME 144 | |
0f113f3e MC |
884 | # define X509V3_F_DO_EXT_I2D 135 |
885 | # define X509V3_F_DO_EXT_NCONF 151 | |
0f113f3e | 886 | # define X509V3_F_GNAMES_FROM_SECTNAME 156 |
0f113f3e MC |
887 | # define X509V3_F_I2S_ASN1_ENUMERATED 121 |
888 | # define X509V3_F_I2S_ASN1_IA5STRING 149 | |
889 | # define X509V3_F_I2S_ASN1_INTEGER 120 | |
890 | # define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138 | |
891 | # define X509V3_F_NOTICE_SECTION 132 | |
892 | # define X509V3_F_NREF_NOS 133 | |
893 | # define X509V3_F_POLICY_SECTION 131 | |
894 | # define X509V3_F_PROCESS_PCI_VALUE 150 | |
895 | # define X509V3_F_R2I_CERTPOL 130 | |
896 | # define X509V3_F_R2I_PCI 155 | |
897 | # define X509V3_F_S2I_ASN1_IA5STRING 100 | |
898 | # define X509V3_F_S2I_ASN1_INTEGER 108 | |
899 | # define X509V3_F_S2I_ASN1_OCTET_STRING 112 | |
0f113f3e MC |
900 | # define X509V3_F_S2I_SKEY_ID 115 |
901 | # define X509V3_F_SET_DIST_POINT_NAME 158 | |
0f113f3e MC |
902 | # define X509V3_F_SXNET_ADD_ID_ASC 125 |
903 | # define X509V3_F_SXNET_ADD_ID_INTEGER 126 | |
904 | # define X509V3_F_SXNET_ADD_ID_ULONG 127 | |
905 | # define X509V3_F_SXNET_GET_ID_ASC 128 | |
906 | # define X509V3_F_SXNET_GET_ID_ULONG 129 | |
907 | # define X509V3_F_V2I_ASIDENTIFIERS 163 | |
908 | # define X509V3_F_V2I_ASN1_BIT_STRING 101 | |
909 | # define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139 | |
910 | # define X509V3_F_V2I_AUTHORITY_KEYID 119 | |
911 | # define X509V3_F_V2I_BASIC_CONSTRAINTS 102 | |
912 | # define X509V3_F_V2I_CRLD 134 | |
913 | # define X509V3_F_V2I_EXTENDED_KEY_USAGE 103 | |
914 | # define X509V3_F_V2I_GENERAL_NAMES 118 | |
915 | # define X509V3_F_V2I_GENERAL_NAME_EX 117 | |
916 | # define X509V3_F_V2I_IDP 157 | |
917 | # define X509V3_F_V2I_IPADDRBLOCKS 159 | |
918 | # define X509V3_F_V2I_ISSUER_ALT 153 | |
919 | # define X509V3_F_V2I_NAME_CONSTRAINTS 147 | |
920 | # define X509V3_F_V2I_POLICY_CONSTRAINTS 146 | |
921 | # define X509V3_F_V2I_POLICY_MAPPINGS 145 | |
922 | # define X509V3_F_V2I_SUBJECT_ALT 154 | |
ba67253d | 923 | # define X509V3_F_V2I_TLS_FEATURE 165 |
0f113f3e MC |
924 | # define X509V3_F_V3_GENERIC_EXTENSION 116 |
925 | # define X509V3_F_X509V3_ADD1_I2D 140 | |
926 | # define X509V3_F_X509V3_ADD_VALUE 105 | |
927 | # define X509V3_F_X509V3_EXT_ADD 104 | |
928 | # define X509V3_F_X509V3_EXT_ADD_ALIAS 106 | |
0f113f3e MC |
929 | # define X509V3_F_X509V3_EXT_I2D 136 |
930 | # define X509V3_F_X509V3_EXT_NCONF 152 | |
931 | # define X509V3_F_X509V3_GET_SECTION 142 | |
932 | # define X509V3_F_X509V3_GET_STRING 143 | |
933 | # define X509V3_F_X509V3_GET_VALUE_BOOL 110 | |
934 | # define X509V3_F_X509V3_PARSE_LIST 109 | |
935 | # define X509V3_F_X509_PURPOSE_ADD 137 | |
936 | # define X509V3_F_X509_PURPOSE_SET 141 | |
9aeaf1b4 DSH |
937 | |
938 | /* Reason codes. */ | |
0f113f3e MC |
939 | # define X509V3_R_BAD_IP_ADDRESS 118 |
940 | # define X509V3_R_BAD_OBJECT 119 | |
941 | # define X509V3_R_BN_DEC2BN_ERROR 100 | |
942 | # define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 | |
943 | # define X509V3_R_DIRNAME_ERROR 149 | |
944 | # define X509V3_R_DISTPOINT_ALREADY_SET 160 | |
945 | # define X509V3_R_DUPLICATE_ZONE_ID 133 | |
946 | # define X509V3_R_ERROR_CONVERTING_ZONE 131 | |
947 | # define X509V3_R_ERROR_CREATING_EXTENSION 144 | |
948 | # define X509V3_R_ERROR_IN_EXTENSION 128 | |
949 | # define X509V3_R_EXPECTED_A_SECTION_NAME 137 | |
950 | # define X509V3_R_EXTENSION_EXISTS 145 | |
951 | # define X509V3_R_EXTENSION_NAME_ERROR 115 | |
952 | # define X509V3_R_EXTENSION_NOT_FOUND 102 | |
953 | # define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103 | |
954 | # define X509V3_R_EXTENSION_VALUE_ERROR 116 | |
955 | # define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151 | |
0f113f3e | 956 | # define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152 |
0f113f3e MC |
957 | # define X509V3_R_INVALID_ASNUMBER 162 |
958 | # define X509V3_R_INVALID_ASRANGE 163 | |
959 | # define X509V3_R_INVALID_BOOLEAN_STRING 104 | |
960 | # define X509V3_R_INVALID_EXTENSION_STRING 105 | |
961 | # define X509V3_R_INVALID_INHERITANCE 165 | |
962 | # define X509V3_R_INVALID_IPADDRESS 166 | |
9021a5df | 963 | # define X509V3_R_INVALID_MULTIPLE_RDNS 161 |
0f113f3e MC |
964 | # define X509V3_R_INVALID_NAME 106 |
965 | # define X509V3_R_INVALID_NULL_ARGUMENT 107 | |
966 | # define X509V3_R_INVALID_NULL_NAME 108 | |
967 | # define X509V3_R_INVALID_NULL_VALUE 109 | |
968 | # define X509V3_R_INVALID_NUMBER 140 | |
969 | # define X509V3_R_INVALID_NUMBERS 141 | |
970 | # define X509V3_R_INVALID_OBJECT_IDENTIFIER 110 | |
971 | # define X509V3_R_INVALID_OPTION 138 | |
972 | # define X509V3_R_INVALID_POLICY_IDENTIFIER 134 | |
973 | # define X509V3_R_INVALID_PROXY_POLICY_SETTING 153 | |
974 | # define X509V3_R_INVALID_PURPOSE 146 | |
975 | # define X509V3_R_INVALID_SAFI 164 | |
976 | # define X509V3_R_INVALID_SECTION 135 | |
977 | # define X509V3_R_INVALID_SYNTAX 143 | |
978 | # define X509V3_R_ISSUER_DECODE_ERROR 126 | |
979 | # define X509V3_R_MISSING_VALUE 124 | |
980 | # define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 | |
981 | # define X509V3_R_NO_CONFIG_DATABASE 136 | |
982 | # define X509V3_R_NO_ISSUER_CERTIFICATE 121 | |
983 | # define X509V3_R_NO_ISSUER_DETAILS 127 | |
984 | # define X509V3_R_NO_POLICY_IDENTIFIER 139 | |
985 | # define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 154 | |
986 | # define X509V3_R_NO_PUBLIC_KEY 114 | |
987 | # define X509V3_R_NO_SUBJECT_DETAILS 125 | |
0f113f3e MC |
988 | # define X509V3_R_OPERATION_NOT_DEFINED 148 |
989 | # define X509V3_R_OTHERNAME_ERROR 147 | |
990 | # define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED 155 | |
991 | # define X509V3_R_POLICY_PATH_LENGTH 156 | |
992 | # define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED 157 | |
0f113f3e MC |
993 | # define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159 |
994 | # define X509V3_R_SECTION_NOT_FOUND 150 | |
995 | # define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122 | |
996 | # define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123 | |
997 | # define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111 | |
998 | # define X509V3_R_UNKNOWN_EXTENSION 129 | |
999 | # define X509V3_R_UNKNOWN_EXTENSION_NAME 130 | |
1000 | # define X509V3_R_UNKNOWN_OPTION 120 | |
1001 | # define X509V3_R_UNSUPPORTED_OPTION 117 | |
1002 | # define X509V3_R_UNSUPPORTED_TYPE 167 | |
1003 | # define X509V3_R_USER_TOO_LONG 132 | |
6d311938 | 1004 | |
0cd0a820 | 1005 | # ifdef __cplusplus |
9aeaf1b4 | 1006 | } |
0cd0a820 | 1007 | # endif |
9aeaf1b4 | 1008 | #endif |