Fix const declarations.
[openssl.git] / crypto / pem / pem.h
1 /* crypto/pem/pem.org */
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 /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 
60  *
61  * Always modify pem.org since pem.h is automatically generated from
62  * it during SSLeay configuration.
63  *
64  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65  */
66
67 #ifndef HEADER_PEM_H
68 #define HEADER_PEM_H
69
70 #ifdef  __cplusplus
71 extern "C" {
72 #endif
73
74 #include "evp.h"
75 #include "x509.h"
76 #include "pem2.h"
77
78 #define PEM_OBJ_UNDEF           0
79 #define PEM_OBJ_X509            1
80 #define PEM_OBJ_X509_REQ        2
81 #define PEM_OBJ_CRL             3
82 #define PEM_OBJ_SSL_SESSION     4
83 #define PEM_OBJ_PRIV_KEY        10
84 #define PEM_OBJ_PRIV_RSA        11
85 #define PEM_OBJ_PRIV_DSA        12
86 #define PEM_OBJ_PRIV_DH         13
87 #define PEM_OBJ_PUB_RSA         14
88 #define PEM_OBJ_PUB_DSA         15
89 #define PEM_OBJ_PUB_DH          16
90 #define PEM_OBJ_DHPARAMS        17
91 #define PEM_OBJ_DSAPARAMS       18
92 #define PEM_OBJ_PRIV_RSA_PUBLIC 19
93
94 #define PEM_ERROR               30
95 #define PEM_DEK_DES_CBC         40
96 #define PEM_DEK_IDEA_CBC        45
97 #define PEM_DEK_DES_EDE         50
98 #define PEM_DEK_DES_ECB         60
99 #define PEM_DEK_RSA             70
100 #define PEM_DEK_RSA_MD2         80
101 #define PEM_DEK_RSA_MD5         90
102
103 #define PEM_MD_MD2              NID_md2
104 #define PEM_MD_MD5              NID_md5
105 #define PEM_MD_SHA              NID_sha
106 #define PEM_MD_MD2_RSA          NID_md2WithRSAEncryption
107 #define PEM_MD_MD5_RSA          NID_md5WithRSAEncryption
108 #define PEM_MD_SHA_RSA          NID_sha1WithRSAEncryption
109
110 #define PEM_STRING_X509_OLD     "X509 CERTIFICATE"
111 #define PEM_STRING_X509         "CERTIFICATE"
112 #define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
113 #define PEM_STRING_X509_REQ     "CERTIFICATE REQUEST"
114 #define PEM_STRING_X509_CRL     "X509 CRL"
115 #define PEM_STRING_EVP_PKEY     "PRIVATE KEY"
116 #define PEM_STRING_RSA          "RSA PRIVATE KEY"
117 #define PEM_STRING_RSA_PUBLIC   "RSA PUBLIC KEY"
118 #define PEM_STRING_DSA          "DSA PRIVATE KEY"
119 #define PEM_STRING_PKCS7        "PKCS7"
120 #define PEM_STRING_DHPARAMS     "DH PARAMETERS"
121 #define PEM_STRING_SSL_SESSION  "SSL SESSION PARAMETERS"
122 #define PEM_STRING_DSAPARAMS    "DSA PARAMETERS"
123
124
125 typedef struct PEM_Encode_Seal_st
126         {
127         EVP_ENCODE_CTX encode;
128         EVP_MD_CTX md;
129         EVP_CIPHER_CTX cipher;
130         } PEM_ENCODE_SEAL_CTX;
131
132 /* enc_type is one off */
133 #define PEM_TYPE_ENCRYPTED      10
134 #define PEM_TYPE_MIC_ONLY       20
135 #define PEM_TYPE_MIC_CLEAR      30
136 #define PEM_TYPE_CLEAR          40
137
138 typedef struct pem_recip_st
139         {
140         char *name;
141         X509_NAME *dn;
142
143         int cipher;
144         int key_enc;
145         char iv[8];
146         } PEM_USER;
147
148 typedef struct pem_ctx_st
149         {
150         int type;               /* what type of object */
151
152         struct  {
153                 int version;    
154                 int mode;               
155                 } proc_type;
156
157         char *domain;
158
159         struct  {
160                 int cipher;
161                 unsigned char iv[8];
162                 } DEK_info;
163                 
164         PEM_USER *originator;
165
166         int num_recipient;
167         PEM_USER **recipient;
168
169 #ifdef HEADER_STACK_H
170         STACK *x509_chain;      /* certificate chain */
171 #else
172         char *x509_chain;       /* certificate chain */
173 #endif
174         EVP_MD *md;             /* signature type */
175
176         int md_enc;             /* is the md encrypted or not? */
177         int md_len;             /* length of md_data */
178         char *md_data;          /* message digest, could be pkey encrypted */
179
180         EVP_CIPHER *dec;        /* date encryption cipher */
181         int key_len;            /* key length */
182         unsigned char *key;     /* key */
183         unsigned char iv[8];    /* the iv */
184
185         
186         int  data_enc;          /* is the data encrypted */
187         int data_len;
188         unsigned char *data;
189         } PEM_CTX;
190
191 #ifdef SSLEAY_MACROS
192
193 #define PEM_write_SSL_SESSION(fp,x) \
194                 PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \
195                         PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL)
196 #define PEM_write_X509(fp,x) \
197                 PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \
198                         (char *)x, NULL,NULL,0,NULL)
199 #define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \
200                 (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \
201                         NULL,NULL,0,NULL)
202 #define PEM_write_X509_CRL(fp,x) \
203                 PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \
204                         fp,(char *)x, NULL,NULL,0,NULL)
205 #define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb) \
206                 PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\
207                         (char *)x,enc,kstr,klen,cb)
208 #define PEM_write_RSAPublicKey(fp,x) \
209                 PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\
210                         PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL)
211 #define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb) \
212                 PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\
213                         (char *)x,enc,kstr,klen,cb)
214 #define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb) \
215                 PEM_ASN1_write((int (*)())i2d_PrivateKey,\
216                 (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
217                         bp,(char *)x,enc,kstr,klen,cb)
218 #define PEM_write_PKCS7(fp,x) \
219                 PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \
220                         (char *)x, NULL,NULL,0,NULL)
221 #define PEM_write_DHparams(fp,x) \
222                 PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\
223                         (char *)x,NULL,NULL,0,NULL)
224
225 #define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \
226                 PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
227                         PEM_STRING_X509,fp, \
228                         (char *)x, NULL,NULL,0,NULL)
229
230 #define PEM_read_SSL_SESSION(fp,x,cb) (SSL_SESSION *)PEM_ASN1_read( \
231         (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb)
232 #define PEM_read_X509(fp,x,cb) (X509 *)PEM_ASN1_read( \
233         (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb)
234 #define PEM_read_X509_REQ(fp,x,cb) (X509_REQ *)PEM_ASN1_read( \
235         (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb)
236 #define PEM_read_X509_CRL(fp,x,cb) (X509_CRL *)PEM_ASN1_read( \
237         (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb)
238 #define PEM_read_RSAPrivateKey(fp,x,cb) (RSA *)PEM_ASN1_read( \
239         (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb)
240 #define PEM_read_RSAPublicKey(fp,x,cb) (RSA *)PEM_ASN1_read( \
241         (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb)
242 #define PEM_read_DSAPrivateKey(fp,x,cb) (DSA *)PEM_ASN1_read( \
243         (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb)
244 #define PEM_read_PrivateKey(fp,x,cb) (EVP_PKEY *)PEM_ASN1_read( \
245         (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb)
246 #define PEM_read_PKCS7(fp,x,cb) (PKCS7 *)PEM_ASN1_read( \
247         (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb)
248 #define PEM_read_DHparams(fp,x,cb) (DH *)PEM_ASN1_read( \
249         (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb)
250
251 #define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb) \
252                 (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \
253         (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\
254                                                         (char **)x,cb)
255
256 #define PEM_write_bio_SSL_SESSION(bp,x) \
257                 PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \
258                         PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL)
259 #define PEM_write_bio_X509(bp,x) \
260                 PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \
261                         (char *)x, NULL,NULL,0,NULL)
262 #define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \
263                 (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \
264                         NULL,NULL,0,NULL)
265 #define PEM_write_bio_X509_CRL(bp,x) \
266                 PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\
267                         bp,(char *)x, NULL,NULL,0,NULL)
268 #define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb) \
269                 PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\
270                         bp,(char *)x,enc,kstr,klen,cb)
271 #define PEM_write_bio_RSAPublicKey(bp,x) \
272                 PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \
273                         PEM_STRING_RSA_PUBLIC,\
274                         bp,(char *)x,NULL,NULL,0,NULL)
275 #define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb) \
276                 PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\
277                         bp,(char *)x,enc,kstr,klen,cb)
278 #define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb) \
279                 PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\
280                 (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
281                         bp,(char *)x,enc,kstr,klen,cb)
282 #define PEM_write_bio_PKCS7(bp,x) \
283                 PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \
284                         (char *)x, NULL,NULL,0,NULL)
285 #define PEM_write_bio_DHparams(bp,x) \
286                 PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\
287                         bp,(char *)x,NULL,NULL,0,NULL)
288 #define PEM_write_bio_DSAparams(bp,x) \
289                 PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \
290                         PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL)
291
292 #define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \
293                 PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
294                         PEM_STRING_X509,bp, \
295                         (char *)x, NULL,NULL,0,NULL)
296
297 #define PEM_read_bio_SSL_SESSION(bp,x,cb) (SSL_SESSION *)PEM_ASN1_read_bio( \
298         (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,(char **)x,cb)
299 #define PEM_read_bio_X509(bp,x,cb) (X509 *)PEM_ASN1_read_bio( \
300         (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb)
301 #define PEM_read_bio_X509_REQ(bp,x,cb) (X509_REQ *)PEM_ASN1_read_bio( \
302         (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb)
303 #define PEM_read_bio_X509_CRL(bp,x,cb) (X509_CRL *)PEM_ASN1_read_bio( \
304         (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb)
305 #define PEM_read_bio_RSAPrivateKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \
306         (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb)
307 #define PEM_read_bio_RSAPublicKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \
308         (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb)
309 #define PEM_read_bio_DSAPrivateKey(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \
310         (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb)
311 #define PEM_read_bio_PrivateKey(bp,x,cb) (EVP_PKEY *)PEM_ASN1_read_bio( \
312         (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb)
313
314 #define PEM_read_bio_PKCS7(bp,x,cb) (PKCS7 *)PEM_ASN1_read_bio( \
315         (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb)
316 #define PEM_read_bio_DHparams(bp,x,cb) (DH *)PEM_ASN1_read_bio( \
317         (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb)
318 #define PEM_read_bio_DSAparams(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \
319         (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb)
320
321 #define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb) \
322                 (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \
323         (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\
324                                                         (char **)x,cb)
325
326 #endif
327
328 #ifndef NOPROTO
329 int     PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
330 int     PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
331                 int (*callback)());
332
333 #ifdef HEADER_BIO_H
334 int     PEM_read_bio(BIO *bp, char **name, char **header,
335                 unsigned char **data,long *len);
336 int     PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data,
337                 long len);
338 char *  PEM_ASN1_read_bio(char *(*d2i)(),const char *name,BIO *bp,char **x,
339                 int (*cb)());
340 int     PEM_ASN1_write_bio(int (*i2d)(),const char *name,BIO *bp,char *x,
341                            const EVP_CIPHER *enc,unsigned char *kstr,int klen,
342                            int (*callback)());
343 STACK * PEM_X509_INFO_read_bio(BIO *bp, STACK *sk, int (*cb)());
344 int     PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
345                 unsigned char *kstr, int klen, int (*cb)());
346 #endif
347
348 #ifndef WIN16
349 int     PEM_read(FILE *fp, char **name, char **header,
350                 unsigned char **data,long *len);
351 int     PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
352 char *  PEM_ASN1_read(char *(*d2i)(),const char *name,FILE *fp,char **x,
353                 int (*cb)());
354 int     PEM_ASN1_write(int (*i2d)(),const char *name,FILE *fp,char *x,
355                        const EVP_CIPHER *enc,unsigned char *kstr,int klen,
356                        int (*callback)());
357 STACK * PEM_X509_INFO_read(FILE *fp, STACK *sk, int (*cb)());
358 #endif
359
360 int     PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
361                 EVP_MD *md_type, unsigned char **ek, int *ekl,
362                 unsigned char *iv, EVP_PKEY **pubk, int npubk);
363 void    PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
364                 unsigned char *in, int inl);
365 int     PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl,
366                 unsigned char *out, int *outl, EVP_PKEY *priv);
367
368 void    PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
369 void    PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
370 int     PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
371                 unsigned int *siglen, EVP_PKEY *pkey);
372
373 void    PEM_proc_type(char *buf, int type);
374 void    PEM_dek_info(char *buf, const char *type, int len, char *str);
375
376 #ifndef SSLEAY_MACROS
377
378 #ifndef WIN16
379 X509 *PEM_read_X509(FILE *fp,X509 **x,int (*cb)());
380 X509_REQ *PEM_read_X509_REQ(FILE *fp,X509_REQ **x,int (*cb)());
381 X509_CRL *PEM_read_X509_CRL(FILE *fp,X509_CRL **x,int (*cb)());
382 RSA *PEM_read_RSAPrivateKey(FILE *fp,RSA **x,int (*cb)());
383 RSA *PEM_read_RSAPublicKey(FILE *fp,RSA **x,int (*cb)());
384 DSA *PEM_read_DSAPrivateKey(FILE *fp,DSA **x,int (*cb)());
385 EVP_PKEY *PEM_read_PrivateKey(FILE *fp,EVP_PKEY **x,int (*cb)());
386 PKCS7 *PEM_read_PKCS7(FILE *fp,PKCS7 **x,int (*cb)());
387 DH *PEM_read_DHparams(FILE *fp,DH **x,int (*cb)());
388 DSA *PEM_read_DSAparams(FILE *fp,DSA **x,int (*cb)());
389 NETSCAPE_CERT_SEQUENCE *PEM_read_NETSCAPE_CERT_SEQUENCE(FILE *fp,NETSCAPE_CERT_SEQUENCE **x,int (*cb)());
390 int PEM_write_X509(FILE *fp,X509 *x);
391 int PEM_write_X509_REQ(FILE *fp,X509_REQ *x);
392 int PEM_write_X509_CRL(FILE *fp,X509_CRL *x);
393 int PEM_write_RSAPrivateKey(FILE *fp,RSA *x,EVP_CIPHER *enc,unsigned char *kstr,
394         int klen,int (*cb)());
395 int PEM_write_RSAPublicKey(FILE *fp,RSA *x);
396 int PEM_write_DSAPrivateKey(FILE *fp,DSA *x,const EVP_CIPHER *enc,
397                             unsigned char *kstr,
398         int klen,int (*cb)());
399 int PEM_write_PrivateKey(FILE *fp,EVP_PKEY *x,EVP_CIPHER *enc,
400         unsigned char *kstr,int klen,int (*cb)());
401 int PEM_write_PKCS7(FILE *fp,PKCS7 *x);
402 int PEM_write_DHparams(FILE *fp,DH *x);
403 int PEM_write_DSAparams(FILE *fp,DSA *x);
404 int PEM_write_NETSCAPE_CERT_SEQUENCE(FILE *fp,NETSCAPE_CERT_SEQUENCE *x);
405 #endif
406
407 #ifdef HEADER_BIO_H
408 X509 *PEM_read_bio_X509(BIO *bp,X509 **x,int (*cb)());
409 X509_REQ *PEM_read_bio_X509_REQ(BIO *bp,X509_REQ **x,int (*cb)());
410 X509_CRL *PEM_read_bio_X509_CRL(BIO *bp,X509_CRL **x,int (*cb)());
411 RSA *PEM_read_bio_RSAPrivateKey(BIO *bp,RSA **x,int (*cb)());
412 RSA *PEM_read_bio_RSAPublicKey(BIO *bp,RSA **x,int (*cb)());
413 DSA *PEM_read_bio_DSAPrivateKey(BIO *bp,DSA **x,int (*cb)());
414 EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp,EVP_PKEY **x,int (*cb)());
415 PKCS7 *PEM_read_bio_PKCS7(BIO *bp,PKCS7 **x,int (*cb)());
416 DH *PEM_read_bio_DHparams(BIO *bp,DH **x,int (*cb)());
417 NETSCAPE_CERT_SEQUENCE *PEM_read_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp,NETSCAPE_CERT_SEQUENCE **x,int (*cb)());
418 DSA *PEM_read_bio_DSAparams(BIO *bp,DSA **x,int (*cb)());
419 int PEM_write_bio_X509(BIO *bp,X509 *x);
420 int PEM_write_bio_X509_REQ(BIO *bp,X509_REQ *x);
421 int PEM_write_bio_X509_CRL(BIO *bp,X509_CRL *x);
422 int PEM_write_bio_RSAPrivateKey(BIO *fp,RSA *x,const EVP_CIPHER *enc,
423         unsigned char *kstr,int klen,int (*cb)());
424 int PEM_write_bio_RSAPublicKey(BIO *fp,RSA *x);
425 int PEM_write_bio_DSAPrivateKey(BIO *fp,DSA *x,const EVP_CIPHER *enc,
426         unsigned char *kstr,int klen,int (*cb)());
427 int PEM_write_bio_PrivateKey(BIO *fp,EVP_PKEY *x,EVP_CIPHER *enc,
428         unsigned char *kstr,int klen,int (*cb)());
429 int PEM_write_bio_PKCS7(BIO *bp,PKCS7 *x);
430 int PEM_write_bio_DHparams(BIO *bp,DH *x);
431 int PEM_write_bio_DSAparams(BIO *bp,DSA *x);
432 int PEM_write_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp,NETSCAPE_CERT_SEQUENCE *x);
433 #endif
434
435 #endif /* SSLEAY_MACROS */
436
437
438 #else
439
440 int     PEM_get_EVP_CIPHER_INFO();
441 int     PEM_do_header();
442 int     PEM_read_bio();
443 int     PEM_write_bio();
444 #ifndef WIN16
445 int     PEM_read();
446 int     PEM_write();
447 STACK * PEM_X509_INFO_read();
448 char *  PEM_ASN1_read();
449 int     PEM_ASN1_write();
450 #endif
451 STACK * PEM_X509_INFO_read_bio();
452 int     PEM_X509_INFO_write_bio();
453 char *  PEM_ASN1_read_bio();
454 int     PEM_ASN1_write_bio();
455 int     PEM_SealInit();
456 void    PEM_SealUpdate();
457 int     PEM_SealFinal();
458 void    PEM_SignInit();
459 void    PEM_SignUpdate();
460 int     PEM_SignFinal();
461
462 void    ERR_load_PEM_strings();
463
464 void    PEM_proc_type();
465 void    PEM_dek_info();
466
467 #ifndef SSLEAY_MACROS
468 #ifndef WIN16
469 X509 *PEM_read_X509();
470 X509_REQ *PEM_read_X509_REQ();
471 X509_CRL *PEM_read_X509_CRL();
472 RSA *PEM_read_RSAPrivateKey();
473 RSA *PEM_read_RSAPublicKey();
474 DSA *PEM_read_DSAPrivateKey();
475 EVP_PKEY *PEM_read_PrivateKey();
476 PKCS7 *PEM_read_PKCS7();
477 DH *PEM_read_DHparams();
478 DSA *PEM_read_DSAparams();
479 NETSCAPE_CERT_SEQUENCE *PEM_read_NETSCAPE_CERT_SEQUENCE();
480 int PEM_write_X509();
481 int PEM_write_X509_REQ();
482 int PEM_write_X509_CRL();
483 int PEM_write_RSAPrivateKey();
484 int PEM_write_RSAPublicKey();
485 int PEM_write_DSAPrivateKey();
486 int PEM_write_PrivateKey();
487 int PEM_write_PKCS7();
488 int PEM_write_DHparams();
489 int PEM_write_DSAparams();
490 int PEM_write_NETSCAPE_CERT_SEQUENCE();
491 #endif
492
493 X509 *PEM_read_bio_X509();
494 X509_REQ *PEM_read_bio_X509_REQ();
495 X509_CRL *PEM_read_bio_X509_CRL();
496 RSA *PEM_read_bio_RSAPrivateKey();
497 RSA *PEM_read_bio_RSAPublicKey();
498 DSA *PEM_read_bio_DSAPrivateKey();
499 EVP_PKEY *PEM_read_bio_PrivateKey();
500 PKCS7 *PEM_read_bio_PKCS7();
501 DH *PEM_read_bio_DHparams();
502 DSA *PEM_read_bio_DSAparams();
503 NETSCAPE_CERT_SEQUENCE *PEM_read_bio_NETSCAPE_CERT_SEQUENCE();
504 int PEM_write_bio_X509();
505 int PEM_write_bio_X509_REQ();
506 int PEM_write_bio_X509_CRL();
507 int PEM_write_bio_RSAPrivateKey();
508 int PEM_write_bio_RSAPublicKey();
509 int PEM_write_bio_DSAPrivateKey();
510 int PEM_write_bio_PrivateKey();
511 int PEM_write_bio_PKCS7();
512 int PEM_write_bio_DHparams();
513 int PEM_write_bio_DSAparams();
514 int PEM_write_bio_NETSCAPE_CERT_SEQUENCE();
515
516 #endif /* SSLEAY_MACROS */
517
518 #endif
519
520 /* BEGIN ERROR CODES */
521 /* Error codes for the PEM functions. */
522
523 /* Function codes. */
524 #define PEM_F_DEF_CALLBACK                               100
525 #define PEM_F_LOAD_IV                                    101
526 #define PEM_F_PEM_ASN1_READ                              102
527 #define PEM_F_PEM_ASN1_READ_BIO                          103
528 #define PEM_F_PEM_ASN1_WRITE                             104
529 #define PEM_F_PEM_ASN1_WRITE_BIO                         105
530 #define PEM_F_PEM_DO_HEADER                              106
531 #define PEM_F_PEM_GET_EVP_CIPHER_INFO                    107
532 #define PEM_F_PEM_READ                                   108
533 #define PEM_F_PEM_READ_BIO                               109
534 #define PEM_F_PEM_SEALFINAL                              110
535 #define PEM_F_PEM_SEALINIT                               111
536 #define PEM_F_PEM_SIGNFINAL                              112
537 #define PEM_F_PEM_WRITE                                  113
538 #define PEM_F_PEM_WRITE_BIO                              114
539 #define PEM_F_PEM_X509_INFO_READ                         115
540 #define PEM_F_PEM_X509_INFO_READ_BIO                     116
541 #define PEM_F_PEM_X509_INFO_WRITE_BIO                    117
542
543 /* Reason codes. */
544 #define PEM_R_BAD_BASE64_DECODE                          100
545 #define PEM_R_BAD_DECRYPT                                101
546 #define PEM_R_BAD_END_LINE                               102
547 #define PEM_R_BAD_IV_CHARS                               103
548 #define PEM_R_BAD_PASSWORD_READ                          104
549 #define PEM_R_NOT_DEK_INFO                               105
550 #define PEM_R_NOT_ENCRYPTED                              106
551 #define PEM_R_NOT_PROC_TYPE                              107
552 #define PEM_R_NO_START_LINE                              108
553 #define PEM_R_PROBLEMS_GETTING_PASSWORD                  109
554 #define PEM_R_PUBLIC_KEY_NO_RSA                          110
555 #define PEM_R_READ_KEY                                   111
556 #define PEM_R_SHORT_HEADER                               112
557 #define PEM_R_UNSUPPORTED_CIPHER                         113
558 #define PEM_R_UNSUPPORTED_ENCRYPTION                     114
559  
560 #ifdef  __cplusplus
561 }
562 #endif
563 #endif
564