2 * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
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
10 #ifndef HEADER_X509V3_H
11 # define HEADER_X509V3_H
13 # include <openssl/bio.h>
14 # include <openssl/x509.h>
15 # include <openssl/conf.h>
21 /* Forward reference */
27 typedef void *(*X509V3_EXT_NEW)(void);
28 typedef void (*X509V3_EXT_FREE) (void *);
29 typedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long);
30 typedef int (*X509V3_EXT_I2D) (void *, unsigned char **);
31 typedef STACK_OF(CONF_VALUE) *
32 (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext,
33 STACK_OF(CONF_VALUE) *extlist);
34 typedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method,
35 struct v3_ext_ctx *ctx,
36 STACK_OF(CONF_VALUE) *values);
37 typedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method,
39 typedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method,
40 struct v3_ext_ctx *ctx, const char *str);
41 typedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext,
42 BIO *out, int indent);
43 typedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method,
44 struct v3_ext_ctx *ctx, const char *str);
46 /* V3 extension structure */
48 struct v3_ext_method {
51 /* If this is set the following four fields are ignored */
53 /* Old style ASN1 calls */
54 X509V3_EXT_NEW ext_new;
55 X509V3_EXT_FREE ext_free;
58 /* The following pair is used for string extensions */
61 /* The following pair is used for multi-valued extensions */
64 /* The following are used for raw extensions */
67 void *usr_data; /* Any extension specific data */
70 typedef struct X509V3_CONF_METHOD_st {
71 char *(*get_string) (void *db, const char *section, const char *value);
72 STACK_OF(CONF_VALUE) *(*get_section) (void *db, const char *section);
73 void (*free_string) (void *db, char *string);
74 void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section);
77 /* Context specific info */
80 # define X509V3_CTX_REPLACE 0x2
84 X509_REQ *subject_req;
86 X509V3_CONF_METHOD *db_meth;
91 typedef struct v3_ext_method X509V3_EXT_METHOD;
93 DEFINE_STACK_OF(X509V3_EXT_METHOD)
95 /* ext_flags values */
96 # define X509V3_EXT_DYNAMIC 0x1
97 # define X509V3_EXT_CTX_DEP 0x2
98 # define X509V3_EXT_MULTILINE 0x4
100 typedef BIT_STRING_BITNAME ENUMERATED_NAMES;
102 typedef struct BASIC_CONSTRAINTS_st {
104 ASN1_INTEGER *pathlen;
107 typedef struct PKEY_USAGE_PERIOD_st {
108 ASN1_GENERALIZEDTIME *notBefore;
109 ASN1_GENERALIZEDTIME *notAfter;
112 typedef struct otherName_st {
113 ASN1_OBJECT *type_id;
117 typedef struct EDIPartyName_st {
118 ASN1_STRING *nameAssigner;
119 ASN1_STRING *partyName;
122 typedef struct GENERAL_NAME_st {
123 # define GEN_OTHERNAME 0
127 # define GEN_DIRNAME 4
128 # define GEN_EDIPARTY 5
135 OTHERNAME *otherName; /* otherName */
136 ASN1_IA5STRING *rfc822Name;
137 ASN1_IA5STRING *dNSName;
138 ASN1_TYPE *x400Address;
139 X509_NAME *directoryName;
140 EDIPARTYNAME *ediPartyName;
141 ASN1_IA5STRING *uniformResourceIdentifier;
142 ASN1_OCTET_STRING *iPAddress;
143 ASN1_OBJECT *registeredID;
145 ASN1_OCTET_STRING *ip; /* iPAddress */
146 X509_NAME *dirn; /* dirn */
147 ASN1_IA5STRING *ia5; /* rfc822Name, dNSName,
148 * uniformResourceIdentifier */
149 ASN1_OBJECT *rid; /* registeredID */
150 ASN1_TYPE *other; /* x400Address */
154 typedef struct ACCESS_DESCRIPTION_st {
156 GENERAL_NAME *location;
157 } ACCESS_DESCRIPTION;
159 typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;
161 typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;
163 typedef STACK_OF(ASN1_INTEGER) TLS_FEATURE;
165 DEFINE_STACK_OF(GENERAL_NAME)
166 typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;
167 DEFINE_STACK_OF(GENERAL_NAMES)
169 DEFINE_STACK_OF(ACCESS_DESCRIPTION)
171 typedef struct DIST_POINT_NAME_st {
174 GENERAL_NAMES *fullname;
175 STACK_OF(X509_NAME_ENTRY) *relativename;
177 /* If relativename then this contains the full distribution point name */
180 /* All existing reasons */
181 # define CRLDP_ALL_REASONS 0x807f
183 # define CRL_REASON_NONE -1
184 # define CRL_REASON_UNSPECIFIED 0
185 # define CRL_REASON_KEY_COMPROMISE 1
186 # define CRL_REASON_CA_COMPROMISE 2
187 # define CRL_REASON_AFFILIATION_CHANGED 3
188 # define CRL_REASON_SUPERSEDED 4
189 # define CRL_REASON_CESSATION_OF_OPERATION 5
190 # define CRL_REASON_CERTIFICATE_HOLD 6
191 # define CRL_REASON_REMOVE_FROM_CRL 8
192 # define CRL_REASON_PRIVILEGE_WITHDRAWN 9
193 # define CRL_REASON_AA_COMPROMISE 10
195 struct DIST_POINT_st {
196 DIST_POINT_NAME *distpoint;
197 ASN1_BIT_STRING *reasons;
198 GENERAL_NAMES *CRLissuer;
202 typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;
204 DEFINE_STACK_OF(DIST_POINT)
206 struct AUTHORITY_KEYID_st {
207 ASN1_OCTET_STRING *keyid;
208 GENERAL_NAMES *issuer;
209 ASN1_INTEGER *serial;
212 /* Strong extranet structures */
214 typedef struct SXNET_ID_st {
216 ASN1_OCTET_STRING *user;
219 DEFINE_STACK_OF(SXNETID)
221 typedef struct SXNET_st {
222 ASN1_INTEGER *version;
223 STACK_OF(SXNETID) *ids;
226 typedef struct NOTICEREF_st {
227 ASN1_STRING *organization;
228 STACK_OF(ASN1_INTEGER) *noticenos;
231 typedef struct USERNOTICE_st {
232 NOTICEREF *noticeref;
233 ASN1_STRING *exptext;
236 typedef struct POLICYQUALINFO_st {
237 ASN1_OBJECT *pqualid;
239 ASN1_IA5STRING *cpsuri;
240 USERNOTICE *usernotice;
245 DEFINE_STACK_OF(POLICYQUALINFO)
247 typedef struct POLICYINFO_st {
248 ASN1_OBJECT *policyid;
249 STACK_OF(POLICYQUALINFO) *qualifiers;
252 typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;
254 DEFINE_STACK_OF(POLICYINFO)
256 typedef struct POLICY_MAPPING_st {
257 ASN1_OBJECT *issuerDomainPolicy;
258 ASN1_OBJECT *subjectDomainPolicy;
261 DEFINE_STACK_OF(POLICY_MAPPING)
263 typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;
265 typedef struct GENERAL_SUBTREE_st {
267 ASN1_INTEGER *minimum;
268 ASN1_INTEGER *maximum;
271 DEFINE_STACK_OF(GENERAL_SUBTREE)
273 struct NAME_CONSTRAINTS_st {
274 STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;
275 STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;
278 typedef struct POLICY_CONSTRAINTS_st {
279 ASN1_INTEGER *requireExplicitPolicy;
280 ASN1_INTEGER *inhibitPolicyMapping;
281 } POLICY_CONSTRAINTS;
283 /* Proxy certificate structures, see RFC 3820 */
284 typedef struct PROXY_POLICY_st {
285 ASN1_OBJECT *policyLanguage;
286 ASN1_OCTET_STRING *policy;
289 typedef struct PROXY_CERT_INFO_EXTENSION_st {
290 ASN1_INTEGER *pcPathLengthConstraint;
291 PROXY_POLICY *proxyPolicy;
292 } PROXY_CERT_INFO_EXTENSION;
294 DECLARE_ASN1_FUNCTIONS(PROXY_POLICY)
295 DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)
297 struct ISSUING_DIST_POINT_st {
298 DIST_POINT_NAME *distpoint;
301 ASN1_BIT_STRING *onlysomereasons;
306 /* Values in idp_flags field */
308 # define IDP_PRESENT 0x1
309 /* IDP values inconsistent */
310 # define IDP_INVALID 0x2
312 # define IDP_ONLYUSER 0x4
314 # define IDP_ONLYCA 0x8
316 # define IDP_ONLYATTR 0x10
317 /* indirectCRL true */
318 # define IDP_INDIRECT 0x20
319 /* onlysomereasons present */
320 # define IDP_REASONS 0x40
322 # define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \
323 ",name:", val->name, ",value:", val->value);
325 # define X509V3_set_ctx_test(ctx) \
326 X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)
327 # define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;
329 # define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \
332 (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \
333 (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \
337 # define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \
339 (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \
340 (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \
344 # define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
346 /* X509_PURPOSE stuff */
348 # define EXFLAG_BCONS 0x1
349 # define EXFLAG_KUSAGE 0x2
350 # define EXFLAG_XKUSAGE 0x4
351 # define EXFLAG_NSCERT 0x8
353 # define EXFLAG_CA 0x10
354 /* Really self issued not necessarily self signed */
355 # define EXFLAG_SI 0x20
356 # define EXFLAG_V1 0x40
357 # define EXFLAG_INVALID 0x80
358 # define EXFLAG_SET 0x100
359 # define EXFLAG_CRITICAL 0x200
360 # define EXFLAG_PROXY 0x400
362 # define EXFLAG_INVALID_POLICY 0x800
363 # define EXFLAG_FRESHEST 0x1000
365 # define EXFLAG_SS 0x2000
367 # define KU_DIGITAL_SIGNATURE 0x0080
368 # define KU_NON_REPUDIATION 0x0040
369 # define KU_KEY_ENCIPHERMENT 0x0020
370 # define KU_DATA_ENCIPHERMENT 0x0010
371 # define KU_KEY_AGREEMENT 0x0008
372 # define KU_KEY_CERT_SIGN 0x0004
373 # define KU_CRL_SIGN 0x0002
374 # define KU_ENCIPHER_ONLY 0x0001
375 # define KU_DECIPHER_ONLY 0x8000
377 # define NS_SSL_CLIENT 0x80
378 # define NS_SSL_SERVER 0x40
379 # define NS_SMIME 0x20
380 # define NS_OBJSIGN 0x10
381 # define NS_SSL_CA 0x04
382 # define NS_SMIME_CA 0x02
383 # define NS_OBJSIGN_CA 0x01
384 # define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)
386 # define XKU_SSL_SERVER 0x1
387 # define XKU_SSL_CLIENT 0x2
388 # define XKU_SMIME 0x4
389 # define XKU_CODE_SIGN 0x8
390 # define XKU_SGC 0x10
391 # define XKU_OCSP_SIGN 0x20
392 # define XKU_TIMESTAMP 0x40
393 # define XKU_DVCS 0x80
394 # define XKU_ANYEKU 0x100
396 # define X509_PURPOSE_DYNAMIC 0x1
397 # define X509_PURPOSE_DYNAMIC_NAME 0x2
399 typedef struct x509_purpose_st {
401 int trust; /* Default trust ID */
403 int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int);
409 # define X509_PURPOSE_SSL_CLIENT 1
410 # define X509_PURPOSE_SSL_SERVER 2
411 # define X509_PURPOSE_NS_SSL_SERVER 3
412 # define X509_PURPOSE_SMIME_SIGN 4
413 # define X509_PURPOSE_SMIME_ENCRYPT 5
414 # define X509_PURPOSE_CRL_SIGN 6
415 # define X509_PURPOSE_ANY 7
416 # define X509_PURPOSE_OCSP_HELPER 8
417 # define X509_PURPOSE_TIMESTAMP_SIGN 9
419 # define X509_PURPOSE_MIN 1
420 # define X509_PURPOSE_MAX 9
422 /* Flags for X509V3_EXT_print() */
424 # define X509V3_EXT_UNKNOWN_MASK (0xfL << 16)
425 /* Return error for unknown extensions */
426 # define X509V3_EXT_DEFAULT 0
427 /* Print error for unknown extensions */
428 # define X509V3_EXT_ERROR_UNKNOWN (1L << 16)
429 /* ASN1 parse unknown extensions */
430 # define X509V3_EXT_PARSE_UNKNOWN (2L << 16)
431 /* BIO_dump unknown extensions */
432 # define X509V3_EXT_DUMP_UNKNOWN (3L << 16)
434 /* Flags for X509V3_add1_i2d */
436 # define X509V3_ADD_OP_MASK 0xfL
437 # define X509V3_ADD_DEFAULT 0L
438 # define X509V3_ADD_APPEND 1L
439 # define X509V3_ADD_REPLACE 2L
440 # define X509V3_ADD_REPLACE_EXISTING 3L
441 # define X509V3_ADD_KEEP_EXISTING 4L
442 # define X509V3_ADD_DELETE 5L
443 # define X509V3_ADD_SILENT 0x10
445 DEFINE_STACK_OF(X509_PURPOSE)
447 DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)
449 DECLARE_ASN1_FUNCTIONS(SXNET)
450 DECLARE_ASN1_FUNCTIONS(SXNETID)
452 int SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userlen);
453 int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user,
455 int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, const char *user,
458 ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, const char *zone);
459 ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);
460 ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);
462 DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)
464 DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)
466 DECLARE_ASN1_FUNCTIONS(GENERAL_NAME)
467 GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);
468 int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);
470 ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
472 STACK_OF(CONF_VALUE) *nval);
473 STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
474 ASN1_BIT_STRING *bits,
475 STACK_OF(CONF_VALUE) *extlist);
476 char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5);
477 ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
478 X509V3_CTX *ctx, const char *str);
480 STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,
482 STACK_OF(CONF_VALUE) *ret);
483 int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);
485 DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)
487 STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
489 STACK_OF(CONF_VALUE) *extlist);
490 GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,
491 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
493 DECLARE_ASN1_FUNCTIONS(OTHERNAME)
494 DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)
495 int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);
496 void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value);
497 void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype);
498 int GENERAL_NAME_set0_othername(GENERAL_NAME *gen,
499 ASN1_OBJECT *oid, ASN1_TYPE *value);
500 int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen,
501 ASN1_OBJECT **poid, ASN1_TYPE **pvalue);
503 char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
504 const ASN1_OCTET_STRING *ia5);
505 ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
506 X509V3_CTX *ctx, const char *str);
508 DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)
509 int i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION *a);
511 DECLARE_ASN1_ALLOC_FUNCTIONS(TLS_FEATURE)
513 DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)
514 DECLARE_ASN1_FUNCTIONS(POLICYINFO)
515 DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)
516 DECLARE_ASN1_FUNCTIONS(USERNOTICE)
517 DECLARE_ASN1_FUNCTIONS(NOTICEREF)
519 DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)
520 DECLARE_ASN1_FUNCTIONS(DIST_POINT)
521 DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)
522 DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)
524 int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);
526 int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);
527 int NAME_CONSTRAINTS_check_CN(X509 *x, NAME_CONSTRAINTS *nc);
529 DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
530 DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)
532 DECLARE_ASN1_ITEM(POLICY_MAPPING)
533 DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)
534 DECLARE_ASN1_ITEM(POLICY_MAPPINGS)
536 DECLARE_ASN1_ITEM(GENERAL_SUBTREE)
537 DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)
539 DECLARE_ASN1_ITEM(NAME_CONSTRAINTS)
540 DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)
542 DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)
543 DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)
545 GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
546 const X509V3_EXT_METHOD *method,
547 X509V3_CTX *ctx, int gen_type,
548 const char *value, int is_nc);
550 # ifdef HEADER_CONF_H
551 GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method,
552 X509V3_CTX *ctx, CONF_VALUE *cnf);
553 GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
554 const X509V3_EXT_METHOD *method,
555 X509V3_CTX *ctx, CONF_VALUE *cnf,
557 void X509V3_conf_free(CONF_VALUE *val);
559 X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,
561 X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name,
563 int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section,
564 STACK_OF(X509_EXTENSION) **sk);
565 int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,
567 int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,
569 int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,
572 X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf,
573 X509V3_CTX *ctx, int ext_nid,
575 X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
576 const char *name, const char *value);
577 int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
578 const char *section, X509 *cert);
579 int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
580 const char *section, X509_REQ *req);
581 int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
582 const char *section, X509_CRL *crl);
584 int X509V3_add_value_bool_nf(const char *name, int asn1_bool,
585 STACK_OF(CONF_VALUE) **extlist);
586 int X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool);
587 int X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint);
588 void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);
589 void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);
592 char *X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section);
593 STACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, const char *section);
594 void X509V3_string_free(X509V3_CTX *ctx, char *str);
595 void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section);
596 void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,
597 X509_REQ *req, X509_CRL *crl, int flags);
599 int X509V3_add_value(const char *name, const char *value,
600 STACK_OF(CONF_VALUE) **extlist);
601 int X509V3_add_value_uchar(const char *name, const unsigned char *value,
602 STACK_OF(CONF_VALUE) **extlist);
603 int X509V3_add_value_bool(const char *name, int asn1_bool,
604 STACK_OF(CONF_VALUE) **extlist);
605 int X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint,
606 STACK_OF(CONF_VALUE) **extlist);
607 char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const ASN1_INTEGER *aint);
608 ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const char *value);
609 char *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, const ASN1_ENUMERATED *aint);
610 char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth,
611 const ASN1_ENUMERATED *aint);
612 int X509V3_EXT_add(X509V3_EXT_METHOD *ext);
613 int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);
614 int X509V3_EXT_add_alias(int nid_to, int nid_from);
615 void X509V3_EXT_cleanup(void);
617 const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);
618 const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);
619 int X509V3_add_standard_extensions(void);
620 STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);
621 void *X509V3_EXT_d2i(X509_EXTENSION *ext);
622 void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit,
625 X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
626 int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,
627 int crit, unsigned long flags);
629 #if OPENSSL_API_COMPAT < 0x10100000L
630 /* The new declarations are in crypto.h, but the old ones were here. */
631 # define hex_to_string OPENSSL_buf2hexstr
632 # define string_to_hex OPENSSL_hexstr2buf
635 void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
637 int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,
639 #ifndef OPENSSL_NO_STDIO
640 int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
642 int X509V3_extensions_print(BIO *out, const char *title,
643 const STACK_OF(X509_EXTENSION) *exts,
644 unsigned long flag, int indent);
646 int X509_check_ca(X509 *x);
647 int X509_check_purpose(X509 *x, int id, int ca);
648 int X509_supported_extension(X509_EXTENSION *ex);
649 int X509_PURPOSE_set(int *p, int purpose);
650 int X509_check_issued(X509 *issuer, X509 *subject);
651 int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);
652 void X509_set_proxy_flag(X509 *x);
653 void X509_set_proxy_pathlen(X509 *x, long l);
654 long X509_get_proxy_pathlen(X509 *x);
656 uint32_t X509_get_extension_flags(X509 *x);
657 uint32_t X509_get_key_usage(X509 *x);
658 uint32_t X509_get_extended_key_usage(X509 *x);
659 const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x);
661 int X509_PURPOSE_get_count(void);
662 X509_PURPOSE *X509_PURPOSE_get0(int idx);
663 int X509_PURPOSE_get_by_sname(const char *sname);
664 int X509_PURPOSE_get_by_id(int id);
665 int X509_PURPOSE_add(int id, int trust, int flags,
666 int (*ck) (const X509_PURPOSE *, const X509 *, int),
667 const char *name, const char *sname, void *arg);
668 char *X509_PURPOSE_get0_name(const X509_PURPOSE *xp);
669 char *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp);
670 int X509_PURPOSE_get_trust(const X509_PURPOSE *xp);
671 void X509_PURPOSE_cleanup(void);
672 int X509_PURPOSE_get_id(const X509_PURPOSE *);
674 STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);
675 STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);
676 void X509_email_free(STACK_OF(OPENSSL_STRING) *sk);
677 STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);
678 /* Flags for X509_check_* functions */
681 * Always check subject name for host match even if subject alt names present
683 # define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT 0x1
684 /* Disable wildcard matching for dnsName fields and common name. */
685 # define X509_CHECK_FLAG_NO_WILDCARDS 0x2
686 /* Wildcards must not match a partial label. */
687 # define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4
688 /* Allow (non-partial) wildcards to match multiple labels. */
689 # define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8
690 /* Constraint verifier subdomain patterns to match a single labels. */
691 # define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10
692 /* Never check the subject CN */
693 # define X509_CHECK_FLAG_NEVER_CHECK_SUBJECT 0x20
695 * Match reference identifiers starting with "." to any sub-domain.
696 * This is a non-public flag, turned on implicitly when the subject
697 * reference identity is a DNS name.
699 # define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000
701 int X509_check_host(X509 *x, const char *chk, size_t chklen,
702 unsigned int flags, char **peername);
703 int X509_check_email(X509 *x, const char *chk, size_t chklen,
705 int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen,
707 int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags);
709 ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);
710 ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);
711 int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk,
712 unsigned long chtype);
714 void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);
715 DEFINE_STACK_OF(X509_POLICY_NODE)
717 #ifndef OPENSSL_NO_RFC3779
718 typedef struct ASRange_st {
719 ASN1_INTEGER *min, *max;
722 # define ASIdOrRange_id 0
723 # define ASIdOrRange_range 1
725 typedef struct ASIdOrRange_st {
733 typedef STACK_OF(ASIdOrRange) ASIdOrRanges;
734 DEFINE_STACK_OF(ASIdOrRange)
736 # define ASIdentifierChoice_inherit 0
737 # define ASIdentifierChoice_asIdsOrRanges 1
739 typedef struct ASIdentifierChoice_st {
743 ASIdOrRanges *asIdsOrRanges;
745 } ASIdentifierChoice;
747 typedef struct ASIdentifiers_st {
748 ASIdentifierChoice *asnum, *rdi;
751 DECLARE_ASN1_FUNCTIONS(ASRange)
752 DECLARE_ASN1_FUNCTIONS(ASIdOrRange)
753 DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)
754 DECLARE_ASN1_FUNCTIONS(ASIdentifiers)
756 typedef struct IPAddressRange_st {
757 ASN1_BIT_STRING *min, *max;
760 # define IPAddressOrRange_addressPrefix 0
761 # define IPAddressOrRange_addressRange 1
763 typedef struct IPAddressOrRange_st {
766 ASN1_BIT_STRING *addressPrefix;
767 IPAddressRange *addressRange;
771 typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;
772 DEFINE_STACK_OF(IPAddressOrRange)
774 # define IPAddressChoice_inherit 0
775 # define IPAddressChoice_addressesOrRanges 1
777 typedef struct IPAddressChoice_st {
781 IPAddressOrRanges *addressesOrRanges;
785 typedef struct IPAddressFamily_st {
786 ASN1_OCTET_STRING *addressFamily;
787 IPAddressChoice *ipAddressChoice;
790 typedef STACK_OF(IPAddressFamily) IPAddrBlocks;
791 DEFINE_STACK_OF(IPAddressFamily)
793 DECLARE_ASN1_FUNCTIONS(IPAddressRange)
794 DECLARE_ASN1_FUNCTIONS(IPAddressOrRange)
795 DECLARE_ASN1_FUNCTIONS(IPAddressChoice)
796 DECLARE_ASN1_FUNCTIONS(IPAddressFamily)
799 * API tag for elements of the ASIdentifer SEQUENCE.
801 # define V3_ASID_ASNUM 0
802 # define V3_ASID_RDI 1
805 * AFI values, assigned by IANA. It'd be nice to make the AFI
806 * handling code totally generic, but there are too many little things
807 * that would need to be defined for other address families for it to
808 * be worth the trouble.
810 # define IANA_AFI_IPV4 1
811 # define IANA_AFI_IPV6 2
814 * Utilities to construct and extract values from RFC3779 extensions,
815 * since some of the encodings (particularly for IP address prefixes
816 * and ranges) are a bit tedious to work with directly.
818 int X509v3_asid_add_inherit(ASIdentifiers *asid, int which);
819 int X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which,
820 ASN1_INTEGER *min, ASN1_INTEGER *max);
821 int X509v3_addr_add_inherit(IPAddrBlocks *addr,
822 const unsigned afi, const unsigned *safi);
823 int X509v3_addr_add_prefix(IPAddrBlocks *addr,
824 const unsigned afi, const unsigned *safi,
825 unsigned char *a, const int prefixlen);
826 int X509v3_addr_add_range(IPAddrBlocks *addr,
827 const unsigned afi, const unsigned *safi,
828 unsigned char *min, unsigned char *max);
829 unsigned X509v3_addr_get_afi(const IPAddressFamily *f);
830 int X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,
831 unsigned char *min, unsigned char *max,
837 int X509v3_asid_is_canonical(ASIdentifiers *asid);
838 int X509v3_addr_is_canonical(IPAddrBlocks *addr);
839 int X509v3_asid_canonize(ASIdentifiers *asid);
840 int X509v3_addr_canonize(IPAddrBlocks *addr);
843 * Tests for inheritance and containment.
845 int X509v3_asid_inherits(ASIdentifiers *asid);
846 int X509v3_addr_inherits(IPAddrBlocks *addr);
847 int X509v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b);
848 int X509v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b);
851 * Check whether RFC 3779 extensions nest properly in chains.
853 int X509v3_asid_validate_path(X509_STORE_CTX *);
854 int X509v3_addr_validate_path(X509_STORE_CTX *);
855 int X509v3_asid_validate_resource_set(STACK_OF(X509) *chain,
857 int allow_inheritance);
858 int X509v3_addr_validate_resource_set(STACK_OF(X509) *chain,
859 IPAddrBlocks *ext, int allow_inheritance);
861 #endif /* OPENSSL_NO_RFC3779 */
863 /* BEGIN ERROR CODES */
865 * The following lines are auto generated by the script mkerr.pl. Any changes
866 * made after this point may be overwritten when the script is next run.
869 int ERR_load_X509V3_strings(void);
871 /* Error codes for the X509V3 functions. */
873 /* Function codes. */
874 # define X509V3_F_A2I_GENERAL_NAME 164
875 # define X509V3_F_ADDR_VALIDATE_PATH_INTERNAL 166
876 # define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 161
877 # define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 162
878 # define X509V3_F_COPY_EMAIL 122
879 # define X509V3_F_COPY_ISSUER 123
880 # define X509V3_F_DO_DIRNAME 144
881 # define X509V3_F_DO_EXT_I2D 135
882 # define X509V3_F_DO_EXT_NCONF 151
883 # define X509V3_F_GNAMES_FROM_SECTNAME 156
884 # define X509V3_F_I2S_ASN1_ENUMERATED 121
885 # define X509V3_F_I2S_ASN1_IA5STRING 149
886 # define X509V3_F_I2S_ASN1_INTEGER 120
887 # define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138
888 # define X509V3_F_NOTICE_SECTION 132
889 # define X509V3_F_NREF_NOS 133
890 # define X509V3_F_POLICY_SECTION 131
891 # define X509V3_F_PROCESS_PCI_VALUE 150
892 # define X509V3_F_R2I_CERTPOL 130
893 # define X509V3_F_R2I_PCI 155
894 # define X509V3_F_S2I_ASN1_IA5STRING 100
895 # define X509V3_F_S2I_ASN1_INTEGER 108
896 # define X509V3_F_S2I_ASN1_OCTET_STRING 112
897 # define X509V3_F_S2I_SKEY_ID 115
898 # define X509V3_F_SET_DIST_POINT_NAME 158
899 # define X509V3_F_SXNET_ADD_ID_ASC 125
900 # define X509V3_F_SXNET_ADD_ID_INTEGER 126
901 # define X509V3_F_SXNET_ADD_ID_ULONG 127
902 # define X509V3_F_SXNET_GET_ID_ASC 128
903 # define X509V3_F_SXNET_GET_ID_ULONG 129
904 # define X509V3_F_V2I_ASIDENTIFIERS 163
905 # define X509V3_F_V2I_ASN1_BIT_STRING 101
906 # define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139
907 # define X509V3_F_V2I_AUTHORITY_KEYID 119
908 # define X509V3_F_V2I_BASIC_CONSTRAINTS 102
909 # define X509V3_F_V2I_CRLD 134
910 # define X509V3_F_V2I_EXTENDED_KEY_USAGE 103
911 # define X509V3_F_V2I_GENERAL_NAMES 118
912 # define X509V3_F_V2I_GENERAL_NAME_EX 117
913 # define X509V3_F_V2I_IDP 157
914 # define X509V3_F_V2I_IPADDRBLOCKS 159
915 # define X509V3_F_V2I_ISSUER_ALT 153
916 # define X509V3_F_V2I_NAME_CONSTRAINTS 147
917 # define X509V3_F_V2I_POLICY_CONSTRAINTS 146
918 # define X509V3_F_V2I_POLICY_MAPPINGS 145
919 # define X509V3_F_V2I_SUBJECT_ALT 154
920 # define X509V3_F_V2I_TLS_FEATURE 165
921 # define X509V3_F_V3_GENERIC_EXTENSION 116
922 # define X509V3_F_X509V3_ADD1_I2D 140
923 # define X509V3_F_X509V3_ADD_VALUE 105
924 # define X509V3_F_X509V3_EXT_ADD 104
925 # define X509V3_F_X509V3_EXT_ADD_ALIAS 106
926 # define X509V3_F_X509V3_EXT_I2D 136
927 # define X509V3_F_X509V3_EXT_NCONF 152
928 # define X509V3_F_X509V3_GET_SECTION 142
929 # define X509V3_F_X509V3_GET_STRING 143
930 # define X509V3_F_X509V3_GET_VALUE_BOOL 110
931 # define X509V3_F_X509V3_PARSE_LIST 109
932 # define X509V3_F_X509_PURPOSE_ADD 137
933 # define X509V3_F_X509_PURPOSE_SET 141
936 # define X509V3_R_BAD_IP_ADDRESS 118
937 # define X509V3_R_BAD_OBJECT 119
938 # define X509V3_R_BN_DEC2BN_ERROR 100
939 # define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101
940 # define X509V3_R_DIRNAME_ERROR 149
941 # define X509V3_R_DISTPOINT_ALREADY_SET 160
942 # define X509V3_R_DUPLICATE_ZONE_ID 133
943 # define X509V3_R_ERROR_CONVERTING_ZONE 131
944 # define X509V3_R_ERROR_CREATING_EXTENSION 144
945 # define X509V3_R_ERROR_IN_EXTENSION 128
946 # define X509V3_R_EXPECTED_A_SECTION_NAME 137
947 # define X509V3_R_EXTENSION_EXISTS 145
948 # define X509V3_R_EXTENSION_NAME_ERROR 115
949 # define X509V3_R_EXTENSION_NOT_FOUND 102
950 # define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103
951 # define X509V3_R_EXTENSION_VALUE_ERROR 116
952 # define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151
953 # define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152
954 # define X509V3_R_INVALID_ASNUMBER 162
955 # define X509V3_R_INVALID_ASRANGE 163
956 # define X509V3_R_INVALID_BOOLEAN_STRING 104
957 # define X509V3_R_INVALID_EXTENSION_STRING 105
958 # define X509V3_R_INVALID_INHERITANCE 165
959 # define X509V3_R_INVALID_IPADDRESS 166
960 # define X509V3_R_INVALID_MULTIPLE_RDNS 161
961 # define X509V3_R_INVALID_NAME 106
962 # define X509V3_R_INVALID_NULL_ARGUMENT 107
963 # define X509V3_R_INVALID_NULL_NAME 108
964 # define X509V3_R_INVALID_NULL_VALUE 109
965 # define X509V3_R_INVALID_NUMBER 140
966 # define X509V3_R_INVALID_NUMBERS 141
967 # define X509V3_R_INVALID_OBJECT_IDENTIFIER 110
968 # define X509V3_R_INVALID_OPTION 138
969 # define X509V3_R_INVALID_POLICY_IDENTIFIER 134
970 # define X509V3_R_INVALID_PROXY_POLICY_SETTING 153
971 # define X509V3_R_INVALID_PURPOSE 146
972 # define X509V3_R_INVALID_SAFI 164
973 # define X509V3_R_INVALID_SECTION 135
974 # define X509V3_R_INVALID_SYNTAX 143
975 # define X509V3_R_ISSUER_DECODE_ERROR 126
976 # define X509V3_R_MISSING_VALUE 124
977 # define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142
978 # define X509V3_R_NO_CONFIG_DATABASE 136
979 # define X509V3_R_NO_ISSUER_CERTIFICATE 121
980 # define X509V3_R_NO_ISSUER_DETAILS 127
981 # define X509V3_R_NO_POLICY_IDENTIFIER 139
982 # define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 154
983 # define X509V3_R_NO_PUBLIC_KEY 114
984 # define X509V3_R_NO_SUBJECT_DETAILS 125
985 # define X509V3_R_OPERATION_NOT_DEFINED 148
986 # define X509V3_R_OTHERNAME_ERROR 147
987 # define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED 155
988 # define X509V3_R_POLICY_PATH_LENGTH 156
989 # define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED 157
990 # define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159
991 # define X509V3_R_SECTION_NOT_FOUND 150
992 # define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122
993 # define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123
994 # define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111
995 # define X509V3_R_UNKNOWN_EXTENSION 129
996 # define X509V3_R_UNKNOWN_EXTENSION_NAME 130
997 # define X509V3_R_UNKNOWN_OPTION 120
998 # define X509V3_R_UNSUPPORTED_OPTION 117
999 # define X509V3_R_UNSUPPORTED_TYPE 167
1000 # define X509V3_R_USER_TOO_LONG 132