]>
Commit | Line | Data |
---|---|---|
d02b48c6 | 1 | /* crypto/x509/x509.h */ |
58964a49 | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
d02b48c6 RE |
3 | * All rights reserved. |
4 | * | |
5 | * This package is an SSL implementation written | |
6 | * by Eric Young (eay@cryptsoft.com). | |
7 | * The implementation was written so as to conform with Netscapes SSL. | |
8 | * | |
9 | * This library is free for commercial and non-commercial use as long as | |
10 | * the following conditions are aheared to. The following conditions | |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | |
13 | * included with this distribution is covered by the same copyright terms | |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | |
15 | * | |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | |
17 | * the code are not to be removed. | |
18 | * If this package is used in a product, Eric Young should be given attribution | |
19 | * as the author of the parts of the library used. | |
20 | * This can be in the form of a textual message at program startup or | |
21 | * in documentation (online or textual) provided with the package. | |
22 | * | |
23 | * Redistribution and use in source and binary forms, with or without | |
24 | * modification, are permitted provided that the following conditions | |
25 | * are met: | |
26 | * 1. Redistributions of source code must retain the copyright | |
27 | * notice, this list of conditions and the following disclaimer. | |
28 | * 2. Redistributions in binary form must reproduce the above copyright | |
29 | * notice, this list of conditions and the following disclaimer in the | |
30 | * documentation and/or other materials provided with the distribution. | |
31 | * 3. All advertising materials mentioning features or use of this software | |
32 | * must display the following acknowledgement: | |
33 | * "This product includes cryptographic software written by | |
34 | * Eric Young (eay@cryptsoft.com)" | |
35 | * The word 'cryptographic' can be left out if the rouines from the library | |
36 | * being used are not cryptographic related :-). | |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | |
38 | * the apps directory (application code) you must include an acknowledgement: | |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | |
40 | * | |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
51 | * SUCH DAMAGE. | |
52 | * | |
53 | * The licence and distribution terms for any publically available version or | |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | |
55 | * copied and put under another distribution licence | |
56 | * [including the GNU Public Licence.] | |
57 | */ | |
58 | ||
59 | #ifndef HEADER_X509_H | |
60 | #define HEADER_X509_H | |
61 | ||
62 | #ifdef __cplusplus | |
63 | extern "C" { | |
64 | #endif | |
65 | ||
7d7d2cbc UM |
66 | #ifdef VMS |
67 | #undef X509_REVOKED_get_ext_by_critical | |
68 | #define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic | |
69 | #endif | |
70 | ||
ec577822 BM |
71 | #include <openssl/stack.h> |
72 | #include <openssl/asn1.h> | |
73 | #include <openssl/safestack.h> | |
d02b48c6 RE |
74 | |
75 | #ifndef NO_RSA | |
ec577822 | 76 | #include <openssl/rsa.h> |
d02b48c6 RE |
77 | #endif |
78 | ||
79 | #ifndef NO_DSA | |
ec577822 | 80 | #include <openssl/dsa.h> |
d02b48c6 RE |
81 | #endif |
82 | ||
83 | #ifndef NO_DH | |
ec577822 | 84 | #include <openssl/dh.h> |
d02b48c6 RE |
85 | #endif |
86 | ||
ec577822 | 87 | #include <openssl/evp.h> |
d02b48c6 | 88 | |
4b55c2a3 DSH |
89 | |
90 | #ifdef WIN32 | |
91 | /* Under Win32 this is defined in wincrypt.h */ | |
92 | #undef X509_NAME | |
93 | #endif | |
94 | ||
d02b48c6 RE |
95 | #define X509_FILETYPE_PEM 1 |
96 | #define X509_FILETYPE_ASN1 2 | |
97 | #define X509_FILETYPE_DEFAULT 3 | |
98 | ||
58964a49 RE |
99 | #define X509v3_KU_DIGITAL_SIGNATURE 0x0080 |
100 | #define X509v3_KU_NON_REPUDIATION 0x0040 | |
101 | #define X509v3_KU_KEY_ENCIPHERMENT 0x0020 | |
102 | #define X509v3_KU_DATA_ENCIPHERMENT 0x0010 | |
103 | #define X509v3_KU_KEY_AGREEMENT 0x0008 | |
104 | #define X509v3_KU_KEY_CERT_SIGN 0x0004 | |
105 | #define X509v3_KU_CRL_SIGN 0x0002 | |
106 | #define X509v3_KU_ENCIPHER_ONLY 0x0001 | |
107 | #define X509v3_KU_DECIPHER_ONLY 0x8000 | |
108 | #define X509v3_KU_UNDEF 0xffff | |
109 | ||
110 | typedef struct X509_objects_st | |
111 | { | |
112 | int nid; | |
113 | int (*a2i)(); | |
114 | int (*i2a)(); | |
115 | } X509_OBJECTS; | |
116 | ||
d02b48c6 RE |
117 | typedef struct X509_algor_st |
118 | { | |
119 | ASN1_OBJECT *algorithm; | |
120 | ASN1_TYPE *parameter; | |
121 | } X509_ALGOR; | |
122 | ||
426edadf BL |
123 | DECLARE_STACK_OF(X509_ALGOR) |
124 | DECLARE_ASN1_SET_OF(X509_ALGOR) | |
125 | ||
d02b48c6 RE |
126 | typedef struct X509_val_st |
127 | { | |
128 | ASN1_UTCTIME *notBefore; | |
129 | ASN1_UTCTIME *notAfter; | |
130 | } X509_VAL; | |
131 | ||
132 | typedef struct X509_pubkey_st | |
133 | { | |
134 | X509_ALGOR *algor; | |
135 | ASN1_BIT_STRING *public_key; | |
cfdcfede | 136 | EVP_PKEY *pkey; |
d02b48c6 RE |
137 | } X509_PUBKEY; |
138 | ||
139 | typedef struct X509_sig_st | |
140 | { | |
141 | X509_ALGOR *algor; | |
142 | ASN1_OCTET_STRING *digest; | |
143 | } X509_SIG; | |
144 | ||
145 | typedef struct X509_name_entry_st | |
146 | { | |
147 | ASN1_OBJECT *object; | |
148 | ASN1_STRING *value; | |
149 | int set; | |
150 | int size; /* temp variable */ | |
151 | } X509_NAME_ENTRY; | |
152 | ||
65d4927b BL |
153 | DECLARE_STACK_OF(X509_NAME_ENTRY) |
154 | DECLARE_ASN1_SET_OF(X509_NAME_ENTRY) | |
155 | ||
d02b48c6 RE |
156 | /* we always keep X509_NAMEs in 2 forms. */ |
157 | typedef struct X509_name_st | |
158 | { | |
65d4927b | 159 | STACK_OF(X509_NAME_ENTRY) *entries; |
d02b48c6 RE |
160 | int modified; /* true if 'bytes' needs to be built */ |
161 | #ifdef HEADER_BUFFER_H | |
162 | BUF_MEM *bytes; | |
163 | #else | |
164 | char *bytes; | |
165 | #endif | |
58964a49 | 166 | unsigned long hash; /* Keep the hash around for lookups */ |
d02b48c6 RE |
167 | } X509_NAME; |
168 | ||
f73e07cf BL |
169 | DECLARE_STACK_OF(X509_NAME) |
170 | ||
58964a49 RE |
171 | #define X509_EX_V_NETSCAPE_HACK 0x8000 |
172 | #define X509_EX_V_INIT 0x0001 | |
d02b48c6 RE |
173 | typedef struct X509_extension_st |
174 | { | |
175 | ASN1_OBJECT *object; | |
176 | short critical; | |
177 | short netscape_hack; | |
178 | ASN1_OCTET_STRING *value; | |
3ea23631 DSH |
179 | struct v3_ext_method *method; /* V3 method to use */ |
180 | void *ext_val; /* extension value */ | |
d02b48c6 RE |
181 | } X509_EXTENSION; |
182 | ||
0b3f827c BL |
183 | DECLARE_STACK_OF(X509_EXTENSION) |
184 | DECLARE_ASN1_SET_OF(X509_EXTENSION) | |
185 | ||
d500de16 BL |
186 | /* a sequence of these are used */ |
187 | typedef struct x509_attributes_st | |
188 | { | |
189 | ASN1_OBJECT *object; | |
190 | int set; /* 1 for a set, 0 for a single item (which is wrong) */ | |
191 | union { | |
192 | char *ptr; | |
d35ea5b0 | 193 | /* 1 */ STACK_OF(ASN1_TYPE) *set; |
d500de16 BL |
194 | /* 0 */ ASN1_TYPE *single; |
195 | } value; | |
196 | } X509_ATTRIBUTE; | |
197 | ||
198 | DECLARE_STACK_OF(X509_ATTRIBUTE) | |
199 | DECLARE_ASN1_SET_OF(X509_ATTRIBUTE) | |
200 | ||
d02b48c6 RE |
201 | typedef struct X509_req_info_st |
202 | { | |
203 | ASN1_INTEGER *version; | |
204 | X509_NAME *subject; | |
205 | X509_PUBKEY *pubkey; | |
206 | /* d=2 hl=2 l= 0 cons: cont: 00 */ | |
d500de16 | 207 | STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ |
d02b48c6 RE |
208 | int req_kludge; |
209 | } X509_REQ_INFO; | |
210 | ||
211 | typedef struct X509_req_st | |
212 | { | |
213 | X509_REQ_INFO *req_info; | |
214 | X509_ALGOR *sig_alg; | |
215 | ASN1_BIT_STRING *signature; | |
216 | int references; | |
217 | } X509_REQ; | |
218 | ||
219 | typedef struct x509_cinf_st | |
220 | { | |
221 | ASN1_INTEGER *version; /* [ 0 ] default of v1 */ | |
222 | ASN1_INTEGER *serialNumber; | |
223 | X509_ALGOR *signature; | |
224 | X509_NAME *issuer; | |
225 | X509_VAL *validity; | |
226 | X509_NAME *subject; | |
227 | X509_PUBKEY *key; | |
228 | ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ | |
229 | ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ | |
0b3f827c | 230 | STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ |
d02b48c6 RE |
231 | } X509_CINF; |
232 | ||
233 | typedef struct x509_st | |
234 | { | |
235 | X509_CINF *cert_info; | |
236 | X509_ALGOR *sig_alg; | |
237 | ASN1_BIT_STRING *signature; | |
238 | int valid; | |
239 | int references; | |
240 | char *name; | |
241 | } X509; | |
242 | ||
f73e07cf BL |
243 | DECLARE_STACK_OF(X509) |
244 | DECLARE_ASN1_SET_OF(X509) | |
245 | ||
d02b48c6 RE |
246 | typedef struct X509_revoked_st |
247 | { | |
248 | ASN1_INTEGER *serialNumber; | |
249 | ASN1_UTCTIME *revocationDate; | |
0b3f827c | 250 | STACK_OF(X509_EXTENSION) /* optional */ *extensions; |
d02b48c6 RE |
251 | int sequence; /* load sequence */ |
252 | } X509_REVOKED; | |
253 | ||
ee8ba0b2 BL |
254 | DECLARE_STACK_OF(X509_REVOKED) |
255 | DECLARE_ASN1_SET_OF(X509_REVOKED) | |
256 | ||
d02b48c6 RE |
257 | typedef struct X509_crl_info_st |
258 | { | |
259 | ASN1_INTEGER *version; | |
260 | X509_ALGOR *sig_alg; | |
261 | X509_NAME *issuer; | |
262 | ASN1_UTCTIME *lastUpdate; | |
263 | ASN1_UTCTIME *nextUpdate; | |
ee8ba0b2 | 264 | STACK_OF(X509_REVOKED) *revoked; |
0b3f827c | 265 | STACK_OF(X509_EXTENSION) /* [0] */ *extensions; |
d02b48c6 RE |
266 | } X509_CRL_INFO; |
267 | ||
268 | typedef struct X509_crl_st | |
269 | { | |
270 | /* actual signature */ | |
271 | X509_CRL_INFO *crl; | |
272 | X509_ALGOR *sig_alg; | |
273 | ASN1_BIT_STRING *signature; | |
274 | int references; | |
275 | } X509_CRL; | |
276 | ||
6d114240 BL |
277 | DECLARE_STACK_OF(X509_CRL) |
278 | DECLARE_ASN1_SET_OF(X509_CRL) | |
279 | ||
d02b48c6 RE |
280 | typedef struct private_key_st |
281 | { | |
282 | int version; | |
283 | /* The PKCS#8 data types */ | |
284 | X509_ALGOR *enc_algor; | |
285 | ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ | |
286 | ||
287 | /* When decrypted, the following will not be NULL */ | |
288 | EVP_PKEY *dec_pkey; | |
289 | ||
290 | /* used to encrypt and decrypt */ | |
291 | int key_length; | |
292 | char *key_data; | |
293 | int key_free; /* true if we should auto free key_data */ | |
294 | ||
295 | /* expanded version of 'enc_algor' */ | |
296 | EVP_CIPHER_INFO cipher; | |
297 | ||
298 | int references; | |
299 | } X509_PKEY; | |
300 | ||
301 | #ifdef HEADER_ENVELOPE_H | |
302 | typedef struct X509_info_st | |
303 | { | |
304 | X509 *x509; | |
305 | X509_CRL *crl; | |
306 | X509_PKEY *x_pkey; | |
307 | ||
308 | EVP_CIPHER_INFO enc_cipher; | |
309 | int enc_len; | |
310 | char *enc_data; | |
311 | ||
312 | int references; | |
313 | } X509_INFO; | |
20b85fdd RE |
314 | |
315 | DECLARE_STACK_OF(X509_INFO) | |
d02b48c6 RE |
316 | #endif |
317 | ||
318 | /* The next 2 structures and their 8 routines were sent to me by | |
319 | * Pat Richard <patr@x509.com> and are used to manipulate | |
320 | * Netscapes spki strucutres - usefull if you are writing a CA web page | |
321 | */ | |
322 | typedef struct Netscape_spkac_st | |
323 | { | |
324 | X509_PUBKEY *pubkey; | |
325 | ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ | |
326 | } NETSCAPE_SPKAC; | |
327 | ||
328 | typedef struct Netscape_spki_st | |
329 | { | |
330 | NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ | |
331 | X509_ALGOR *sig_algor; | |
332 | ASN1_BIT_STRING *signature; | |
333 | } NETSCAPE_SPKI; | |
334 | ||
92c046ca DSH |
335 | /* Netscape certificate sequence structure */ |
336 | typedef struct Netscape_certificate_sequence | |
337 | { | |
338 | ASN1_OBJECT *type; | |
e5e932d2 | 339 | STACK_OF(X509) *certs; |
92c046ca DSH |
340 | } NETSCAPE_CERT_SEQUENCE; |
341 | ||
d02b48c6 RE |
342 | typedef struct CBCParameter_st |
343 | { | |
344 | unsigned char iv[8]; | |
345 | } CBC_PARAM; | |
346 | ||
cfcefcbe DSH |
347 | /* Password based encryption structure */ |
348 | ||
349 | typedef struct PBEPARAM_st { | |
350 | ASN1_OCTET_STRING *salt; | |
351 | ASN1_INTEGER *iter; | |
352 | } PBEPARAM; | |
353 | ||
d2e26dcc DSH |
354 | /* Password based encryption V2 structures */ |
355 | ||
356 | typedef struct PBE2PARAM_st { | |
357 | X509_ALGOR *keyfunc; | |
358 | X509_ALGOR *encryption; | |
359 | } PBE2PARAM; | |
360 | ||
361 | typedef struct PBKDF2PARAM_st { | |
8e21c146 | 362 | ASN1_TYPE *salt; /* Usually OCTET STRING but could be anything */ |
d2e26dcc DSH |
363 | ASN1_INTEGER *iter; |
364 | ASN1_INTEGER *keylength; | |
365 | X509_ALGOR *prf; | |
366 | } PBKDF2PARAM; | |
367 | ||
368 | ||
cfcefcbe DSH |
369 | /* PKCS#8 private key info structure */ |
370 | ||
371 | typedef struct pkcs8_priv_key_info_st | |
372 | { | |
373 | int broken; /* Flag for various broken formats */ | |
374 | #define PKCS8_OK 0 | |
375 | #define PKCS8_NO_OCTET 1 | |
376 | ASN1_INTEGER *version; | |
377 | X509_ALGOR *pkeyalg; | |
378 | ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */ | |
fc875472 | 379 | STACK_OF(X509_ATTRIBUTE) *attributes; |
cfcefcbe DSH |
380 | } PKCS8_PRIV_KEY_INFO; |
381 | ||
ec577822 BM |
382 | #include <openssl/x509_vfy.h> |
383 | #include <openssl/pkcs7.h> | |
d02b48c6 RE |
384 | |
385 | #ifdef SSLEAY_MACROS | |
386 | #define X509_verify(a,r) ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,\ | |
387 | a->signature,(char *)a->cert_info,r) | |
388 | #define X509_REQ_verify(a,r) ASN1_verify((int (*)())i2d_X509_REQ_INFO, \ | |
389 | a->sig_alg,a->signature,(char *)a->req_info,r) | |
390 | #define X509_CRL_verify(a,r) ASN1_verify((int (*)())i2d_X509_CRL_INFO, \ | |
391 | a->sig_alg, a->signature,(char *)a->crl,r) | |
d02b48c6 RE |
392 | |
393 | #define X509_sign(x,pkey,md) \ | |
394 | ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, \ | |
395 | x->sig_alg, x->signature, (char *)x->cert_info,pkey,md) | |
396 | #define X509_REQ_sign(x,pkey,md) \ | |
397 | ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, \ | |
398 | x->signature, (char *)x->req_info,pkey,md) | |
399 | #define X509_CRL_sign(x,pkey,md) \ | |
400 | ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,x->sig_alg, \ | |
401 | x->signature, (char *)x->crl,pkey,md) | |
402 | #define NETSCAPE_SPKI_sign(x,pkey,md) \ | |
403 | ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, \ | |
404 | x->signature, (char *)x->spkac,pkey,md) | |
405 | ||
406 | #define X509_dup(x509) (X509 *)ASN1_dup((int (*)())i2d_X509, \ | |
407 | (char *(*)())d2i_X509,(char *)x509) | |
dfeab068 RE |
408 | #define X509_ATTRIBUTE_dup(xa) (X509_ATTRIBUTE *)ASN1_dup(\ |
409 | (int (*)())i2d_X509_ATTRIBUTE, \ | |
410 | (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa) | |
d02b48c6 RE |
411 | #define X509_EXTENSION_dup(ex) (X509_EXTENSION *)ASN1_dup( \ |
412 | (int (*)())i2d_X509_EXTENSION, \ | |
413 | (char *(*)())d2i_X509_EXTENSION,(char *)ex) | |
414 | #define d2i_X509_fp(fp,x509) (X509 *)ASN1_d2i_fp((char *(*)())X509_new, \ | |
415 | (char *(*)())d2i_X509, (fp),(unsigned char **)(x509)) | |
416 | #define i2d_X509_fp(fp,x509) ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509) | |
417 | #define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \ | |
418 | (char *(*)())d2i_X509, (bp),(unsigned char **)(x509)) | |
419 | #define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509) | |
420 | ||
421 | #define X509_CRL_dup(crl) (X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL, \ | |
422 | (char *(*)())d2i_X509_CRL,(char *)crl) | |
423 | #define d2i_X509_CRL_fp(fp,crl) (X509_CRL *)ASN1_d2i_fp((char *(*)()) \ | |
424 | X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),\ | |
425 | (unsigned char **)(crl)) | |
426 | #define i2d_X509_CRL_fp(fp,crl) ASN1_i2d_fp(i2d_X509_CRL,fp,\ | |
427 | (unsigned char *)crl) | |
428 | #define d2i_X509_CRL_bio(bp,crl) (X509_CRL *)ASN1_d2i_bio((char *(*)()) \ | |
429 | X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),\ | |
430 | (unsigned char **)(crl)) | |
431 | #define i2d_X509_CRL_bio(bp,crl) ASN1_i2d_bio(i2d_X509_CRL,bp,\ | |
432 | (unsigned char *)crl) | |
433 | ||
434 | #define PKCS7_dup(p7) (PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7, \ | |
435 | (char *(*)())d2i_PKCS7,(char *)p7) | |
436 | #define d2i_PKCS7_fp(fp,p7) (PKCS7 *)ASN1_d2i_fp((char *(*)()) \ | |
437 | PKCS7_new,(char *(*)())d2i_PKCS7, (fp),\ | |
438 | (unsigned char **)(p7)) | |
439 | #define i2d_PKCS7_fp(fp,p7) ASN1_i2d_fp(i2d_PKCS7,fp,\ | |
440 | (unsigned char *)p7) | |
441 | #define d2i_PKCS7_bio(bp,p7) (PKCS7 *)ASN1_d2i_bio((char *(*)()) \ | |
442 | PKCS7_new,(char *(*)())d2i_PKCS7, (bp),\ | |
443 | (unsigned char **)(p7)) | |
444 | #define i2d_PKCS7_bio(bp,p7) ASN1_i2d_bio(i2d_PKCS7,bp,\ | |
445 | (unsigned char *)p7) | |
446 | ||
447 | #define X509_REQ_dup(req) (X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ, \ | |
448 | (char *(*)())d2i_X509_REQ,(char *)req) | |
449 | #define d2i_X509_REQ_fp(fp,req) (X509_REQ *)ASN1_d2i_fp((char *(*)())\ | |
450 | X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),\ | |
451 | (unsigned char **)(req)) | |
452 | #define i2d_X509_REQ_fp(fp,req) ASN1_i2d_fp(i2d_X509_REQ,fp,\ | |
453 | (unsigned char *)req) | |
454 | #define d2i_X509_REQ_bio(bp,req) (X509_REQ *)ASN1_d2i_bio((char *(*)())\ | |
455 | X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),\ | |
456 | (unsigned char **)(req)) | |
457 | #define i2d_X509_REQ_bio(bp,req) ASN1_i2d_bio(i2d_X509_REQ,bp,\ | |
458 | (unsigned char *)req) | |
459 | ||
460 | #define RSAPublicKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey, \ | |
461 | (char *(*)())d2i_RSAPublicKey,(char *)rsa) | |
462 | #define RSAPrivateKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey, \ | |
463 | (char *(*)())d2i_RSAPrivateKey,(char *)rsa) | |
464 | ||
465 | #define d2i_RSAPrivateKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ | |
466 | RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp), \ | |
467 | (unsigned char **)(rsa)) | |
468 | #define i2d_RSAPrivateKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPrivateKey,fp, \ | |
469 | (unsigned char *)rsa) | |
470 | #define d2i_RSAPrivateKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ | |
471 | RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp), \ | |
472 | (unsigned char **)(rsa)) | |
473 | #define i2d_RSAPrivateKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPrivateKey,bp, \ | |
474 | (unsigned char *)rsa) | |
475 | ||
476 | #define d2i_RSAPublicKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ | |
477 | RSA_new,(char *(*)())d2i_RSAPublicKey, (fp), \ | |
478 | (unsigned char **)(rsa)) | |
479 | #define i2d_RSAPublicKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPublicKey,fp, \ | |
480 | (unsigned char *)rsa) | |
481 | #define d2i_RSAPublicKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ | |
482 | RSA_new,(char *(*)())d2i_RSAPublicKey, (bp), \ | |
483 | (unsigned char **)(rsa)) | |
484 | #define i2d_RSAPublicKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPublicKey,bp, \ | |
485 | (unsigned char *)rsa) | |
486 | ||
487 | #define d2i_DSAPrivateKey_fp(fp,dsa) (DSA *)ASN1_d2i_fp((char *(*)())\ | |
488 | DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp), \ | |
489 | (unsigned char **)(dsa)) | |
490 | #define i2d_DSAPrivateKey_fp(fp,dsa) ASN1_i2d_fp(i2d_DSAPrivateKey,fp, \ | |
491 | (unsigned char *)dsa) | |
492 | #define d2i_DSAPrivateKey_bio(bp,dsa) (DSA *)ASN1_d2i_bio((char *(*)())\ | |
493 | DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp), \ | |
494 | (unsigned char **)(dsa)) | |
495 | #define i2d_DSAPrivateKey_bio(bp,dsa) ASN1_i2d_bio(i2d_DSAPrivateKey,bp, \ | |
496 | (unsigned char *)dsa) | |
497 | ||
dfeab068 RE |
498 | #define X509_ALGOR_dup(xn) (X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,\ |
499 | (char *(*)())d2i_X509_ALGOR,(char *)xn) | |
500 | ||
d02b48c6 RE |
501 | #define X509_NAME_dup(xn) (X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME, \ |
502 | (char *(*)())d2i_X509_NAME,(char *)xn) | |
503 | #define X509_NAME_ENTRY_dup(ne) (X509_NAME_ENTRY *)ASN1_dup( \ | |
504 | (int (*)())i2d_X509_NAME_ENTRY, \ | |
505 | (char *(*)())d2i_X509_NAME_ENTRY,\ | |
506 | (char *)ne) | |
507 | ||
508 | #define X509_digest(data,type,md,len) \ | |
509 | ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len) | |
510 | #define X509_NAME_digest(data,type,md,len) \ | |
511 | ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len) | |
dfeab068 | 512 | #ifndef PKCS7_ISSUER_AND_SERIAL_digest |
d02b48c6 RE |
513 | #define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ |
514 | ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\ | |
515 | (char *)data,md,len) | |
516 | #endif | |
dfeab068 | 517 | #endif |
d02b48c6 | 518 | |
58964a49 RE |
519 | #define X509_EXT_PACK_UNKNOWN 1 |
520 | #define X509_EXT_PACK_STRING 2 | |
521 | ||
d02b48c6 RE |
522 | #define X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version) |
523 | /* #define X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */ | |
524 | #define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore) | |
525 | #define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter) | |
526 | #define X509_extract_key(x) X509_get_pubkey(x) /*****/ | |
527 | #define X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version) | |
528 | #define X509_REQ_get_subject_name(x) ((x)->req_info->subject) | |
529 | #define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) | |
530 | #define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) | |
531 | #define X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm)) | |
532 | ||
0ca5f8b1 DSH |
533 | #define X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version) |
534 | #define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate) | |
535 | #define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate) | |
536 | #define X509_CRL_get_issuer(x) ((x)->crl->issuer) | |
537 | #define X509_CRL_get_REVOKED(x) ((x)->crl->revoked) | |
538 | ||
d02b48c6 RE |
539 | /* This one is only used so that a binary form can output, as in |
540 | * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */ | |
541 | #define X509_get_X509_PUBKEY(x) ((x)->cert_info->key) | |
542 | ||
d02b48c6 | 543 | |
16bc9fea BM |
544 | const char *X509_verify_cert_error_string(long n); |
545 | ||
d02b48c6 RE |
546 | #ifndef SSLEAY_MACROS |
547 | #ifdef HEADER_ENVELOPE_H | |
548 | int X509_verify(X509 *a, EVP_PKEY *r); | |
d02b48c6 RE |
549 | |
550 | int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); | |
551 | int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); | |
552 | int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); | |
553 | ||
092ec334 | 554 | NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len); |
8ce97163 DSH |
555 | char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x); |
556 | EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x); | |
557 | int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); | |
558 | ||
559 | int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); | |
560 | ||
e778802f BL |
561 | int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); |
562 | int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); | |
563 | int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); | |
564 | int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); | |
d02b48c6 RE |
565 | |
566 | int X509_digest(X509 *data,EVP_MD *type,unsigned char *md,unsigned int *len); | |
567 | int X509_NAME_digest(X509_NAME *data,EVP_MD *type, | |
568 | unsigned char *md,unsigned int *len); | |
569 | #endif | |
570 | ||
58964a49 | 571 | #ifndef NO_FP_API |
31a352d1 | 572 | X509 *d2i_X509_fp(FILE *fp, X509 **x509); |
d02b48c6 | 573 | int i2d_X509_fp(FILE *fp,X509 *x509); |
31a352d1 | 574 | X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl); |
d02b48c6 | 575 | int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl); |
31a352d1 | 576 | X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req); |
d02b48c6 | 577 | int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req); |
f5d7a031 | 578 | #ifndef NO_RSA |
31a352d1 | 579 | RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa); |
d02b48c6 | 580 | int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa); |
31a352d1 | 581 | RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa); |
d02b48c6 RE |
582 | int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa); |
583 | #endif | |
f5d7a031 | 584 | #ifndef NO_DSA |
3ea23631 DSH |
585 | DSA *d2i_DSAPublicKey_fp(FILE *fp, DSA **dsa); |
586 | int i2d_DSAPublicKey_fp(FILE *fp, DSA *dsa); | |
31a352d1 | 587 | DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); |
f5d7a031 | 588 | int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa); |
3cbb7937 DSH |
589 | X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8); |
590 | int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8); | |
591 | PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, | |
592 | PKCS8_PRIV_KEY_INFO **p8inf); | |
593 | int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf); | |
f5d7a031 UM |
594 | #endif |
595 | #endif | |
d02b48c6 RE |
596 | |
597 | #ifdef HEADER_BIO_H | |
31a352d1 | 598 | X509 *d2i_X509_bio(BIO *bp,X509 **x509); |
d02b48c6 | 599 | int i2d_X509_bio(BIO *bp,X509 *x509); |
31a352d1 | 600 | X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl); |
d02b48c6 | 601 | int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl); |
31a352d1 | 602 | X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req); |
d02b48c6 | 603 | int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req); |
f5d7a031 | 604 | #ifndef NO_RSA |
31a352d1 | 605 | RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa); |
d02b48c6 | 606 | int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa); |
31a352d1 | 607 | RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa); |
d02b48c6 RE |
608 | int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa); |
609 | #endif | |
f5d7a031 | 610 | #ifndef NO_DSA |
3ea23631 DSH |
611 | DSA *d2i_DSAPublicKey_bio(BIO *bp, DSA **dsa); |
612 | int i2d_DSAPublicKey_bio(BIO *bp, DSA *dsa); | |
31a352d1 | 613 | DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); |
f5d7a031 | 614 | int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa); |
5271ebd9 | 615 | #endif |
3cbb7937 DSH |
616 | X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8); |
617 | int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8); | |
618 | PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, | |
619 | PKCS8_PRIV_KEY_INFO **p8inf); | |
620 | int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf); | |
f5d7a031 | 621 | #endif |
d02b48c6 RE |
622 | |
623 | X509 *X509_dup(X509 *x509); | |
dfeab068 | 624 | X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa); |
d02b48c6 RE |
625 | X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex); |
626 | X509_CRL *X509_CRL_dup(X509_CRL *crl); | |
627 | X509_REQ *X509_REQ_dup(X509_REQ *req); | |
dfeab068 | 628 | X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn); |
d02b48c6 RE |
629 | X509_NAME *X509_NAME_dup(X509_NAME *xn); |
630 | X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne); | |
f5d7a031 | 631 | #ifndef NO_RSA |
d02b48c6 RE |
632 | RSA *RSAPublicKey_dup(RSA *rsa); |
633 | RSA *RSAPrivateKey_dup(RSA *rsa); | |
f5d7a031 | 634 | #endif |
d02b48c6 RE |
635 | |
636 | #endif /* !SSLEAY_MACROS */ | |
637 | ||
638 | int X509_cmp_current_time(ASN1_UTCTIME *s); | |
639 | ASN1_UTCTIME * X509_gmtime_adj(ASN1_UTCTIME *s, long adj); | |
640 | ||
e778802f BL |
641 | const char * X509_get_default_cert_area(void ); |
642 | const char * X509_get_default_cert_dir(void ); | |
643 | const char * X509_get_default_cert_file(void ); | |
644 | const char * X509_get_default_cert_dir_env(void ); | |
645 | const char * X509_get_default_cert_file_env(void ); | |
646 | const char * X509_get_default_private_dir(void ); | |
d02b48c6 | 647 | |
58964a49 | 648 | X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, EVP_MD *md); |
d02b48c6 RE |
649 | X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey); |
650 | void ERR_load_X509_strings(void ); | |
651 | ||
652 | X509_ALGOR * X509_ALGOR_new(void ); | |
653 | void X509_ALGOR_free(X509_ALGOR *a); | |
654 | int i2d_X509_ALGOR(X509_ALGOR *a,unsigned char **pp); | |
655 | X509_ALGOR * d2i_X509_ALGOR(X509_ALGOR **a,unsigned char **pp, | |
656 | long length); | |
657 | ||
658 | X509_VAL * X509_VAL_new(void ); | |
659 | void X509_VAL_free(X509_VAL *a); | |
660 | int i2d_X509_VAL(X509_VAL *a,unsigned char **pp); | |
661 | X509_VAL * d2i_X509_VAL(X509_VAL **a,unsigned char **pp, | |
662 | long length); | |
663 | ||
664 | X509_PUBKEY * X509_PUBKEY_new(void ); | |
665 | void X509_PUBKEY_free(X509_PUBKEY *a); | |
666 | int i2d_X509_PUBKEY(X509_PUBKEY *a,unsigned char **pp); | |
667 | X509_PUBKEY * d2i_X509_PUBKEY(X509_PUBKEY **a,unsigned char **pp, | |
668 | long length); | |
669 | int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); | |
670 | EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); | |
7e258a56 BL |
671 | int X509_get_pubkey_parameters(EVP_PKEY *pkey, |
672 | STACK_OF(X509) *chain); | |
d02b48c6 RE |
673 | |
674 | ||
675 | X509_SIG * X509_SIG_new(void ); | |
676 | void X509_SIG_free(X509_SIG *a); | |
677 | int i2d_X509_SIG(X509_SIG *a,unsigned char **pp); | |
678 | X509_SIG * d2i_X509_SIG(X509_SIG **a,unsigned char **pp,long length); | |
679 | ||
680 | X509_REQ_INFO *X509_REQ_INFO_new(void); | |
681 | void X509_REQ_INFO_free(X509_REQ_INFO *a); | |
682 | int i2d_X509_REQ_INFO(X509_REQ_INFO *a,unsigned char **pp); | |
683 | X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a,unsigned char **pp, | |
684 | long length); | |
685 | ||
686 | X509_REQ * X509_REQ_new(void); | |
687 | void X509_REQ_free(X509_REQ *a); | |
688 | int i2d_X509_REQ(X509_REQ *a,unsigned char **pp); | |
689 | X509_REQ * d2i_X509_REQ(X509_REQ **a,unsigned char **pp,long length); | |
690 | ||
691 | X509_ATTRIBUTE *X509_ATTRIBUTE_new(void ); | |
692 | void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a); | |
693 | int i2d_X509_ATTRIBUTE(X509_ATTRIBUTE *a,unsigned char **pp); | |
694 | X509_ATTRIBUTE *d2i_X509_ATTRIBUTE(X509_ATTRIBUTE **a,unsigned char **pp, | |
695 | long length); | |
c8b41850 | 696 | X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); |
dfeab068 | 697 | |
d02b48c6 RE |
698 | |
699 | X509_EXTENSION *X509_EXTENSION_new(void ); | |
700 | void X509_EXTENSION_free(X509_EXTENSION *a); | |
701 | int i2d_X509_EXTENSION(X509_EXTENSION *a,unsigned char **pp); | |
702 | X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a,unsigned char **pp, | |
703 | long length); | |
704 | ||
705 | X509_NAME_ENTRY *X509_NAME_ENTRY_new(void); | |
706 | void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a); | |
707 | int i2d_X509_NAME_ENTRY(X509_NAME_ENTRY *a,unsigned char **pp); | |
708 | X509_NAME_ENTRY *d2i_X509_NAME_ENTRY(X509_NAME_ENTRY **a,unsigned char **pp, | |
709 | long length); | |
710 | ||
711 | X509_NAME * X509_NAME_new(void); | |
712 | void X509_NAME_free(X509_NAME *a); | |
713 | int i2d_X509_NAME(X509_NAME *a,unsigned char **pp); | |
714 | X509_NAME * d2i_X509_NAME(X509_NAME **a,unsigned char **pp,long length); | |
715 | int X509_NAME_set(X509_NAME **xn, X509_NAME *name); | |
716 | ||
717 | ||
718 | X509_CINF * X509_CINF_new(void); | |
719 | void X509_CINF_free(X509_CINF *a); | |
720 | int i2d_X509_CINF(X509_CINF *a,unsigned char **pp); | |
721 | X509_CINF * d2i_X509_CINF(X509_CINF **a,unsigned char **pp,long length); | |
722 | ||
723 | X509 * X509_new(void); | |
724 | void X509_free(X509 *a); | |
725 | int i2d_X509(X509 *a,unsigned char **pp); | |
726 | X509 * d2i_X509(X509 **a,unsigned char **pp,long length); | |
727 | ||
728 | X509_REVOKED * X509_REVOKED_new(void); | |
729 | void X509_REVOKED_free(X509_REVOKED *a); | |
730 | int i2d_X509_REVOKED(X509_REVOKED *a,unsigned char **pp); | |
731 | X509_REVOKED * d2i_X509_REVOKED(X509_REVOKED **a,unsigned char **pp,long length); | |
732 | ||
733 | X509_CRL_INFO *X509_CRL_INFO_new(void); | |
734 | void X509_CRL_INFO_free(X509_CRL_INFO *a); | |
735 | int i2d_X509_CRL_INFO(X509_CRL_INFO *a,unsigned char **pp); | |
736 | X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a,unsigned char **pp, | |
737 | long length); | |
738 | ||
739 | X509_CRL * X509_CRL_new(void); | |
740 | void X509_CRL_free(X509_CRL *a); | |
741 | int i2d_X509_CRL(X509_CRL *a,unsigned char **pp); | |
742 | X509_CRL * d2i_X509_CRL(X509_CRL **a,unsigned char **pp,long length); | |
743 | ||
744 | X509_PKEY * X509_PKEY_new(void ); | |
745 | void X509_PKEY_free(X509_PKEY *a); | |
746 | int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp); | |
747 | X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,unsigned char **pp,long length); | |
748 | ||
749 | NETSCAPE_SPKI * NETSCAPE_SPKI_new(void ); | |
750 | void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a); | |
751 | int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a,unsigned char **pp); | |
752 | NETSCAPE_SPKI * d2i_NETSCAPE_SPKI(NETSCAPE_SPKI **a,unsigned char **pp, | |
753 | long length); | |
754 | ||
755 | NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void ); | |
756 | void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a); | |
757 | int i2d_NETSCAPE_SPKAC(NETSCAPE_SPKAC *a,unsigned char **pp); | |
758 | NETSCAPE_SPKAC *d2i_NETSCAPE_SPKAC(NETSCAPE_SPKAC **a,unsigned char **pp, | |
759 | long length); | |
760 | ||
92c046ca DSH |
761 | |
762 | int i2d_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE *a, unsigned char **pp); | |
763 | NETSCAPE_CERT_SEQUENCE *NETSCAPE_CERT_SEQUENCE_new(void); | |
764 | NETSCAPE_CERT_SEQUENCE *d2i_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE **a, unsigned char **pp, long length); | |
765 | void NETSCAPE_CERT_SEQUENCE_free(NETSCAPE_CERT_SEQUENCE *a); | |
766 | ||
d02b48c6 RE |
767 | #ifdef HEADER_ENVELOPE_H |
768 | X509_INFO * X509_INFO_new(void); | |
769 | void X509_INFO_free(X509_INFO *a); | |
770 | char * X509_NAME_oneline(X509_NAME *a,char *buf,int size); | |
771 | ||
772 | int ASN1_verify(int (*i2d)(), X509_ALGOR *algor1, | |
773 | ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey); | |
774 | ||
775 | int ASN1_digest(int (*i2d)(),EVP_MD *type,char *data, | |
776 | unsigned char *md,unsigned int *len); | |
777 | ||
778 | int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2, | |
779 | ASN1_BIT_STRING *signature, | |
e778802f | 780 | char *data,EVP_PKEY *pkey, const EVP_MD *type); |
d02b48c6 RE |
781 | #endif |
782 | ||
783 | int X509_set_version(X509 *x,long version); | |
784 | int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); | |
785 | ASN1_INTEGER * X509_get_serialNumber(X509 *x); | |
786 | int X509_set_issuer_name(X509 *x, X509_NAME *name); | |
787 | X509_NAME * X509_get_issuer_name(X509 *a); | |
788 | int X509_set_subject_name(X509 *x, X509_NAME *name); | |
789 | X509_NAME * X509_get_subject_name(X509 *a); | |
790 | int X509_set_notBefore(X509 *x, ASN1_UTCTIME *tm); | |
791 | int X509_set_notAfter(X509 *x, ASN1_UTCTIME *tm); | |
792 | int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); | |
793 | EVP_PKEY * X509_get_pubkey(X509 *x); | |
794 | int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */); | |
795 | ||
796 | int X509_REQ_set_version(X509_REQ *x,long version); | |
797 | int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name); | |
798 | int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); | |
799 | EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); | |
87c49f62 DSH |
800 | int X509_REQ_extension_nid(int nid); |
801 | int * X509_REQ_get_extesion_nids(void); | |
802 | void X509_REQ_set_extension_nids(int *nids); | |
803 | STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req); | |
fd520577 DSH |
804 | int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, |
805 | int nid); | |
806 | int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts); | |
d02b48c6 RE |
807 | |
808 | int X509_check_private_key(X509 *x509,EVP_PKEY *pkey); | |
809 | ||
810 | int X509_issuer_and_serial_cmp(X509 *a, X509 *b); | |
811 | unsigned long X509_issuer_and_serial_hash(X509 *a); | |
812 | ||
813 | int X509_issuer_name_cmp(X509 *a, X509 *b); | |
814 | unsigned long X509_issuer_name_hash(X509 *a); | |
815 | ||
816 | int X509_subject_name_cmp(X509 *a,X509 *b); | |
817 | unsigned long X509_subject_name_hash(X509 *x); | |
818 | ||
819 | int X509_NAME_cmp (X509_NAME *a, X509_NAME *b); | |
820 | unsigned long X509_NAME_hash(X509_NAME *x); | |
821 | ||
822 | int X509_CRL_cmp(X509_CRL *a,X509_CRL *b); | |
58964a49 | 823 | #ifndef NO_FP_API |
d02b48c6 | 824 | int X509_print_fp(FILE *bp,X509 *x); |
0ca5f8b1 | 825 | int X509_CRL_print_fp(FILE *bp,X509_CRL *x); |
d02b48c6 RE |
826 | int X509_REQ_print_fp(FILE *bp,X509_REQ *req); |
827 | #endif | |
828 | ||
829 | #ifdef HEADER_BIO_H | |
830 | int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); | |
831 | int X509_print(BIO *bp,X509 *x); | |
0ca5f8b1 | 832 | int X509_CRL_print(BIO *bp,X509_CRL *x); |
d02b48c6 RE |
833 | int X509_REQ_print(BIO *bp,X509_REQ *req); |
834 | #endif | |
835 | ||
836 | int X509_NAME_entry_count(X509_NAME *name); | |
837 | int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, | |
838 | char *buf,int len); | |
839 | int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, | |
840 | char *buf,int len); | |
841 | ||
58964a49 RE |
842 | /* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use |
843 | * lastpos, seach after that position on. */ | |
844 | int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); | |
d02b48c6 | 845 | int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, |
58964a49 | 846 | int lastpos); |
d02b48c6 RE |
847 | X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc); |
848 | X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); | |
849 | int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, | |
850 | int loc, int set); | |
851 | X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, | |
852 | int type,unsigned char *bytes, int len); | |
853 | X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, | |
854 | ASN1_OBJECT *obj, int type,unsigned char *bytes, | |
855 | int len); | |
856 | int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, | |
857 | ASN1_OBJECT *obj); | |
858 | int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, | |
859 | unsigned char *bytes, int len); | |
860 | ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne); | |
861 | ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne); | |
862 | ||
0b3f827c BL |
863 | int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); |
864 | int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, | |
865 | int nid, int lastpos); | |
866 | int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, | |
867 | ASN1_OBJECT *obj,int lastpos); | |
868 | int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, | |
869 | int crit, int lastpos); | |
870 | X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); | |
871 | X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); | |
872 | STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, | |
873 | X509_EXTENSION *ex, int loc); | |
58964a49 | 874 | |
d02b48c6 | 875 | int X509_get_ext_count(X509 *x); |
58964a49 RE |
876 | int X509_get_ext_by_NID(X509 *x, int nid, int lastpos); |
877 | int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos); | |
878 | int X509_get_ext_by_critical(X509 *x, int crit, int lastpos); | |
d02b48c6 RE |
879 | X509_EXTENSION *X509_get_ext(X509 *x, int loc); |
880 | X509_EXTENSION *X509_delete_ext(X509 *x, int loc); | |
881 | int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); | |
882 | ||
883 | int X509_CRL_get_ext_count(X509_CRL *x); | |
58964a49 RE |
884 | int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos); |
885 | int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos); | |
886 | int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos); | |
d02b48c6 RE |
887 | X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc); |
888 | X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); | |
889 | int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); | |
890 | ||
891 | int X509_REVOKED_get_ext_count(X509_REVOKED *x); | |
58964a49 RE |
892 | int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos); |
893 | int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos); | |
894 | int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos); | |
d02b48c6 RE |
895 | X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc); |
896 | X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); | |
897 | int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); | |
898 | ||
899 | X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, | |
900 | int nid, int crit, ASN1_OCTET_STRING *data); | |
901 | X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, | |
902 | ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data); | |
903 | int X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj); | |
904 | int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); | |
905 | int X509_EXTENSION_set_data(X509_EXTENSION *ex, | |
906 | ASN1_OCTET_STRING *data); | |
907 | ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex); | |
908 | ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); | |
909 | int X509_EXTENSION_get_critical(X509_EXTENSION *ex); | |
d02b48c6 RE |
910 | |
911 | int X509_verify_cert(X509_STORE_CTX *ctx); | |
912 | ||
913 | /* lookup a cert from a X509 STACK */ | |
f73e07cf BL |
914 | X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name, |
915 | ASN1_INTEGER *serial); | |
916 | X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name); | |
d02b48c6 | 917 | |
cfcefcbe DSH |
918 | int i2d_PBEPARAM(PBEPARAM *a, unsigned char **pp); |
919 | PBEPARAM *PBEPARAM_new(void); | |
920 | PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, unsigned char **pp, long length); | |
921 | void PBEPARAM_free(PBEPARAM *a); | |
8d8c7266 | 922 | X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen); |
8eb57af5 DSH |
923 | X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, |
924 | unsigned char *salt, int saltlen); | |
cfcefcbe | 925 | |
d2e26dcc DSH |
926 | int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp); |
927 | PBKDF2PARAM *PBKDF2PARAM_new(void); | |
928 | PBKDF2PARAM *d2i_PBKDF2PARAM(PBKDF2PARAM **a, unsigned char **pp, long length); | |
929 | void PBKDF2PARAM_free(PBKDF2PARAM *a); | |
930 | ||
931 | int i2d_PBE2PARAM(PBE2PARAM *a, unsigned char **pp); | |
932 | PBE2PARAM *PBE2PARAM_new(void); | |
933 | PBE2PARAM *d2i_PBE2PARAM(PBE2PARAM **a, unsigned char **pp, long length); | |
934 | void PBE2PARAM_free(PBE2PARAM *a); | |
935 | ||
cfcefcbe DSH |
936 | /* PKCS#8 utilities */ |
937 | ||
938 | int i2d_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO *a, unsigned char **pp); | |
939 | PKCS8_PRIV_KEY_INFO *PKCS8_PRIV_KEY_INFO_new(void); | |
940 | PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a, | |
941 | unsigned char **pp, long length); | |
942 | void PKCS8_PRIV_KEY_INFO_free(PKCS8_PRIV_KEY_INFO *a); | |
943 | ||
944 | EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); | |
945 | PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); | |
946 | PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken); | |
947 | ||
d02b48c6 | 948 | /* BEGIN ERROR CODES */ |
6d311938 DSH |
949 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
950 | * made after this point may be overwritten when the script is next run. | |
951 | */ | |
952 | ||
d02b48c6 RE |
953 | /* Error codes for the X509 functions. */ |
954 | ||
955 | /* Function codes. */ | |
956 | #define X509_F_ADD_CERT_DIR 100 | |
957 | #define X509_F_BY_FILE_CTRL 101 | |
958 | #define X509_F_DIR_CTRL 102 | |
959 | #define X509_F_GET_CERT_BY_SUBJECT 103 | |
8ce97163 DSH |
960 | #define X509_F_NETSCAPE_SPKI_B64_DECODE 129 |
961 | #define X509_F_NETSCAPE_SPKI_B64_ENCODE 130 | |
d02b48c6 | 962 | #define X509_F_X509V3_ADD_EXT 104 |
4004dbb7 | 963 | #define X509_F_X509_CHECK_PRIVATE_KEY 128 |
d02b48c6 RE |
964 | #define X509_F_X509_EXTENSION_CREATE_BY_NID 108 |
965 | #define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 | |
966 | #define X509_F_X509_GET_PUBKEY_PARAMETERS 110 | |
967 | #define X509_F_X509_LOAD_CERT_FILE 111 | |
58964a49 RE |
968 | #define X509_F_X509_LOAD_CRL_FILE 112 |
969 | #define X509_F_X509_NAME_ADD_ENTRY 113 | |
970 | #define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 | |
971 | #define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 | |
972 | #define X509_F_X509_NAME_ONELINE 116 | |
973 | #define X509_F_X509_NAME_PRINT 117 | |
974 | #define X509_F_X509_PRINT_FP 118 | |
975 | #define X509_F_X509_PUBKEY_GET 119 | |
976 | #define X509_F_X509_PUBKEY_SET 120 | |
977 | #define X509_F_X509_REQ_PRINT 121 | |
978 | #define X509_F_X509_REQ_PRINT_FP 122 | |
979 | #define X509_F_X509_REQ_TO_X509 123 | |
980 | #define X509_F_X509_STORE_ADD_CERT 124 | |
981 | #define X509_F_X509_STORE_ADD_CRL 125 | |
982 | #define X509_F_X509_TO_X509_REQ 126 | |
983 | #define X509_F_X509_VERIFY_CERT 127 | |
d02b48c6 RE |
984 | |
985 | /* Reason codes. */ | |
986 | #define X509_R_BAD_X509_FILETYPE 100 | |
8ce97163 | 987 | #define X509_R_BASE64_DECODE_ERROR 118 |
4004dbb7 | 988 | #define X509_R_CANT_CHECK_DH_KEY 114 |
d02b48c6 RE |
989 | #define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 |
990 | #define X509_R_ERR_ASN1_LIB 102 | |
fdc71ecc | 991 | #define X509_R_INVALID_DIRECTORY 113 |
4004dbb7 BL |
992 | #define X509_R_KEY_TYPE_MISMATCH 115 |
993 | #define X509_R_KEY_VALUES_MISMATCH 116 | |
d02b48c6 RE |
994 | #define X509_R_LOADING_CERT_DIR 103 |
995 | #define X509_R_LOADING_DEFAULTS 104 | |
996 | #define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 | |
997 | #define X509_R_SHOULD_RETRY 106 | |
998 | #define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 | |
999 | #define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 | |
4004dbb7 | 1000 | #define X509_R_UNKNOWN_KEY_TYPE 117 |
d02b48c6 | 1001 | #define X509_R_UNKNOWN_NID 109 |
d02b48c6 | 1002 | #define X509_R_UNSUPPORTED_ALGORITHM 111 |
58964a49 | 1003 | #define X509_R_WRONG_LOOKUP_TYPE 112 |
6d311938 | 1004 | |
d02b48c6 RE |
1005 | #ifdef __cplusplus |
1006 | } | |
1007 | #endif | |
1008 | #endif | |
1009 |