blob: 5b98441bec5e06d3724ae9e9831689f79ad0f3a8 [file] [log] [blame]
Adam Langley95c29f32014-06-20 12:00:00 -07001/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
2 * project 1999. */
3/* ====================================================================
4 * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * 3. All advertising materials mentioning features or use of this
19 * software must display the following acknowledgment:
20 * "This product includes software developed by the OpenSSL Project
21 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
22 *
23 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
24 * endorse or promote products derived from this software without
25 * prior written permission. For written permission, please contact
26 * licensing@OpenSSL.org.
27 *
28 * 5. Products derived from this software may not be called "OpenSSL"
29 * nor may "OpenSSL" appear in their names without prior written
30 * permission of the OpenSSL Project.
31 *
32 * 6. Redistributions of any form whatsoever must retain the following
33 * acknowledgment:
34 * "This product includes software developed by the OpenSSL Project
35 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
38 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 * OF THE POSSIBILITY OF SUCH DAMAGE.
49 * ====================================================================
50 *
51 * This product includes cryptographic software written by Eric Young
52 * (eay@cryptsoft.com). This product includes software written by Tim
53 * Hudson (tjh@cryptsoft.com). */
54
55#ifndef HEADER_X509V3_H
56#define HEADER_X509V3_H
57
58#include <openssl/bio.h>
59#include <openssl/conf.h>
60#include <openssl/x509.h>
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66/* Forward reference */
67struct v3_ext_method;
68struct v3_ext_ctx;
69
70/* Useful typedefs */
71
72typedef void * (*X509V3_EXT_NEW)(void);
73typedef void (*X509V3_EXT_FREE)(void *);
74typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long);
75typedef int (*X509V3_EXT_I2D)(void *, unsigned char **);
76typedef STACK_OF(CONF_VALUE) *
77 (*X509V3_EXT_I2V)(const struct v3_ext_method *method, void *ext,
78 STACK_OF(CONF_VALUE) *extlist);
79typedef void * (*X509V3_EXT_V2I)(const struct v3_ext_method *method,
80 struct v3_ext_ctx *ctx,
81 STACK_OF(CONF_VALUE) *values);
82typedef char * (*X509V3_EXT_I2S)(const struct v3_ext_method *method, void *ext);
83typedef void * (*X509V3_EXT_S2I)(const struct v3_ext_method *method,
84 struct v3_ext_ctx *ctx, const char *str);
85typedef int (*X509V3_EXT_I2R)(const struct v3_ext_method *method, void *ext,
86 BIO *out, int indent);
87typedef void * (*X509V3_EXT_R2I)(const struct v3_ext_method *method,
88 struct v3_ext_ctx *ctx, const char *str);
89
90/* V3 extension structure */
91
92struct v3_ext_method {
93int ext_nid;
94int ext_flags;
95/* If this is set the following four fields are ignored */
96ASN1_ITEM_EXP *it;
97/* Old style ASN1 calls */
98X509V3_EXT_NEW ext_new;
99X509V3_EXT_FREE ext_free;
100X509V3_EXT_D2I d2i;
101X509V3_EXT_I2D i2d;
102
103/* The following pair is used for string extensions */
104X509V3_EXT_I2S i2s;
105X509V3_EXT_S2I s2i;
106
107/* The following pair is used for multi-valued extensions */
108X509V3_EXT_I2V i2v;
109X509V3_EXT_V2I v2i;
110
111/* The following are used for raw extensions */
112X509V3_EXT_I2R i2r;
113X509V3_EXT_R2I r2i;
114
115void *usr_data; /* Any extension specific data */
116};
117
118typedef struct X509V3_CONF_METHOD_st {
119char * (*get_string)(void *db, char *section, char *value);
120STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section);
121void (*free_string)(void *db, char * string);
122void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section);
123} X509V3_CONF_METHOD;
124
125/* Context specific info */
126struct v3_ext_ctx {
127#define CTX_TEST 0x1
128int flags;
129X509 *issuer_cert;
130X509 *subject_cert;
131X509_REQ *subject_req;
132X509_CRL *crl;
133X509V3_CONF_METHOD *db_meth;
134void *db;
135/* Maybe more here */
136};
137
138typedef struct v3_ext_method X509V3_EXT_METHOD;
139
140DECLARE_STACK_OF(X509V3_EXT_METHOD)
141
142/* ext_flags values */
143#define X509V3_EXT_DYNAMIC 0x1
144#define X509V3_EXT_CTX_DEP 0x2
145#define X509V3_EXT_MULTILINE 0x4
146
147typedef BIT_STRING_BITNAME ENUMERATED_NAMES;
148
149typedef struct BASIC_CONSTRAINTS_st {
150int ca;
151ASN1_INTEGER *pathlen;
152} BASIC_CONSTRAINTS;
153
154
155typedef struct PKEY_USAGE_PERIOD_st {
156ASN1_GENERALIZEDTIME *notBefore;
157ASN1_GENERALIZEDTIME *notAfter;
158} PKEY_USAGE_PERIOD;
159
160typedef struct otherName_st {
161ASN1_OBJECT *type_id;
162ASN1_TYPE *value;
163} OTHERNAME;
164
165typedef struct EDIPartyName_st {
166 ASN1_STRING *nameAssigner;
167 ASN1_STRING *partyName;
168} EDIPARTYNAME;
169
170typedef struct GENERAL_NAME_st {
171
172#define GEN_OTHERNAME 0
173#define GEN_EMAIL 1
174#define GEN_DNS 2
175#define GEN_X400 3
176#define GEN_DIRNAME 4
177#define GEN_EDIPARTY 5
178#define GEN_URI 6
179#define GEN_IPADD 7
180#define GEN_RID 8
181
182int type;
183union {
184 char *ptr;
185 OTHERNAME *otherName; /* otherName */
186 ASN1_IA5STRING *rfc822Name;
187 ASN1_IA5STRING *dNSName;
188 ASN1_TYPE *x400Address;
189 X509_NAME *directoryName;
190 EDIPARTYNAME *ediPartyName;
191 ASN1_IA5STRING *uniformResourceIdentifier;
192 ASN1_OCTET_STRING *iPAddress;
193 ASN1_OBJECT *registeredID;
194
195 /* Old names */
196 ASN1_OCTET_STRING *ip; /* iPAddress */
197 X509_NAME *dirn; /* dirn */
198 ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */
199 ASN1_OBJECT *rid; /* registeredID */
200 ASN1_TYPE *other; /* x400Address */
201} d;
202} GENERAL_NAME;
203
204typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;
205
206typedef struct ACCESS_DESCRIPTION_st {
207 ASN1_OBJECT *method;
208 GENERAL_NAME *location;
209} ACCESS_DESCRIPTION;
210
211typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;
212
213typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;
214
215DECLARE_STACK_OF(GENERAL_NAME)
216DECLARE_ASN1_SET_OF(GENERAL_NAME)
217
218DECLARE_STACK_OF(ACCESS_DESCRIPTION)
219DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION)
220
221typedef struct DIST_POINT_NAME_st {
222int type;
223union {
224 GENERAL_NAMES *fullname;
225 STACK_OF(X509_NAME_ENTRY) *relativename;
226} name;
227/* If relativename then this contains the full distribution point name */
228X509_NAME *dpname;
229} DIST_POINT_NAME;
230/* All existing reasons */
231#define CRLDP_ALL_REASONS 0x807f
232
233#define CRL_REASON_NONE -1
234#define CRL_REASON_UNSPECIFIED 0
235#define CRL_REASON_KEY_COMPROMISE 1
236#define CRL_REASON_CA_COMPROMISE 2
237#define CRL_REASON_AFFILIATION_CHANGED 3
238#define CRL_REASON_SUPERSEDED 4
239#define CRL_REASON_CESSATION_OF_OPERATION 5
240#define CRL_REASON_CERTIFICATE_HOLD 6
241#define CRL_REASON_REMOVE_FROM_CRL 8
242#define CRL_REASON_PRIVILEGE_WITHDRAWN 9
243#define CRL_REASON_AA_COMPROMISE 10
244
245struct DIST_POINT_st {
246DIST_POINT_NAME *distpoint;
247ASN1_BIT_STRING *reasons;
248GENERAL_NAMES *CRLissuer;
249int dp_reasons;
250};
251
252typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;
253
254DECLARE_STACK_OF(DIST_POINT)
255DECLARE_ASN1_SET_OF(DIST_POINT)
256
257struct AUTHORITY_KEYID_st {
258ASN1_OCTET_STRING *keyid;
259GENERAL_NAMES *issuer;
260ASN1_INTEGER *serial;
261};
262
263/* Strong extranet structures */
264
265typedef struct SXNET_ID_st {
266 ASN1_INTEGER *zone;
267 ASN1_OCTET_STRING *user;
268} SXNETID;
269
270DECLARE_STACK_OF(SXNETID)
271DECLARE_ASN1_SET_OF(SXNETID)
272
273typedef struct SXNET_st {
274 ASN1_INTEGER *version;
275 STACK_OF(SXNETID) *ids;
276} SXNET;
277
278typedef struct NOTICEREF_st {
279 ASN1_STRING *organization;
280 STACK_OF(ASN1_INTEGER) *noticenos;
281} NOTICEREF;
282
283typedef struct USERNOTICE_st {
284 NOTICEREF *noticeref;
285 ASN1_STRING *exptext;
286} USERNOTICE;
287
288typedef struct POLICYQUALINFO_st {
289 ASN1_OBJECT *pqualid;
290 union {
291 ASN1_IA5STRING *cpsuri;
292 USERNOTICE *usernotice;
293 ASN1_TYPE *other;
294 } d;
295} POLICYQUALINFO;
296
297DECLARE_STACK_OF(POLICYQUALINFO)
298DECLARE_ASN1_SET_OF(POLICYQUALINFO)
299
300typedef struct POLICYINFO_st {
301 ASN1_OBJECT *policyid;
302 STACK_OF(POLICYQUALINFO) *qualifiers;
303} POLICYINFO;
304
305typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;
306
307DECLARE_STACK_OF(POLICYINFO)
308DECLARE_ASN1_SET_OF(POLICYINFO)
309
310typedef struct POLICY_MAPPING_st {
311 ASN1_OBJECT *issuerDomainPolicy;
312 ASN1_OBJECT *subjectDomainPolicy;
313} POLICY_MAPPING;
314
315DECLARE_STACK_OF(POLICY_MAPPING)
316
317typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;
318
319typedef struct GENERAL_SUBTREE_st {
320 GENERAL_NAME *base;
321 ASN1_INTEGER *minimum;
322 ASN1_INTEGER *maximum;
323} GENERAL_SUBTREE;
324
325DECLARE_STACK_OF(GENERAL_SUBTREE)
326
327struct NAME_CONSTRAINTS_st {
328 STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;
329 STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;
330};
331
332typedef struct POLICY_CONSTRAINTS_st {
333 ASN1_INTEGER *requireExplicitPolicy;
334 ASN1_INTEGER *inhibitPolicyMapping;
335} POLICY_CONSTRAINTS;
336
337/* Proxy certificate structures, see RFC 3820 */
338typedef struct PROXY_POLICY_st
339 {
340 ASN1_OBJECT *policyLanguage;
341 ASN1_OCTET_STRING *policy;
342 } PROXY_POLICY;
343
344typedef struct PROXY_CERT_INFO_EXTENSION_st
345 {
346 ASN1_INTEGER *pcPathLengthConstraint;
347 PROXY_POLICY *proxyPolicy;
348 } PROXY_CERT_INFO_EXTENSION;
349
350DECLARE_ASN1_FUNCTIONS(PROXY_POLICY)
351DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)
352
353struct ISSUING_DIST_POINT_st
354 {
355 DIST_POINT_NAME *distpoint;
356 int onlyuser;
357 int onlyCA;
358 ASN1_BIT_STRING *onlysomereasons;
359 int indirectCRL;
360 int onlyattr;
361 };
362
363/* Values in idp_flags field */
364/* IDP present */
365#define IDP_PRESENT 0x1
366/* IDP values inconsistent */
367#define IDP_INVALID 0x2
368/* onlyuser true */
369#define IDP_ONLYUSER 0x4
370/* onlyCA true */
371#define IDP_ONLYCA 0x8
372/* onlyattr true */
373#define IDP_ONLYATTR 0x10
374/* indirectCRL true */
375#define IDP_INDIRECT 0x20
376/* onlysomereasons present */
377#define IDP_REASONS 0x40
378
379#define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \
380",name:", val->name, ",value:", val->value);
381
382#define X509V3_set_ctx_test(ctx) \
383 X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)
384#define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;
385
386#define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \
387 0,0,0,0, \
388 0,0, \
389 (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \
390 (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \
391 NULL, NULL, \
392 table}
393
394#define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \
395 0,0,0,0, \
396 (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \
397 (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \
398 0,0,0,0, \
399 NULL}
400
401#define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
402
403
404/* X509_PURPOSE stuff */
405
406#define EXFLAG_BCONS 0x1
407#define EXFLAG_KUSAGE 0x2
408#define EXFLAG_XKUSAGE 0x4
409#define EXFLAG_NSCERT 0x8
410
411#define EXFLAG_CA 0x10
412/* Really self issued not necessarily self signed */
413#define EXFLAG_SI 0x20
414#define EXFLAG_SS 0x20
415#define EXFLAG_V1 0x40
416#define EXFLAG_INVALID 0x80
417#define EXFLAG_SET 0x100
418#define EXFLAG_CRITICAL 0x200
419#define EXFLAG_PROXY 0x400
420
421#define EXFLAG_INVALID_POLICY 0x800
422#define EXFLAG_FRESHEST 0x1000
423
424#define KU_DIGITAL_SIGNATURE 0x0080
425#define KU_NON_REPUDIATION 0x0040
426#define KU_KEY_ENCIPHERMENT 0x0020
427#define KU_DATA_ENCIPHERMENT 0x0010
428#define KU_KEY_AGREEMENT 0x0008
429#define KU_KEY_CERT_SIGN 0x0004
430#define KU_CRL_SIGN 0x0002
431#define KU_ENCIPHER_ONLY 0x0001
432#define KU_DECIPHER_ONLY 0x8000
433
434#define NS_SSL_CLIENT 0x80
435#define NS_SSL_SERVER 0x40
436#define NS_SMIME 0x20
437#define NS_OBJSIGN 0x10
438#define NS_SSL_CA 0x04
439#define NS_SMIME_CA 0x02
440#define NS_OBJSIGN_CA 0x01
441#define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)
442
443#define XKU_SSL_SERVER 0x1
444#define XKU_SSL_CLIENT 0x2
445#define XKU_SMIME 0x4
446#define XKU_CODE_SIGN 0x8
447#define XKU_SGC 0x10
448#define XKU_OCSP_SIGN 0x20
449#define XKU_TIMESTAMP 0x40
450#define XKU_DVCS 0x80
451#define XKU_ANYEKU 0x100
452
453#define X509_PURPOSE_DYNAMIC 0x1
454#define X509_PURPOSE_DYNAMIC_NAME 0x2
455
456typedef struct x509_purpose_st {
457 int purpose;
458 int trust; /* Default trust ID */
459 int flags;
460 int (*check_purpose)(const struct x509_purpose_st *,
461 const X509 *, int);
462 char *name;
463 char *sname;
464 void *usr_data;
465} X509_PURPOSE;
466
467#define X509_PURPOSE_SSL_CLIENT 1
468#define X509_PURPOSE_SSL_SERVER 2
469#define X509_PURPOSE_NS_SSL_SERVER 3
470#define X509_PURPOSE_SMIME_SIGN 4
471#define X509_PURPOSE_SMIME_ENCRYPT 5
472#define X509_PURPOSE_CRL_SIGN 6
473#define X509_PURPOSE_ANY 7
474#define X509_PURPOSE_OCSP_HELPER 8
475#define X509_PURPOSE_TIMESTAMP_SIGN 9
476
477#define X509_PURPOSE_MIN 1
478#define X509_PURPOSE_MAX 9
479
480/* Flags for X509V3_EXT_print() */
481
482#define X509V3_EXT_UNKNOWN_MASK (0xfL << 16)
483/* Return error for unknown extensions */
484#define X509V3_EXT_DEFAULT 0
485/* Print error for unknown extensions */
486#define X509V3_EXT_ERROR_UNKNOWN (1L << 16)
487/* ASN1 parse unknown extensions */
488#define X509V3_EXT_PARSE_UNKNOWN (2L << 16)
489/* BIO_dump unknown extensions */
490#define X509V3_EXT_DUMP_UNKNOWN (3L << 16)
491
492/* Flags for X509V3_add1_i2d */
493
494#define X509V3_ADD_OP_MASK 0xfL
495#define X509V3_ADD_DEFAULT 0L
496#define X509V3_ADD_APPEND 1L
497#define X509V3_ADD_REPLACE 2L
498#define X509V3_ADD_REPLACE_EXISTING 3L
499#define X509V3_ADD_KEEP_EXISTING 4L
500#define X509V3_ADD_DELETE 5L
501#define X509V3_ADD_SILENT 0x10
502
503DECLARE_STACK_OF(X509_PURPOSE)
504
505DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)
506
507DECLARE_ASN1_FUNCTIONS(SXNET)
508DECLARE_ASN1_FUNCTIONS(SXNETID)
509
510int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen);
511int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen);
512int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen);
513
514ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone);
515ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);
516ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);
517
518DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)
519
520DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)
521
522DECLARE_ASN1_FUNCTIONS(GENERAL_NAME)
523GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);
524int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);
525
526
527
528ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
529 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
530STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
531 ASN1_BIT_STRING *bits,
532 STACK_OF(CONF_VALUE) *extlist);
533
534STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret);
535int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);
536
537DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)
538
539STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
540 GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist);
541GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,
542 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
543
544DECLARE_ASN1_FUNCTIONS(OTHERNAME)
545DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)
546int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);
547void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value);
548void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype);
549int GENERAL_NAME_set0_othername(GENERAL_NAME *gen,
550 ASN1_OBJECT *oid, ASN1_TYPE *value);
551int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen,
552 ASN1_OBJECT **poid, ASN1_TYPE **pvalue);
553
554char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5);
555ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str);
556
557DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)
558int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a);
559
560DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)
561DECLARE_ASN1_FUNCTIONS(POLICYINFO)
562DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)
563DECLARE_ASN1_FUNCTIONS(USERNOTICE)
564DECLARE_ASN1_FUNCTIONS(NOTICEREF)
565
566DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)
567DECLARE_ASN1_FUNCTIONS(DIST_POINT)
568DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)
569DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)
570
571int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);
572
573int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);
574
575DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
576DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)
577
578DECLARE_ASN1_ITEM(POLICY_MAPPING)
579DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)
580DECLARE_ASN1_ITEM(POLICY_MAPPINGS)
581
582DECLARE_ASN1_ITEM(GENERAL_SUBTREE)
583DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)
584
585DECLARE_ASN1_ITEM(NAME_CONSTRAINTS)
586DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)
587
588DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)
589DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)
590
591GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
592 const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
593 int gen_type, char *value, int is_nc);
594
595GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
596 CONF_VALUE *cnf);
597GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
598 const X509V3_EXT_METHOD *method,
599 X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc);
600void X509V3_conf_free(CONF_VALUE *val);
601
602X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value);
603X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value);
604int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk);
605int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert);
606int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
607int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);
608
609X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
610 int ext_nid, char *value);
611X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
612 char *name, char *value);
613int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
614 char *section, X509 *cert);
615int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
616 char *section, X509_REQ *req);
617int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
618 char *section, X509_CRL *crl);
619
620int X509V3_add_value_bool_nf(char *name, int asn1_bool,
621 STACK_OF(CONF_VALUE) **extlist);
622int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);
623int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);
624void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);
625void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);
626
627char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section);
628STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section);
629void X509V3_string_free(X509V3_CTX *ctx, char *str);
630void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section);
631void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,
632 X509_REQ *req, X509_CRL *crl, int flags);
633
634int X509V3_add_value(const char *name, const char *value,
635 STACK_OF(CONF_VALUE) **extlist);
636int X509V3_add_value_uchar(const char *name, const unsigned char *value,
637 STACK_OF(CONF_VALUE) **extlist);
638int X509V3_add_value_bool(const char *name, int asn1_bool,
639 STACK_OF(CONF_VALUE) **extlist);
640int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint,
641 STACK_OF(CONF_VALUE) **extlist);
642char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint);
643ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value);
644char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint);
645char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint);
646int X509V3_EXT_add(X509V3_EXT_METHOD *ext);
647int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);
648int X509V3_EXT_add_alias(int nid_to, int nid_from);
649void X509V3_EXT_cleanup(void);
650
651const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);
652const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);
653int X509V3_add_standard_extensions(void);
654STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);
655void *X509V3_EXT_d2i(X509_EXTENSION *ext);
656void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx);
657
658
659X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
660int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags);
661
662char *hex_to_string(const unsigned char *buffer, long len);
663unsigned char *string_to_hex(const char *str, long *len);
664int name_cmp(const char *name, const char *cmp);
665
666void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
667 int ml);
668int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent);
669int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
670
Adam Langley73510762014-06-20 12:00:00 -0700671int X509V3_extensions_print(BIO *out, const char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent);
Adam Langley95c29f32014-06-20 12:00:00 -0700672
673int X509_check_ca(X509 *x);
674int X509_check_purpose(X509 *x, int id, int ca);
675int X509_supported_extension(X509_EXTENSION *ex);
676int X509_PURPOSE_set(int *p, int purpose);
677int X509_check_issued(X509 *issuer, X509 *subject);
678int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);
679int X509_PURPOSE_get_count(void);
680X509_PURPOSE * X509_PURPOSE_get0(int idx);
681int X509_PURPOSE_get_by_sname(char *sname);
682int X509_PURPOSE_get_by_id(int id);
683int X509_PURPOSE_add(int id, int trust, int flags,
684 int (*ck)(const X509_PURPOSE *, const X509 *, int),
685 char *name, char *sname, void *arg);
686char *X509_PURPOSE_get0_name(X509_PURPOSE *xp);
687char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp);
688int X509_PURPOSE_get_trust(X509_PURPOSE *xp);
689void X509_PURPOSE_cleanup(void);
690int X509_PURPOSE_get_id(X509_PURPOSE *);
691
692STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);
693STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);
694void X509_email_free(STACK_OF(OPENSSL_STRING) *sk);
695STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);
696/* Flags for X509_check_* functions */
697
698/* Always check subject name for host match even if subject alt names present */
699#define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT 0x1
700/* Disable wild-card matching for dnsName fields and common name. */
701#define X509_CHECK_FLAG_NO_WILDCARDS 0x2
702
703int X509_check_host(X509 *x, const unsigned char *chk, size_t chklen,
704 unsigned int flags);
705int X509_check_email(X509 *x, const unsigned char *chk, size_t chklen,
706 unsigned int flags);
707int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen,
708 unsigned int flags);
709int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags);
710
711ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);
712ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);
713int a2i_ipadd(unsigned char *ipout, const char *ipasc);
714int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk,
715 unsigned long chtype);
716
717void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);
718DECLARE_STACK_OF(X509_POLICY_NODE)
719
720/* BEGIN ERROR CODES */
721/* The following lines are auto generated by the script mkerr.pl. Any changes
722 * made after this point may be overwritten when the script is next run.
723 */
724void ERR_load_X509V3_strings(void);
725
726
727#ifdef __cplusplus
728}
729#endif
730#define X509V3_F_do_ext_i2d 100
731#define X509V3_F_v2i_AUTHORITY_KEYID 101
732#define X509V3_F_X509V3_parse_list 102
733#define X509V3_F_SXNET_add_id_asc 103
734#define X509V3_F_SXNET_get_id_ulong 104
735#define X509V3_F_v2i_AUTHORITY_INFO_ACCESS 105
736#define X509V3_F_X509V3_EXT_add 106
737#define X509V3_F_i2s_ASN1_INTEGER 107
738#define X509V3_F_s2i_ASN1_OCTET_STRING 108
739#define X509V3_F_copy_issuer 109
740#define X509V3_F_v2i_subject_alt 110
741#define X509V3_F_copy_email 111
742#define X509V3_F_X509V3_EXT_i2d 112
743#define X509V3_F_v2i_crld 113
744#define X509V3_F_policy_section 114
745#define X509V3_F_a2i_GENERAL_NAME 115
746#define X509V3_F_hex_to_string 116
747#define X509V3_F_i2s_ASN1_IA5STRING 117
748#define X509V3_F_string_to_hex 118
749#define X509V3_F_v3_generic_extension 119
750#define X509V3_F_X509V3_get_section 120
751#define X509V3_F_s2i_skey_id 121
752#define X509V3_F_nref_nos 122
753#define X509V3_F_X509V3_get_value_bool 123
754#define X509V3_F_v2i_NAME_CONSTRAINTS 124
755#define X509V3_F_v2i_POLICY_MAPPINGS 125
756#define X509V3_F_v2i_GENERAL_NAMES 126
757#define X509V3_F_do_dirname 127
758#define X509V3_F_v2i_ASN1_BIT_STRING 128
759#define X509V3_F_SXNET_add_id_ulong 129
760#define X509V3_F_X509V3_EXT_add_alias 130
761#define X509V3_F_X509V3_add1_i2d 131
762#define X509V3_F_r2i_pci 132
763#define X509V3_F_X509V3_get_string 133
764#define X509V3_F_gnames_from_sectname 134
765#define X509V3_F_r2i_certpol 135
766#define X509V3_F_X509V3_add_value 136
767#define X509V3_F_s2i_ASN1_INTEGER 137
768#define X509V3_F_v2i_issuer_alt 138
769#define X509V3_F_v2i_GENERAL_NAME_ex 139
770#define X509V3_F_X509V3_EXT_nconf 140
771#define X509V3_F_v2i_BASIC_CONSTRAINTS 141
772#define X509V3_F_process_pci_value 142
773#define X509V3_F_notice_section 143
774#define X509V3_F_X509_PURPOSE_set 144
775#define X509V3_F_do_ext_nconf 145
776#define X509V3_F_i2s_ASN1_ENUMERATED 146
777#define X509V3_F_s2i_ASN1_IA5STRING 147
778#define X509V3_F_v2i_POLICY_CONSTRAINTS 148
779#define X509V3_F_v2i_EXTENDED_KEY_USAGE 149
780#define X509V3_F_SXNET_get_id_asc 150
781#define X509V3_F_set_dist_point_name 151
782#define X509V3_F_v2i_idp 152
783#define X509V3_F_X509_PURPOSE_add 153
784#define X509V3_F_SXNET_add_id_INTEGER 154
785#define X509V3_F_i2v_AUTHORITY_INFO_ACCESS 155
786#define X509V3_R_INVALID_BOOLEAN_STRING 100
787#define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 101
788#define X509V3_R_INVALID_NAME 102
789#define X509V3_R_OPERATION_NOT_DEFINED 103
790#define X509V3_R_POLICY_PATH_LENGTH 104
791#define X509V3_R_INVALID_PROXY_POLICY_SETTING 105
792#define X509V3_R_INVALID_ASRANGE 106
793#define X509V3_R_ERROR_CREATING_EXTENSION 107
794#define X509V3_R_ISSUER_DECODE_ERROR 108
795#define X509V3_R_OTHERNAME_ERROR 109
796#define X509V3_R_ILLEGAL_HEX_DIGIT 110
797#define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 111
798#define X509V3_R_USER_TOO_LONG 112
799#define X509V3_R_INVALID_INHERITANCE 113
800#define X509V3_R_INVALID_SAFI 114
801#define X509V3_R_INVALID_NULL_VALUE 115
802#define X509V3_R_NO_SUBJECT_DETAILS 116
803#define X509V3_R_BAD_OBJECT 117
804#define X509V3_R_DIRNAME_ERROR 118
805#define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 119
806#define X509V3_R_INVALID_EXTENSION_STRING 120
807#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 121
808#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 122
809#define X509V3_R_INVALID_OPTION 123
810#define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 124
811#define X509V3_R_INVALID_POLICY_IDENTIFIER 125
812#define X509V3_R_INVALID_PURPOSE 126
813#define X509V3_R_UNKNOWN_EXTENSION 127
814#define X509V3_R_NO_ISSUER_CERTIFICATE 128
815#define X509V3_R_BN_DEC2BN_ERROR 129
816#define X509V3_R_EXPECTED_A_SECTION_NAME 130
817#define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED 131
818#define X509V3_R_MISSING_VALUE 132
819#define X509V3_R_SECTION_NOT_FOUND 133
820#define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 134
821#define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED 135
822#define X509V3_R_ILLEGAL_EMPTY_EXTENSION 136
823#define X509V3_R_NO_POLICY_IDENTIFIER 137
824#define X509V3_R_NO_ISSUER_DETAILS 138
825#define X509V3_R_NO_CONFIG_DATABASE 139
826#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 140
827#define X509V3_R_INVALID_SECTION 141
828#define X509V3_R_INVALID_IPADDRESS 142
829#define X509V3_R_EXTENSION_VALUE_ERROR 143
830#define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 144
831#define X509V3_R_INVALID_NULL_ARGUMENT 145
832#define X509V3_R_ERROR_IN_EXTENSION 146
833#define X509V3_R_INVALID_NULL_NAME 147
834#define X509V3_R_BAD_IP_ADDRESS 148
835#define X509V3_R_UNSUPPORTED_OPTION 149
836#define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 150
837#define X509V3_R_EXTENSION_EXISTS 151
838#define X509V3_R_UNKNOWN_OPTION 152
839#define X509V3_R_ERROR_CONVERTING_ZONE 153
840#define X509V3_R_NO_PUBLIC_KEY 154
841#define X509V3_R_INVALID_MULTIPLE_RDNS 155
842#define X509V3_R_INVALID_SYNTAX 156
843#define X509V3_R_UNKNOWN_EXTENSION_NAME 157
844#define X509V3_R_ODD_NUMBER_OF_DIGITS 158
845#define X509V3_R_DISTPOINT_ALREADY_SET 159
846#define X509V3_R_UNSUPPORTED_TYPE 160
847#define X509V3_R_EXTENSION_NAME_ERROR 161
848#define X509V3_R_INVALID_NUMBERS 162
849#define X509V3_R_INVALID_NUMBER 163
850#define X509V3_R_INVALID_OBJECT_IDENTIFIER 164
851#define X509V3_R_DUPLICATE_ZONE_ID 165
852#define X509V3_R_EXTENSION_NOT_FOUND 166
853#define X509V3_R_INVALID_ASNUMBER 167
854
855#endif