2 /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
5 /* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
34 * 6. Redistributions of any form whatsoever must retain the following
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
58 #ifndef HEADER_X509V3_H
59 #define HEADER_X509V3_H
68 /* Forward reference */
74 typedef char * (*X509V3_EXT_NEW)();
75 typedef void (*X509V3_EXT_FREE)();
76 typedef char * (*X509V3_EXT_D2I)();
77 typedef int (*X509V3_EXT_I2D)();
78 typedef STACK * (*X509V3_EXT_I2V)(struct v3_ext_method *method, char *ext);
79 typedef char * (*X509V3_EXT_V2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, STACK *values);
80 typedef char * (*X509V3_EXT_I2S)(struct v3_ext_method *method, char *ext);
81 typedef char * (*X509V3_EXT_S2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, char *str);
82 typedef int (*X509V3_EXT_I2R)(struct v3_ext_method *method, char *ext, BIO *out);
84 /* V3 extension structure */
86 struct v3_ext_method {
89 X509V3_EXT_NEW ext_new;
90 X509V3_EXT_FREE ext_free;
94 /* The following pair is used for string extensions */
98 /* The following pair is used for multi-valued extensions */
102 /* The following is used for raw extensions */
105 char *usr_data; /* Any extension specific data */
108 /* Context specific info */
109 struct v3_ctx_struct {
112 X509_REQ *subject_req;
113 /* Maybe more here */
116 typedef struct v3_ext_method X509V3_EXT_METHOD;
117 typedef struct v3_ext_ctx X509V3_CTX;
119 /* ext_flags values */
120 #define X509V3_EXT_DYNAMIC 0x1
126 } BIT_STRING_BITNAME;
130 ASN1_INTEGER *pathlen;
133 #define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \
134 ",name:", val->name, ",value:", val->value);
136 #define EXT_BITSTRING(nid, table) { nid, 0, \
137 (X509V3_EXT_NEW)asn1_bit_string_new, ASN1_STRING_free, \
138 (X509V3_EXT_D2I)d2i_ASN1_BIT_STRING, \
139 i2d_ASN1_BIT_STRING, \
141 (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \
142 (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \
146 #define EXT_IA5STRING(nid) { nid, 0, \
147 (X509V3_EXT_NEW)ia5string_new, ASN1_STRING_free, \
148 (X509V3_EXT_D2I)d2i_ASN1_IA5STRING, \
149 i2d_ASN1_IA5STRING, \
150 (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \
151 (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \
155 #define EXT_END { -1, 0, NULL, NULL, NULL, NULL, NULL, NULL, \
160 void ERR_load_X509V3_strings(void);
161 void ERR_X509V3_error(int function, int reason, char *file, int line);
162 int i2d_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS *a, unsigned char **pp);
163 BASIC_CONSTRAINTS *d2i_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS **a, unsigned char **pp, long length);
164 BASIC_CONSTRAINTS *BASIC_CONSTRAINTS_new(void);
165 void BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *a);
167 int i2d_ext_ku(STACK *a, unsigned char **pp);
168 STACK *d2i_ext_ku(STACK **a, unsigned char **pp, long length);
169 void ext_ku_free(STACK *a);
170 STACK *ext_ku_new(void);
173 void X509V3_conf_free(CONF_VALUE *val);
174 X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value);
175 X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value);
176 int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert);
177 int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);
178 int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);
181 int X509V3_add_value(char *name, char *value, STACK **extlist);
182 int X509V3_add_value_bool(char *name, int asn1_bool, STACK **extlist);
183 int X509V3_add_value_int( char *name, ASN1_INTEGER *aint, STACK **extlist);
184 int X509V3_EXT_add(X509V3_EXT_METHOD *ext);
185 int X509V3_EXT_add_alias(int nid_to, int nid_from);
186 void X509V3_EXT_cleanup(void);
188 X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);
189 X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);
190 int X509V3_add_standard_extensions(void);
191 STACK *X509V3_parse_list(char *line);
193 int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, int flag);
194 int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag);
198 void ERR_load_X509V3_strings();
199 void ERR_X509V3_error();
200 int i2d_BASIC_CONSTRAINTS();
201 BASIC_CONSTRAINTS *d2i_BASIC_CONSTRAINTS();
202 BASIC_CONSTRAINTS *BASIC_CONSTRAINTS_new();
203 void BASIC_CONSTRAINTS_free();
211 void X509V3_conf_free();
212 X509_EXTENSION *X509V3_EXT_conf_nid();
213 X509_EXTENSION *X509V3_EXT_conf();
214 int X509V3_EXT_add_conf();
215 int X509V3_get_value_bool();
216 int X509V3_get_value_int();
219 int X509V3_add_value();
220 int X509V3_add_value_bool();
221 int X509V3_add_value_int();
222 int X509V3_EXT_add();
223 int X509V3_EXT_add_alias();
224 void X509V3_EXT_cleanup();
226 X509V3_EXT_METHOD *X509V3_EXT_get();
227 X509V3_EXT_METHOD *X509V3_EXT_get_nid();
228 int X509V3_add_standard_extensions();
229 STACK *X509V3_parse_list();
231 int X509V3_EXT_print();
232 int X509V3_EXT_print_fp();
235 /* BEGIN ERROR CODES */
236 /* Error codes for the X509V3 functions. */
238 /* Function codes. */
239 #define X509V3_F_S2I_ASN1_IA5STRING 100
240 #define X509V3_F_V2I_ASN1_BIT_STRING 101
241 #define X509V3_F_V2I_BASIC_CONSTRAINTS 102
242 #define X509V3_F_V2I_EXT_KU 103
243 #define X509V3_F_X509V3_ADD_EXT 104
244 #define X509V3_F_X509V3_ADD_VALUE 105
245 #define X509V3_F_X509V3_EXT_ADD_ALIAS 106
246 #define X509V3_F_X509V3_EXT_CONF 107
247 #define X509V3_F_X509V3_GET_VALUE_INT 108
248 #define X509V3_F_X509V3_PARSE_LIST 109
249 #define X509V3_F_X509V3_VALUE_GET_BOOL 110
252 #define X509V3_R_BN_DEC2BN_ERROR 100
253 #define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101
254 #define X509V3_R_EXTENSION_NOT_FOUND 102
255 #define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103
256 #define X509V3_R_INVALID_BOOLEAN_STRING 104
257 #define X509V3_R_INVALID_EXTENSION_STRING 105
258 #define X509V3_R_INVALID_NAME 106
259 #define X509V3_R_INVALID_NULL_ARGUMENT 107
260 #define X509V3_R_INVALID_NULL_NAME 108
261 #define X509V3_R_INVALID_NULL_VALUE 109
262 #define X509V3_R_INVALID_OBJECT_IDENTIFIER 110
263 #define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111