Move the Win32 #undefs of X509_NAME and PKCS7_ISSUER_AND_SERIAL so they will
[openssl.git] / crypto / x509 / x509.h
1 /* crypto/x509/x509.h */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
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
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
71 #include <openssl/stack.h>
72 #include <openssl/asn1.h>
73 #include <openssl/safestack.h>
74
75 #ifndef NO_RSA
76 #include <openssl/rsa.h>
77 #endif
78
79 #ifndef NO_DSA
80 #include <openssl/dsa.h>
81 #endif
82
83 #ifndef NO_DH
84 #include <openssl/dh.h>
85 #endif
86
87 #include <openssl/evp.h>
88
89
90 #ifdef WIN32
91 /* Under Win32 this is defined in wincrypt.h */
92 #undef X509_NAME
93 #endif
94
95 #define X509_FILETYPE_PEM       1
96 #define X509_FILETYPE_ASN1      2
97 #define X509_FILETYPE_DEFAULT   3
98
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
117 typedef struct X509_algor_st
118         {
119         ASN1_OBJECT *algorithm;
120         ASN1_TYPE *parameter;
121         } X509_ALGOR;
122
123 typedef struct X509_val_st
124         {
125         ASN1_UTCTIME *notBefore;
126         ASN1_UTCTIME *notAfter;
127         } X509_VAL;
128
129 typedef struct X509_pubkey_st
130         {
131         X509_ALGOR *algor;
132         ASN1_BIT_STRING *public_key;
133         EVP_PKEY *pkey;
134         } X509_PUBKEY;
135
136 typedef struct X509_sig_st
137         {
138         X509_ALGOR *algor;
139         ASN1_OCTET_STRING *digest;
140         } X509_SIG;
141
142 typedef struct X509_name_entry_st
143         {
144         ASN1_OBJECT *object;
145         ASN1_STRING *value;
146         int set;
147         int size;       /* temp variable */
148         } X509_NAME_ENTRY;
149
150 DECLARE_STACK_OF(X509_NAME_ENTRY)
151 DECLARE_ASN1_SET_OF(X509_NAME_ENTRY)
152
153 /* we always keep X509_NAMEs in 2 forms. */
154 typedef struct X509_name_st
155         {
156         STACK_OF(X509_NAME_ENTRY) *entries;
157         int modified;   /* true if 'bytes' needs to be built */
158 #ifdef HEADER_BUFFER_H
159         BUF_MEM *bytes;
160 #else
161         char *bytes;
162 #endif
163         unsigned long hash; /* Keep the hash around for lookups */
164         } X509_NAME;
165
166 DECLARE_STACK_OF(X509_NAME)
167
168 #define X509_EX_V_NETSCAPE_HACK         0x8000
169 #define X509_EX_V_INIT                  0x0001
170 typedef struct X509_extension_st
171         {
172         ASN1_OBJECT *object;
173         short critical;
174         short netscape_hack;
175         ASN1_OCTET_STRING *value;
176         long argl;                      /* used when decoding */
177         char *argp;                     /* used when decoding */
178         void (*ex_free)();              /* clear argp stuff */
179         } X509_EXTENSION;
180
181 DECLARE_STACK_OF(X509_EXTENSION)
182 DECLARE_ASN1_SET_OF(X509_EXTENSION)
183
184 /* a sequence of these are used */
185 typedef struct x509_attributes_st
186         {
187         ASN1_OBJECT *object;
188         int set; /* 1 for a set, 0 for a single item (which is wrong) */
189         union   {
190                 char            *ptr;
191 /* 1 */         STACK_OF(ASN1_TYPE) *set;
192 /* 0 */         ASN1_TYPE       *single;
193                 } value;
194         } X509_ATTRIBUTE;
195
196 DECLARE_STACK_OF(X509_ATTRIBUTE)
197 DECLARE_ASN1_SET_OF(X509_ATTRIBUTE)
198
199 typedef struct X509_req_info_st
200         {
201         ASN1_INTEGER *version;
202         X509_NAME *subject;
203         X509_PUBKEY *pubkey;
204         /*  d=2 hl=2 l=  0 cons: cont: 00 */
205         STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
206         int req_kludge;
207         } X509_REQ_INFO;
208
209 typedef struct X509_req_st
210         {
211         X509_REQ_INFO *req_info;
212         X509_ALGOR *sig_alg;
213         ASN1_BIT_STRING *signature;
214         int references;
215         } X509_REQ;
216
217 typedef struct x509_cinf_st
218         {
219         ASN1_INTEGER *version;          /* [ 0 ] default of v1 */
220         ASN1_INTEGER *serialNumber;
221         X509_ALGOR *signature;
222         X509_NAME *issuer;
223         X509_VAL *validity;
224         X509_NAME *subject;
225         X509_PUBKEY *key;
226         ASN1_BIT_STRING *issuerUID;             /* [ 1 ] optional in v2 */
227         ASN1_BIT_STRING *subjectUID;            /* [ 2 ] optional in v2 */
228         STACK_OF(X509_EXTENSION) *extensions;   /* [ 3 ] optional in v3 */
229         } X509_CINF;
230
231 typedef struct x509_st
232         {
233         X509_CINF *cert_info;
234         X509_ALGOR *sig_alg;
235         ASN1_BIT_STRING *signature;
236         int valid;
237         int references;
238         char *name;
239         } X509;
240
241 DECLARE_STACK_OF(X509)
242 DECLARE_ASN1_SET_OF(X509)
243
244 typedef struct X509_revoked_st
245         {
246         ASN1_INTEGER *serialNumber;
247         ASN1_UTCTIME *revocationDate;
248         STACK_OF(X509_EXTENSION) /* optional */ *extensions;
249         int sequence; /* load sequence */
250         } X509_REVOKED;
251
252 typedef struct X509_crl_info_st
253         {
254         ASN1_INTEGER *version;
255         X509_ALGOR *sig_alg;
256         X509_NAME *issuer;
257         ASN1_UTCTIME *lastUpdate;
258         ASN1_UTCTIME *nextUpdate;
259         STACK /* X509_REVOKED */ *revoked;
260         STACK_OF(X509_EXTENSION) /* [0] */ *extensions;
261         } X509_CRL_INFO;
262
263 typedef struct X509_crl_st
264         {
265         /* actual signature */
266         X509_CRL_INFO *crl;
267         X509_ALGOR *sig_alg;
268         ASN1_BIT_STRING *signature;
269         int references;
270         } X509_CRL;
271
272 typedef struct private_key_st
273         {
274         int version;
275         /* The PKCS#8 data types */
276         X509_ALGOR *enc_algor;
277         ASN1_OCTET_STRING *enc_pkey;    /* encrypted pub key */
278
279         /* When decrypted, the following will not be NULL */
280         EVP_PKEY *dec_pkey;
281
282         /* used to encrypt and decrypt */
283         int key_length;
284         char *key_data;
285         int key_free;   /* true if we should auto free key_data */
286
287         /* expanded version of 'enc_algor' */
288         EVP_CIPHER_INFO cipher;
289
290         int references;
291         } X509_PKEY;
292
293 #ifdef HEADER_ENVELOPE_H
294 typedef struct X509_info_st
295         {
296         X509 *x509;
297         X509_CRL *crl;
298         X509_PKEY *x_pkey;
299
300         EVP_CIPHER_INFO enc_cipher;
301         int enc_len;
302         char *enc_data;
303
304         int references;
305         } X509_INFO;
306
307 DECLARE_STACK_OF(X509_INFO)
308 #endif
309
310 /* The next 2 structures and their 8 routines were sent to me by
311  * Pat Richard <patr@x509.com> and are used to manipulate
312  * Netscapes spki strucutres - usefull if you are writing a CA web page
313  */
314 typedef struct Netscape_spkac_st
315         {
316         X509_PUBKEY *pubkey;
317         ASN1_IA5STRING *challenge;      /* challenge sent in atlas >= PR2 */
318         } NETSCAPE_SPKAC;
319
320 typedef struct Netscape_spki_st
321         {
322         NETSCAPE_SPKAC *spkac;  /* signed public key and challenge */
323         X509_ALGOR *sig_algor;
324         ASN1_BIT_STRING *signature;
325         } NETSCAPE_SPKI;
326
327 /* Netscape certificate sequence structure */
328 typedef struct Netscape_certificate_sequence
329         {
330         ASN1_OBJECT *type;
331         STACK /* X509 */ *certs;
332         } NETSCAPE_CERT_SEQUENCE;
333
334 #ifndef HEADER_BN_H
335 #define BIGNUM          char
336 #endif
337
338 typedef struct CBCParameter_st
339         {
340         unsigned char iv[8];
341         } CBC_PARAM;
342
343 /* Password based encryption structure */
344
345 typedef struct PBEPARAM_st {
346 ASN1_OCTET_STRING *salt;
347 ASN1_INTEGER *iter;
348 } PBEPARAM;
349
350 /* Password based encryption V2 structures */
351
352 typedef struct PBE2PARAM_st {
353 X509_ALGOR *keyfunc;
354 X509_ALGOR *encryption;
355 } PBE2PARAM;
356
357 typedef struct PBKDF2PARAM_st {
358 ASN1_OCTET_STRING *salt;
359 ASN1_INTEGER *iter;
360 ASN1_INTEGER *keylength;
361 X509_ALGOR *prf;
362 } PBKDF2PARAM;
363
364
365 /* PKCS#8 private key info structure */
366
367 typedef struct pkcs8_priv_key_info_st
368         {
369         int broken;     /* Flag for various broken formats */
370 #define PKCS8_OK        0
371 #define PKCS8_NO_OCTET  1
372         ASN1_INTEGER *version;
373         X509_ALGOR *pkeyalg;
374         ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */
375         STACK *attributes;
376         } PKCS8_PRIV_KEY_INFO;
377
378 #include <openssl/x509_vfy.h>
379 #include <openssl/pkcs7.h>
380
381 #ifdef SSLEAY_MACROS
382 #define X509_verify(a,r) ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,\
383         a->signature,(char *)a->cert_info,r)
384 #define X509_REQ_verify(a,r) ASN1_verify((int (*)())i2d_X509_REQ_INFO, \
385         a->sig_alg,a->signature,(char *)a->req_info,r)
386 #define X509_CRL_verify(a,r) ASN1_verify((int (*)())i2d_X509_CRL_INFO, \
387         a->sig_alg, a->signature,(char *)a->crl,r)
388
389 #define X509_sign(x,pkey,md) \
390         ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, \
391                 x->sig_alg, x->signature, (char *)x->cert_info,pkey,md)
392 #define X509_REQ_sign(x,pkey,md) \
393         ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, \
394                 x->signature, (char *)x->req_info,pkey,md)
395 #define X509_CRL_sign(x,pkey,md) \
396         ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,x->sig_alg, \
397                 x->signature, (char *)x->crl,pkey,md)
398 #define NETSCAPE_SPKI_sign(x,pkey,md) \
399         ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, \
400                 x->signature, (char *)x->spkac,pkey,md)
401
402 #define X509_dup(x509) (X509 *)ASN1_dup((int (*)())i2d_X509, \
403                 (char *(*)())d2i_X509,(char *)x509)
404 #define X509_ATTRIBUTE_dup(xa) (X509_ATTRIBUTE *)ASN1_dup(\
405                 (int (*)())i2d_X509_ATTRIBUTE, \
406                 (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa)
407 #define X509_EXTENSION_dup(ex) (X509_EXTENSION *)ASN1_dup( \
408                 (int (*)())i2d_X509_EXTENSION, \
409                 (char *(*)())d2i_X509_EXTENSION,(char *)ex)
410 #define d2i_X509_fp(fp,x509) (X509 *)ASN1_d2i_fp((char *(*)())X509_new, \
411                 (char *(*)())d2i_X509, (fp),(unsigned char **)(x509))
412 #define i2d_X509_fp(fp,x509) ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509)
413 #define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \
414                 (char *(*)())d2i_X509, (bp),(unsigned char **)(x509))
415 #define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509)
416
417 #define X509_CRL_dup(crl) (X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL, \
418                 (char *(*)())d2i_X509_CRL,(char *)crl)
419 #define d2i_X509_CRL_fp(fp,crl) (X509_CRL *)ASN1_d2i_fp((char *(*)()) \
420                 X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),\
421                 (unsigned char **)(crl))
422 #define i2d_X509_CRL_fp(fp,crl) ASN1_i2d_fp(i2d_X509_CRL,fp,\
423                 (unsigned char *)crl)
424 #define d2i_X509_CRL_bio(bp,crl) (X509_CRL *)ASN1_d2i_bio((char *(*)()) \
425                 X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),\
426                 (unsigned char **)(crl))
427 #define i2d_X509_CRL_bio(bp,crl) ASN1_i2d_bio(i2d_X509_CRL,bp,\
428                 (unsigned char *)crl)
429
430 #define PKCS7_dup(p7) (PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7, \
431                 (char *(*)())d2i_PKCS7,(char *)p7)
432 #define d2i_PKCS7_fp(fp,p7) (PKCS7 *)ASN1_d2i_fp((char *(*)()) \
433                 PKCS7_new,(char *(*)())d2i_PKCS7, (fp),\
434                 (unsigned char **)(p7))
435 #define i2d_PKCS7_fp(fp,p7) ASN1_i2d_fp(i2d_PKCS7,fp,\
436                 (unsigned char *)p7)
437 #define d2i_PKCS7_bio(bp,p7) (PKCS7 *)ASN1_d2i_bio((char *(*)()) \
438                 PKCS7_new,(char *(*)())d2i_PKCS7, (bp),\
439                 (unsigned char **)(p7))
440 #define i2d_PKCS7_bio(bp,p7) ASN1_i2d_bio(i2d_PKCS7,bp,\
441                 (unsigned char *)p7)
442
443 #define X509_REQ_dup(req) (X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ, \
444                 (char *(*)())d2i_X509_REQ,(char *)req)
445 #define d2i_X509_REQ_fp(fp,req) (X509_REQ *)ASN1_d2i_fp((char *(*)())\
446                 X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),\
447                 (unsigned char **)(req))
448 #define i2d_X509_REQ_fp(fp,req) ASN1_i2d_fp(i2d_X509_REQ,fp,\
449                 (unsigned char *)req)
450 #define d2i_X509_REQ_bio(bp,req) (X509_REQ *)ASN1_d2i_bio((char *(*)())\
451                 X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),\
452                 (unsigned char **)(req))
453 #define i2d_X509_REQ_bio(bp,req) ASN1_i2d_bio(i2d_X509_REQ,bp,\
454                 (unsigned char *)req)
455
456 #define RSAPublicKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey, \
457                 (char *(*)())d2i_RSAPublicKey,(char *)rsa)
458 #define RSAPrivateKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey, \
459                 (char *(*)())d2i_RSAPrivateKey,(char *)rsa)
460
461 #define d2i_RSAPrivateKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\
462                 RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp), \
463                 (unsigned char **)(rsa))
464 #define i2d_RSAPrivateKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPrivateKey,fp, \
465                 (unsigned char *)rsa)
466 #define d2i_RSAPrivateKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\
467                 RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp), \
468                 (unsigned char **)(rsa))
469 #define i2d_RSAPrivateKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPrivateKey,bp, \
470                 (unsigned char *)rsa)
471
472 #define d2i_RSAPublicKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\
473                 RSA_new,(char *(*)())d2i_RSAPublicKey, (fp), \
474                 (unsigned char **)(rsa))
475 #define i2d_RSAPublicKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPublicKey,fp, \
476                 (unsigned char *)rsa)
477 #define d2i_RSAPublicKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\
478                 RSA_new,(char *(*)())d2i_RSAPublicKey, (bp), \
479                 (unsigned char **)(rsa))
480 #define i2d_RSAPublicKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPublicKey,bp, \
481                 (unsigned char *)rsa)
482
483 #define d2i_DSAPrivateKey_fp(fp,dsa) (DSA *)ASN1_d2i_fp((char *(*)())\
484                 DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp), \
485                 (unsigned char **)(dsa))
486 #define i2d_DSAPrivateKey_fp(fp,dsa) ASN1_i2d_fp(i2d_DSAPrivateKey,fp, \
487                 (unsigned char *)dsa)
488 #define d2i_DSAPrivateKey_bio(bp,dsa) (DSA *)ASN1_d2i_bio((char *(*)())\
489                 DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp), \
490                 (unsigned char **)(dsa))
491 #define i2d_DSAPrivateKey_bio(bp,dsa) ASN1_i2d_bio(i2d_DSAPrivateKey,bp, \
492                 (unsigned char *)dsa)
493
494 #define X509_ALGOR_dup(xn) (X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,\
495                 (char *(*)())d2i_X509_ALGOR,(char *)xn)
496
497 #define X509_NAME_dup(xn) (X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME, \
498                 (char *(*)())d2i_X509_NAME,(char *)xn)
499 #define X509_NAME_ENTRY_dup(ne) (X509_NAME_ENTRY *)ASN1_dup( \
500                 (int (*)())i2d_X509_NAME_ENTRY, \
501                 (char *(*)())d2i_X509_NAME_ENTRY,\
502                 (char *)ne)
503
504 #define X509_digest(data,type,md,len) \
505         ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len)
506 #define X509_NAME_digest(data,type,md,len) \
507         ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len)
508 #ifndef PKCS7_ISSUER_AND_SERIAL_digest
509 #define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \
510         ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\
511                 (char *)data,md,len)
512 #endif
513 #endif
514
515 #define X509_EXT_PACK_UNKNOWN   1
516 #define X509_EXT_PACK_STRING    2
517
518 #define         X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version)
519 /* #define      X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */
520 #define         X509_get_notBefore(x) ((x)->cert_info->validity->notBefore)
521 #define         X509_get_notAfter(x) ((x)->cert_info->validity->notAfter)
522 #define         X509_extract_key(x)     X509_get_pubkey(x) /*****/
523 #define         X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version)
524 #define         X509_REQ_get_subject_name(x) ((x)->req_info->subject)
525 #define         X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)
526 #define         X509_name_cmp(a,b)      X509_NAME_cmp((a),(b))
527 #define         X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm))
528
529 #define         X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version)
530 #define         X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate)
531 #define         X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate)
532 #define         X509_CRL_get_issuer(x) ((x)->crl->issuer)
533 #define         X509_CRL_get_REVOKED(x) ((x)->crl->revoked)
534
535 /* This one is only used so that a binary form can output, as in
536  * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */
537 #define         X509_get_X509_PUBKEY(x) ((x)->cert_info->key)
538
539
540 #ifndef SSLEAY_MACROS
541 #ifdef HEADER_ENVELOPE_H
542 int X509_verify(X509 *a, EVP_PKEY *r);
543 const char *X509_verify_cert_error_string(long n);
544
545 int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
546 int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
547 int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
548
549 int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
550 int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
551 int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
552 int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
553
554 int X509_digest(X509 *data,EVP_MD *type,unsigned char *md,unsigned int *len);
555 int X509_NAME_digest(X509_NAME *data,EVP_MD *type,
556         unsigned char *md,unsigned int *len);
557 #endif
558
559 #ifndef NO_FP_API
560 X509 *d2i_X509_fp(FILE *fp, X509 **x509);
561 int i2d_X509_fp(FILE *fp,X509 *x509);
562 X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl);
563 int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl);
564 X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req);
565 int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req);
566 #ifndef NO_RSA
567 RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
568 int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
569 RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
570 int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
571 #endif
572 #ifndef NO_DSA
573 DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
574 int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
575 #endif
576 #endif
577
578 #ifdef HEADER_BIO_H
579 X509 *d2i_X509_bio(BIO *bp,X509 **x509);
580 int i2d_X509_bio(BIO *bp,X509 *x509);
581 X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl);
582 int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl);
583 X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req);
584 int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req);
585 #ifndef NO_RSA
586 RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
587 int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
588 RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
589 int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
590 #endif
591 #ifndef NO_DSA
592 DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
593 int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
594 #endif
595 #endif
596
597 X509 *X509_dup(X509 *x509);
598 X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);
599 X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);
600 X509_CRL *X509_CRL_dup(X509_CRL *crl);
601 X509_REQ *X509_REQ_dup(X509_REQ *req);
602 X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
603 X509_NAME *X509_NAME_dup(X509_NAME *xn);
604 X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
605 #ifndef NO_RSA
606 RSA *RSAPublicKey_dup(RSA *rsa);
607 RSA *RSAPrivateKey_dup(RSA *rsa);
608 #endif
609
610 #endif /* !SSLEAY_MACROS */
611
612 int             X509_cmp_current_time(ASN1_UTCTIME *s);
613 ASN1_UTCTIME *  X509_gmtime_adj(ASN1_UTCTIME *s, long adj);
614
615 const char *    X509_get_default_cert_area(void );
616 const char *    X509_get_default_cert_dir(void );
617 const char *    X509_get_default_cert_file(void );
618 const char *    X509_get_default_cert_dir_env(void );
619 const char *    X509_get_default_cert_file_env(void );
620 const char *    X509_get_default_private_dir(void );
621
622 X509_REQ *      X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, EVP_MD *md);
623 X509 *          X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);
624 void ERR_load_X509_strings(void );
625
626 X509_ALGOR *    X509_ALGOR_new(void );
627 void            X509_ALGOR_free(X509_ALGOR *a);
628 int             i2d_X509_ALGOR(X509_ALGOR *a,unsigned char **pp);
629 X509_ALGOR *    d2i_X509_ALGOR(X509_ALGOR **a,unsigned char **pp,
630                         long length);
631
632 X509_VAL *      X509_VAL_new(void );
633 void            X509_VAL_free(X509_VAL *a);
634 int             i2d_X509_VAL(X509_VAL *a,unsigned char **pp);
635 X509_VAL *      d2i_X509_VAL(X509_VAL **a,unsigned char **pp,
636                         long length);
637
638 X509_PUBKEY *   X509_PUBKEY_new(void );
639 void            X509_PUBKEY_free(X509_PUBKEY *a);
640 int             i2d_X509_PUBKEY(X509_PUBKEY *a,unsigned char **pp);
641 X509_PUBKEY *   d2i_X509_PUBKEY(X509_PUBKEY **a,unsigned char **pp,
642                         long length);
643 int             X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
644 EVP_PKEY *      X509_PUBKEY_get(X509_PUBKEY *key);
645 int             X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK *chain);
646
647
648 X509_SIG *      X509_SIG_new(void );
649 void            X509_SIG_free(X509_SIG *a);
650 int             i2d_X509_SIG(X509_SIG *a,unsigned char **pp);
651 X509_SIG *      d2i_X509_SIG(X509_SIG **a,unsigned char **pp,long length);
652
653 X509_REQ_INFO *X509_REQ_INFO_new(void);
654 void            X509_REQ_INFO_free(X509_REQ_INFO *a);
655 int             i2d_X509_REQ_INFO(X509_REQ_INFO *a,unsigned char **pp);
656 X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a,unsigned char **pp,
657                         long length);
658
659 X509_REQ *      X509_REQ_new(void);
660 void            X509_REQ_free(X509_REQ *a);
661 int             i2d_X509_REQ(X509_REQ *a,unsigned char **pp);
662 X509_REQ *      d2i_X509_REQ(X509_REQ **a,unsigned char **pp,long length);
663
664 X509_ATTRIBUTE *X509_ATTRIBUTE_new(void );
665 void            X509_ATTRIBUTE_free(X509_ATTRIBUTE *a);
666 int             i2d_X509_ATTRIBUTE(X509_ATTRIBUTE *a,unsigned char **pp);
667 X509_ATTRIBUTE *d2i_X509_ATTRIBUTE(X509_ATTRIBUTE **a,unsigned char **pp,
668                         long length);
669 X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
670
671
672 X509_EXTENSION *X509_EXTENSION_new(void );
673 void            X509_EXTENSION_free(X509_EXTENSION *a);
674 int             i2d_X509_EXTENSION(X509_EXTENSION *a,unsigned char **pp);
675 X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a,unsigned char **pp,
676                         long length);
677
678 X509_NAME_ENTRY *X509_NAME_ENTRY_new(void);
679 void            X509_NAME_ENTRY_free(X509_NAME_ENTRY *a);
680 int             i2d_X509_NAME_ENTRY(X509_NAME_ENTRY *a,unsigned char **pp);
681 X509_NAME_ENTRY *d2i_X509_NAME_ENTRY(X509_NAME_ENTRY **a,unsigned char **pp,
682                         long length);
683
684 X509_NAME *     X509_NAME_new(void);
685 void            X509_NAME_free(X509_NAME *a);
686 int             i2d_X509_NAME(X509_NAME *a,unsigned char **pp);
687 X509_NAME *     d2i_X509_NAME(X509_NAME **a,unsigned char **pp,long length);
688 int             X509_NAME_set(X509_NAME **xn, X509_NAME *name);
689
690
691 X509_CINF *     X509_CINF_new(void);
692 void            X509_CINF_free(X509_CINF *a);
693 int             i2d_X509_CINF(X509_CINF *a,unsigned char **pp);
694 X509_CINF *     d2i_X509_CINF(X509_CINF **a,unsigned char **pp,long length);
695
696 X509 *          X509_new(void);
697 void            X509_free(X509 *a);
698 int             i2d_X509(X509 *a,unsigned char **pp);
699 X509 *          d2i_X509(X509 **a,unsigned char **pp,long length);
700
701 X509_REVOKED *  X509_REVOKED_new(void);
702 void            X509_REVOKED_free(X509_REVOKED *a);
703 int             i2d_X509_REVOKED(X509_REVOKED *a,unsigned char **pp);
704 X509_REVOKED *  d2i_X509_REVOKED(X509_REVOKED **a,unsigned char **pp,long length);
705
706 X509_CRL_INFO *X509_CRL_INFO_new(void);
707 void            X509_CRL_INFO_free(X509_CRL_INFO *a);
708 int             i2d_X509_CRL_INFO(X509_CRL_INFO *a,unsigned char **pp);
709 X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a,unsigned char **pp,
710                         long length);
711
712 X509_CRL *      X509_CRL_new(void);
713 void            X509_CRL_free(X509_CRL *a);
714 int             i2d_X509_CRL(X509_CRL *a,unsigned char **pp);
715 X509_CRL *      d2i_X509_CRL(X509_CRL **a,unsigned char **pp,long length);
716
717 X509_PKEY *     X509_PKEY_new(void );
718 void            X509_PKEY_free(X509_PKEY *a);
719 int             i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp);
720 X509_PKEY *     d2i_X509_PKEY(X509_PKEY **a,unsigned char **pp,long length);
721
722 NETSCAPE_SPKI * NETSCAPE_SPKI_new(void );
723 void            NETSCAPE_SPKI_free(NETSCAPE_SPKI *a);
724 int             i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a,unsigned char **pp);
725 NETSCAPE_SPKI * d2i_NETSCAPE_SPKI(NETSCAPE_SPKI **a,unsigned char **pp,
726                         long length);
727
728 NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void );
729 void            NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a);
730 int             i2d_NETSCAPE_SPKAC(NETSCAPE_SPKAC *a,unsigned char **pp);
731 NETSCAPE_SPKAC *d2i_NETSCAPE_SPKAC(NETSCAPE_SPKAC **a,unsigned char **pp,
732                 long length);
733
734
735 int i2d_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE *a, unsigned char **pp);
736 NETSCAPE_CERT_SEQUENCE *NETSCAPE_CERT_SEQUENCE_new(void);
737 NETSCAPE_CERT_SEQUENCE *d2i_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE **a, unsigned char **pp, long length);
738 void NETSCAPE_CERT_SEQUENCE_free(NETSCAPE_CERT_SEQUENCE *a);
739
740 #ifdef HEADER_ENVELOPE_H
741 X509_INFO *     X509_INFO_new(void);
742 void            X509_INFO_free(X509_INFO *a);
743 char *          X509_NAME_oneline(X509_NAME *a,char *buf,int size);
744
745 int ASN1_verify(int (*i2d)(), X509_ALGOR *algor1,
746         ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey);
747
748 int ASN1_digest(int (*i2d)(),EVP_MD *type,char *data,
749         unsigned char *md,unsigned int *len);
750
751 int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
752         ASN1_BIT_STRING *signature,
753         char *data,EVP_PKEY *pkey, const EVP_MD *type);
754 #endif
755
756 int             X509_set_version(X509 *x,long version);
757 int             X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
758 ASN1_INTEGER *  X509_get_serialNumber(X509 *x);
759 int             X509_set_issuer_name(X509 *x, X509_NAME *name);
760 X509_NAME *     X509_get_issuer_name(X509 *a);
761 int             X509_set_subject_name(X509 *x, X509_NAME *name);
762 X509_NAME *     X509_get_subject_name(X509 *a);
763 int             X509_set_notBefore(X509 *x, ASN1_UTCTIME *tm);
764 int             X509_set_notAfter(X509 *x, ASN1_UTCTIME *tm);
765 int             X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
766 EVP_PKEY *      X509_get_pubkey(X509 *x);
767 int             X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */);
768
769 int             X509_REQ_set_version(X509_REQ *x,long version);
770 int             X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name);
771 int             X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
772 EVP_PKEY *      X509_REQ_get_pubkey(X509_REQ *req);
773
774 int             X509_check_private_key(X509 *x509,EVP_PKEY *pkey);
775
776 int             X509_issuer_and_serial_cmp(X509 *a, X509 *b);
777 unsigned long   X509_issuer_and_serial_hash(X509 *a);
778
779 int             X509_issuer_name_cmp(X509 *a, X509 *b);
780 unsigned long   X509_issuer_name_hash(X509 *a);
781
782 int             X509_subject_name_cmp(X509 *a,X509 *b);
783 unsigned long   X509_subject_name_hash(X509 *x);
784
785 int             X509_NAME_cmp (X509_NAME *a, X509_NAME *b);
786 unsigned long   X509_NAME_hash(X509_NAME *x);
787
788 int             X509_CRL_cmp(X509_CRL *a,X509_CRL *b);
789 #ifndef NO_FP_API
790 int             X509_print_fp(FILE *bp,X509 *x);
791 int             X509_CRL_print_fp(FILE *bp,X509_CRL *x);
792 int             X509_REQ_print_fp(FILE *bp,X509_REQ *req);
793 #endif
794
795 #ifdef HEADER_BIO_H
796 int             X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
797 int             X509_print(BIO *bp,X509 *x);
798 int             X509_CRL_print(BIO *bp,X509_CRL *x);
799 int             X509_REQ_print(BIO *bp,X509_REQ *req);
800 #endif
801
802 int             X509_NAME_entry_count(X509_NAME *name);
803 int             X509_NAME_get_text_by_NID(X509_NAME *name, int nid,
804                         char *buf,int len);
805 int             X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
806                         char *buf,int len);
807
808 /* NOTE: you should be passsing -1, not 0 as lastpos.  The functions that use
809  * lastpos, seach after that position on. */
810 int             X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
811 int             X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj,
812                         int lastpos);
813 X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
814 X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
815 int             X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne,
816                         int loc, int set);
817 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
818                         int type,unsigned char *bytes, int len);
819 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
820                         ASN1_OBJECT *obj, int type,unsigned char *bytes,
821                         int len);
822 int             X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne,
823                         ASN1_OBJECT *obj);
824 int             X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
825                         unsigned char *bytes, int len);
826 ASN1_OBJECT *   X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);
827 ASN1_STRING *   X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);
828
829 int             X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
830 int             X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
831                                       int nid, int lastpos);
832 int             X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
833                                       ASN1_OBJECT *obj,int lastpos);
834 int             X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
835                                            int crit, int lastpos);
836 X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
837 X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
838 STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
839                                          X509_EXTENSION *ex, int loc);
840
841 int             X509_get_ext_count(X509 *x);
842 int             X509_get_ext_by_NID(X509 *x, int nid, int lastpos);
843 int             X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos);
844 int             X509_get_ext_by_critical(X509 *x, int crit, int lastpos);
845 X509_EXTENSION *X509_get_ext(X509 *x, int loc);
846 X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
847 int             X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
848
849 int             X509_CRL_get_ext_count(X509_CRL *x);
850 int             X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);
851 int             X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos);
852 int             X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);
853 X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);
854 X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
855 int             X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
856
857 int             X509_REVOKED_get_ext_count(X509_REVOKED *x);
858 int             X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);
859 int             X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos);
860 int             X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);
861 X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);
862 X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
863 int             X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
864
865 X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
866                         int nid, int crit, ASN1_OCTET_STRING *data);
867 X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
868                         ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data);
869 int             X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj);
870 int             X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
871 int             X509_EXTENSION_set_data(X509_EXTENSION *ex,
872                         ASN1_OCTET_STRING *data);
873 ASN1_OBJECT *   X509_EXTENSION_get_object(X509_EXTENSION *ex);
874 ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
875 int             X509_EXTENSION_get_critical(X509_EXTENSION *ex);
876
877 int             X509_verify_cert(X509_STORE_CTX *ctx);
878
879 /* lookup a cert from a X509 STACK */
880 X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name,
881                                      ASN1_INTEGER *serial);
882 X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name);
883
884 int i2d_PBEPARAM(PBEPARAM *a, unsigned char **pp);
885 PBEPARAM *PBEPARAM_new(void);
886 PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, unsigned char **pp, long length);
887 void PBEPARAM_free(PBEPARAM *a);
888 X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen);
889
890 int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp);
891 PBKDF2PARAM *PBKDF2PARAM_new(void);
892 PBKDF2PARAM *d2i_PBKDF2PARAM(PBKDF2PARAM **a, unsigned char **pp, long length);
893 void PBKDF2PARAM_free(PBKDF2PARAM *a);
894
895 int i2d_PBE2PARAM(PBE2PARAM *a, unsigned char **pp);
896 PBE2PARAM *PBE2PARAM_new(void);
897 PBE2PARAM *d2i_PBE2PARAM(PBE2PARAM **a, unsigned char **pp, long length);
898 void PBE2PARAM_free(PBE2PARAM *a);
899
900 /* PKCS#8 utilities */
901
902 int i2d_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO *a, unsigned char **pp);
903 PKCS8_PRIV_KEY_INFO *PKCS8_PRIV_KEY_INFO_new(void);
904 PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a,
905                                          unsigned char **pp, long length);
906 void PKCS8_PRIV_KEY_INFO_free(PKCS8_PRIV_KEY_INFO *a);
907
908 EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);
909 PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
910 PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
911
912 /* Password based encryption routines */
913
914 int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
915              unsigned char *salt, int saltlen, int iter, EVP_CIPHER_CTX *ctx,
916              int en_de);
917 int EVP_PBE_ALGOR_CipherInit(X509_ALGOR *algor, const char *pass,
918                              int passlen, EVP_CIPHER_CTX *ctx, int en_de);
919 int EVP_PBE_alg_add(int nid, EVP_CIPHER *cipher, EVP_MD *md,
920                     EVP_PBE_KEYGEN *keygen);
921 void EVP_PBE_cleanup(void);
922
923 /* BEGIN ERROR CODES */
924 /* The following lines are auto generated by the script mkerr.pl. Any changes
925  * made after this point may be overwritten when the script is next run.
926  */
927
928 /* Error codes for the X509 functions. */
929
930 /* Function codes. */
931 #define X509_F_ADD_CERT_DIR                              100
932 #define X509_F_BY_FILE_CTRL                              101
933 #define X509_F_DIR_CTRL                                  102
934 #define X509_F_GET_CERT_BY_SUBJECT                       103
935 #define X509_F_X509V3_ADD_EXT                            104
936 #define X509_F_X509_CHECK_PRIVATE_KEY                    128
937 #define X509_F_X509_EXTENSION_CREATE_BY_NID              108
938 #define X509_F_X509_EXTENSION_CREATE_BY_OBJ              109
939 #define X509_F_X509_GET_PUBKEY_PARAMETERS                110
940 #define X509_F_X509_LOAD_CERT_FILE                       111
941 #define X509_F_X509_LOAD_CRL_FILE                        112
942 #define X509_F_X509_NAME_ADD_ENTRY                       113
943 #define X509_F_X509_NAME_ENTRY_CREATE_BY_NID             114
944 #define X509_F_X509_NAME_ENTRY_SET_OBJECT                115
945 #define X509_F_X509_NAME_ONELINE                         116
946 #define X509_F_X509_NAME_PRINT                           117
947 #define X509_F_X509_PRINT_FP                             118
948 #define X509_F_X509_PUBKEY_GET                           119
949 #define X509_F_X509_PUBKEY_SET                           120
950 #define X509_F_X509_REQ_PRINT                            121
951 #define X509_F_X509_REQ_PRINT_FP                         122
952 #define X509_F_X509_REQ_TO_X509                          123
953 #define X509_F_X509_STORE_ADD_CERT                       124
954 #define X509_F_X509_STORE_ADD_CRL                        125
955 #define X509_F_X509_TO_X509_REQ                          126
956 #define X509_F_X509_VERIFY_CERT                          127
957
958 /* Reason codes. */
959 #define X509_R_BAD_X509_FILETYPE                         100
960 #define X509_R_CANT_CHECK_DH_KEY                         114
961 #define X509_R_CERT_ALREADY_IN_HASH_TABLE                101
962 #define X509_R_ERR_ASN1_LIB                              102
963 #define X509_R_INVALID_DIRECTORY                         113
964 #define X509_R_KEY_TYPE_MISMATCH                         115
965 #define X509_R_KEY_VALUES_MISMATCH                       116
966 #define X509_R_LOADING_CERT_DIR                          103
967 #define X509_R_LOADING_DEFAULTS                          104
968 #define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY              105
969 #define X509_R_SHOULD_RETRY                              106
970 #define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN        107
971 #define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY            108
972 #define X509_R_UNKNOWN_KEY_TYPE                          117
973 #define X509_R_UNKNOWN_NID                               109
974 #define X509_R_UNSUPPORTED_ALGORITHM                     111
975 #define X509_R_WRONG_LOOKUP_TYPE                         112
976
977 #ifdef  __cplusplus
978 }
979 #endif
980 #endif
981