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