1 /* crypto/pem/pem.org */
2 /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
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.
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).
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.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
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)"
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
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.]
59 /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
61 * Always modify pem.org since pem.h is automatically generated from
62 * it during SSLeay configuration.
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
77 #define PEM_OBJ_UNDEF 0
78 #define PEM_OBJ_X509 1
79 #define PEM_OBJ_X509_REQ 2
81 #define PEM_OBJ_SSL_SESSION 4
82 #define PEM_OBJ_PRIV_KEY 10
83 #define PEM_OBJ_PRIV_RSA 11
84 #define PEM_OBJ_PRIV_DSA 12
85 #define PEM_OBJ_PRIV_DH 13
86 #define PEM_OBJ_PUB_RSA 14
87 #define PEM_OBJ_PUB_DSA 15
88 #define PEM_OBJ_PUB_DH 16
89 #define PEM_OBJ_DHPARAMS 17
90 #define PEM_OBJ_DSAPARAMS 18
91 #define PEM_OBJ_PRIV_RSA_PUBLIC 19
94 #define PEM_DEK_DES_CBC 40
95 #define PEM_DEK_IDEA_CBC 45
96 #define PEM_DEK_DES_EDE 50
97 #define PEM_DEK_DES_ECB 60
98 #define PEM_DEK_RSA 70
99 #define PEM_DEK_RSA_MD2 80
100 #define PEM_DEK_RSA_MD5 90
102 #define PEM_MD_MD2 NID_md2
103 #define PEM_MD_MD5 NID_md5
104 #define PEM_MD_SHA NID_sha
105 #define PEM_MD_MD2_RSA NID_md2WithRSAEncryption
106 #define PEM_MD_MD5_RSA NID_md5WithRSAEncryption
107 #define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption
109 #define PEM_STRING_X509_OLD "X509 CERTIFICATE"
110 #define PEM_STRING_X509 "CERTIFICATE"
111 #define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
112 #define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
113 #define PEM_STRING_X509_CRL "X509 CRL"
114 #define PEM_STRING_EVP_PKEY "PRIVATE KEY"
115 #define PEM_STRING_RSA "RSA PRIVATE KEY"
116 #define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
117 #define PEM_STRING_DSA "DSA PRIVATE KEY"
118 #define PEM_STRING_PKCS7 "PKCS7"
119 #define PEM_STRING_DHPARAMS "DH PARAMETERS"
120 #define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
121 #define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
123 #ifndef HEADER_ENVELOPE_H
125 #define EVP_ENCODE_CTX_SIZE 92
126 #define EVP_MD_SIZE 48
127 #define EVP_MD_CTX_SIZE 152
128 #define EVP_CIPHER_SIZE 28
129 #define EVP_CIPHER_CTX_SIZE 4212
130 #define EVP_MAX_MD_SIZE 20
132 typedef struct evp_encode_ctx_st
134 char data[EVP_ENCODE_CTX_SIZE];
137 typedef struct env_md_ctx_st
139 char data[EVP_MD_CTX_SIZE];
142 typedef struct evp_cipher_st
144 char data[EVP_CIPHER_SIZE];
147 typedef struct evp_cipher_ctx_st
149 char data[EVP_CIPHER_CTX_SIZE];
154 typedef struct PEM_Encode_Seal_st
156 EVP_ENCODE_CTX encode;
158 EVP_CIPHER_CTX cipher;
159 } PEM_ENCODE_SEAL_CTX;
161 /* enc_type is one off */
162 #define PEM_TYPE_ENCRYPTED 10
163 #define PEM_TYPE_MIC_ONLY 20
164 #define PEM_TYPE_MIC_CLEAR 30
165 #define PEM_TYPE_CLEAR 40
167 typedef struct pem_recip_st
177 typedef struct pem_ctx_st
179 int type; /* what type of object */
193 PEM_USER *originator;
196 PEM_USER **recipient;
198 #ifdef HEADER_STACK_H
199 STACK *x509_chain; /* certificate chain */
201 char *x509_chain; /* certificate chain */
203 EVP_MD *md; /* signature type */
205 int md_enc; /* is the md encrypted or not? */
206 int md_len; /* length of md_data */
207 char *md_data; /* message digest, could be pkey encrypted */
209 EVP_CIPHER *dec; /* date encryption cipher */
210 int key_len; /* key length */
211 unsigned char *key; /* key */
212 unsigned char iv[8]; /* the iv */
215 int data_enc; /* is the data encrypted */
222 #define PEM_write_SSL_SESSION(fp,x) \
223 PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \
224 PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL)
225 #define PEM_write_X509(fp,x) \
226 PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \
227 (char *)x, NULL,NULL,0,NULL)
228 #define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \
229 (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \
231 #define PEM_write_X509_CRL(fp,x) \
232 PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \
233 fp,(char *)x, NULL,NULL,0,NULL)
234 #define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb) \
235 PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\
236 (char *)x,enc,kstr,klen,cb)
237 #define PEM_write_RSAPublicKey(fp,x) \
238 PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\
239 PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL)
240 #define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb) \
241 PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\
242 (char *)x,enc,kstr,klen,cb)
243 #define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb) \
244 PEM_ASN1_write((int (*)())i2d_PrivateKey,\
245 (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
246 bp,(char *)x,enc,kstr,klen,cb)
247 #define PEM_write_PKCS7(fp,x) \
248 PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \
249 (char *)x, NULL,NULL,0,NULL)
250 #define PEM_write_DHparams(fp,x) \
251 PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\
252 (char *)x,NULL,NULL,0,NULL)
254 #define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \
255 PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
256 PEM_STRING_X509,fp, \
257 (char *)x, NULL,NULL,0,NULL)
259 #define PEM_read_SSL_SESSION(fp,x,cb) (SSL_SESSION *)PEM_ASN1_read( \
260 (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb)
261 #define PEM_read_X509(fp,x,cb) (X509 *)PEM_ASN1_read( \
262 (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb)
263 #define PEM_read_X509_REQ(fp,x,cb) (X509_REQ *)PEM_ASN1_read( \
264 (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb)
265 #define PEM_read_X509_CRL(fp,x,cb) (X509_CRL *)PEM_ASN1_read( \
266 (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb)
267 #define PEM_read_RSAPrivateKey(fp,x,cb) (RSA *)PEM_ASN1_read( \
268 (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb)
269 #define PEM_read_RSAPublicKey(fp,x,cb) (RSA *)PEM_ASN1_read( \
270 (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb)
271 #define PEM_read_DSAPrivateKey(fp,x,cb) (DSA *)PEM_ASN1_read( \
272 (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb)
273 #define PEM_read_PrivateKey(fp,x,cb) (EVP_PKEY *)PEM_ASN1_read( \
274 (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb)
275 #define PEM_read_PKCS7(fp,x,cb) (PKCS7 *)PEM_ASN1_read( \
276 (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb)
277 #define PEM_read_DHparams(fp,x,cb) (DH *)PEM_ASN1_read( \
278 (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb)
280 #define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb) \
281 (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \
282 (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\
285 #define PEM_write_bio_SSL_SESSION(bp,x) \
286 PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \
287 PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL)
288 #define PEM_write_bio_X509(bp,x) \
289 PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \
290 (char *)x, NULL,NULL,0,NULL)
291 #define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \
292 (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \
294 #define PEM_write_bio_X509_CRL(bp,x) \
295 PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\
296 bp,(char *)x, NULL,NULL,0,NULL)
297 #define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb) \
298 PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\
299 bp,(char *)x,enc,kstr,klen,cb)
300 #define PEM_write_bio_RSAPublicKey(bp,x) \
301 PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \
302 PEM_STRING_RSA_PUBLIC,\
303 bp,(char *)x,NULL,NULL,0,NULL)
304 #define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb) \
305 PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\
306 bp,(char *)x,enc,kstr,klen,cb)
307 #define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb) \
308 PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\
309 (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
310 bp,(char *)x,enc,kstr,klen,cb)
311 #define PEM_write_bio_PKCS7(bp,x) \
312 PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \
313 (char *)x, NULL,NULL,0,NULL)
314 #define PEM_write_bio_DHparams(bp,x) \
315 PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\
316 bp,(char *)x,NULL,NULL,0,NULL)
317 #define PEM_write_bio_DSAparams(bp,x) \
318 PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \
319 PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL)
321 #define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \
322 PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
323 PEM_STRING_X509,bp, \
324 (char *)x, NULL,NULL,0,NULL)
326 #define PEM_read_bio_SSL_SESSION(bp,x,cb) (SSL_SESSION *)PEM_ASN1_read_bio( \
327 (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,(char **)x,cb)
328 #define PEM_read_bio_X509(bp,x,cb) (X509 *)PEM_ASN1_read_bio( \
329 (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb)
330 #define PEM_read_bio_X509_REQ(bp,x,cb) (X509_REQ *)PEM_ASN1_read_bio( \
331 (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb)
332 #define PEM_read_bio_X509_CRL(bp,x,cb) (X509_CRL *)PEM_ASN1_read_bio( \
333 (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb)
334 #define PEM_read_bio_RSAPrivateKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \
335 (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb)
336 #define PEM_read_bio_RSAPublicKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \
337 (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb)
338 #define PEM_read_bio_DSAPrivateKey(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \
339 (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb)
340 #define PEM_read_bio_PrivateKey(bp,x,cb) (EVP_PKEY *)PEM_ASN1_read_bio( \
341 (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb)
343 #define PEM_read_bio_PKCS7(bp,x,cb) (PKCS7 *)PEM_ASN1_read_bio( \
344 (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb)
345 #define PEM_read_bio_DHparams(bp,x,cb) (DH *)PEM_ASN1_read_bio( \
346 (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb)
347 #define PEM_read_bio_DSAparams(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \
348 (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb)
350 #define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb) \
351 (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \
352 (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\
358 int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
359 int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
363 int PEM_read_bio(BIO *bp, char **name, char **header,
364 unsigned char **data,long *len);
365 int PEM_write_bio(BIO *bp,char *name,char *hdr,unsigned char *data,
367 char * PEM_ASN1_read_bio(char *(*d2i)(),char *name,BIO *bp,char **x,
369 int PEM_ASN1_write_bio(int (*i2d)(),char *name,BIO *bp,char *x,
370 EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)());
371 STACK * PEM_X509_INFO_read_bio(BIO *bp, STACK *sk, int (*cb)());
372 int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
373 unsigned char *kstr, int klen, int (*cb)());
377 int PEM_read(FILE *fp, char **name, char **header,
378 unsigned char **data,long *len);
379 int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
380 char * PEM_ASN1_read(char *(*d2i)(),char *name,FILE *fp,char **x,
382 int PEM_ASN1_write(int (*i2d)(),char *name,FILE *fp,char *x,
383 EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)());
384 STACK * PEM_X509_INFO_read(FILE *fp, STACK *sk, int (*cb)());
387 int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
388 EVP_MD *md_type, unsigned char **ek, int *ekl,
389 unsigned char *iv, EVP_PKEY **pubk, int npubk);
390 void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
391 unsigned char *in, int inl);
392 int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl,
393 unsigned char *out, int *outl, EVP_PKEY *priv);
395 void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
396 void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
397 int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
398 unsigned int *siglen, EVP_PKEY *pkey);
400 void ERR_load_PEM_strings(void);
402 void PEM_proc_type(char *buf, int type);
403 void PEM_dek_info(char *buf, char *type, int len, char *str);
405 #ifndef SSLEAY_MACROS
408 X509 *PEM_read_X509(FILE *fp,X509 **x,int (*cb)());
409 X509_REQ *PEM_read_X509_REQ(FILE *fp,X509_REQ **x,int (*cb)());
410 X509_CRL *PEM_read_X509_CRL(FILE *fp,X509_CRL **x,int (*cb)());
411 RSA *PEM_read_RSAPrivateKey(FILE *fp,RSA **x,int (*cb)());
412 RSA *PEM_read_RSAPublicKey(FILE *fp,RSA **x,int (*cb)());
413 DSA *PEM_read_DSAPrivateKey(FILE *fp,DSA **x,int (*cb)());
414 EVP_PKEY *PEM_read_PrivateKey(FILE *fp,EVP_PKEY **x,int (*cb)());
415 PKCS7 *PEM_read_PKCS7(FILE *fp,PKCS7 **x,int (*cb)());
416 DH *PEM_read_DHparams(FILE *fp,DH **x,int (*cb)());
417 DSA *PEM_read_DSAparams(FILE *fp,DSA **x,int (*cb)());
418 NETSCAPE_CERT_SEQUENCE *PEM_read_NETSCAPE_CERT_SEQUENCE(FILE *fp,NETSCAPE_CERT_SEQUENCE **x,int (*cb)());
419 int PEM_write_X509(FILE *fp,X509 *x);
420 int PEM_write_X509_REQ(FILE *fp,X509_REQ *x);
421 int PEM_write_X509_CRL(FILE *fp,X509_CRL *x);
422 int PEM_write_RSAPrivateKey(FILE *fp,RSA *x,EVP_CIPHER *enc,unsigned char *kstr,
423 int klen,int (*cb)());
424 int PEM_write_RSAPublicKey(FILE *fp,RSA *x);
425 int PEM_write_DSAPrivateKey(FILE *fp,DSA *x,EVP_CIPHER *enc,unsigned char *kstr,
426 int klen,int (*cb)());
427 int PEM_write_PrivateKey(FILE *fp,EVP_PKEY *x,EVP_CIPHER *enc,
428 unsigned char *kstr,int klen,int (*cb)());
429 int PEM_write_PKCS7(FILE *fp,PKCS7 *x);
430 int PEM_write_DHparams(FILE *fp,DH *x);
431 int PEM_write_DSAparams(FILE *fp,DSA *x);
432 int PEM_write_NETSCAPE_CERT_SEQUENCE(FILE *fp,NETSCAPE_CERT_SEQUENCE *x);
436 X509 *PEM_read_bio_X509(BIO *bp,X509 **x,int (*cb)());
437 X509_REQ *PEM_read_bio_X509_REQ(BIO *bp,X509_REQ **x,int (*cb)());
438 X509_CRL *PEM_read_bio_X509_CRL(BIO *bp,X509_CRL **x,int (*cb)());
439 RSA *PEM_read_bio_RSAPrivateKey(BIO *bp,RSA **x,int (*cb)());
440 RSA *PEM_read_bio_RSAPublicKey(BIO *bp,RSA **x,int (*cb)());
441 DSA *PEM_read_bio_DSAPrivateKey(BIO *bp,DSA **x,int (*cb)());
442 EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp,EVP_PKEY **x,int (*cb)());
443 PKCS7 *PEM_read_bio_PKCS7(BIO *bp,PKCS7 **x,int (*cb)());
444 DH *PEM_read_bio_DHparams(BIO *bp,DH **x,int (*cb)());
445 NETSCAPE_CERT_SEQUENCE *PEM_read_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp,NETSCAPE_CERT_SEQUENCE **x,int (*cb)());
446 DSA *PEM_read_bio_DSAparams(BIO *bp,DSA **x,int (*cb)());
447 int PEM_write_bio_X509(BIO *bp,X509 *x);
448 int PEM_write_bio_X509_REQ(BIO *bp,X509_REQ *x);
449 int PEM_write_bio_X509_CRL(BIO *bp,X509_CRL *x);
450 int PEM_write_bio_RSAPrivateKey(BIO *fp,RSA *x,EVP_CIPHER *enc,
451 unsigned char *kstr,int klen,int (*cb)());
452 int PEM_write_bio_RSAPublicKey(BIO *fp,RSA *x);
453 int PEM_write_bio_DSAPrivateKey(BIO *fp,DSA *x,EVP_CIPHER *enc,
454 unsigned char *kstr,int klen,int (*cb)());
455 int PEM_write_bio_PrivateKey(BIO *fp,EVP_PKEY *x,EVP_CIPHER *enc,
456 unsigned char *kstr,int klen,int (*cb)());
457 int PEM_write_bio_PKCS7(BIO *bp,PKCS7 *x);
458 int PEM_write_bio_DHparams(BIO *bp,DH *x);
459 int PEM_write_bio_DSAparams(BIO *bp,DSA *x);
460 int PEM_write_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp,NETSCAPE_CERT_SEQUENCE *x);
463 #endif /* SSLEAY_MACROS */
468 int PEM_get_EVP_CIPHER_INFO();
475 STACK * PEM_X509_INFO_read();
476 char * PEM_ASN1_read();
477 int PEM_ASN1_write();
479 STACK * PEM_X509_INFO_read_bio();
480 int PEM_X509_INFO_write_bio();
481 char * PEM_ASN1_read_bio();
482 int PEM_ASN1_write_bio();
484 void PEM_SealUpdate();
488 void ERR_load_PEM_strings();
490 void PEM_proc_type();
493 #ifndef SSLEAY_MACROS
495 X509 *PEM_read_X509();
496 X509_REQ *PEM_read_X509_REQ();
497 X509_CRL *PEM_read_X509_CRL();
498 RSA *PEM_read_RSAPrivateKey();
499 RSA *PEM_read_RSAPublicKey();
500 DSA *PEM_read_DSAPrivateKey();
501 EVP_PKEY *PEM_read_PrivateKey();
502 PKCS7 *PEM_read_PKCS7();
503 DH *PEM_read_DHparams();
504 DSA *PEM_read_DSAparams();
505 int PEM_write_X509();
506 int PEM_write_X509_REQ();
507 int PEM_write_X509_CRL();
508 int PEM_write_RSAPrivateKey();
509 int PEM_write_RSAPublicKey();
510 int PEM_write_DSAPrivateKey();
511 int PEM_write_PrivateKey();
512 int PEM_write_PKCS7();
513 int PEM_write_DHparams();
514 int PEM_write_DSAparams();
517 X509 *PEM_read_bio_X509();
518 X509_REQ *PEM_read_bio_X509_REQ();
519 X509_CRL *PEM_read_bio_X509_CRL();
520 RSA *PEM_read_bio_RSAPrivateKey();
521 RSA *PEM_read_bio_RSAPublicKey();
522 DSA *PEM_read_bio_DSAPrivateKey();
523 EVP_PKEY *PEM_read_bio_PrivateKey();
524 PKCS7 *PEM_read_bio_PKCS7();
525 DH *PEM_read_bio_DHparams();
526 DSA *PEM_read_bio_DSAparams();
527 int PEM_write_bio_X509();
528 int PEM_write_bio_X509_REQ();
529 int PEM_write_bio_X509_CRL();
530 int PEM_write_bio_RSAPrivateKey();
531 int PEM_write_bio_RSAPublicKey();
532 int PEM_write_bio_DSAPrivateKey();
533 int PEM_write_bio_PrivateKey();
534 int PEM_write_bio_PKCS7();
535 int PEM_write_bio_DHparams();
536 int PEM_write_bio_DSAparams();
538 #endif /* SSLEAY_MACROS */
542 /* BEGIN ERROR CODES */
543 /* Error codes for the PEM functions. */
545 /* Function codes. */
546 #define PEM_F_DEF_CALLBACK 100
547 #define PEM_F_LOAD_IV 101
548 #define PEM_F_PEM_ASN1_READ 102
549 #define PEM_F_PEM_ASN1_READ_BIO 103
550 #define PEM_F_PEM_ASN1_WRITE 104
551 #define PEM_F_PEM_ASN1_WRITE_BIO 105
552 #define PEM_F_PEM_DO_HEADER 106
553 #define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
554 #define PEM_F_PEM_READ 108
555 #define PEM_F_PEM_READ_BIO 109
556 #define PEM_F_PEM_SEALFINAL 110
557 #define PEM_F_PEM_SEALINIT 111
558 #define PEM_F_PEM_SIGNFINAL 112
559 #define PEM_F_PEM_WRITE 113
560 #define PEM_F_PEM_WRITE_BIO 114
561 #define PEM_F_PEM_X509_INFO_READ 115
562 #define PEM_F_PEM_X509_INFO_READ_BIO 116
563 #define PEM_F_PEM_X509_INFO_WRITE_BIO 117
566 #define PEM_R_BAD_BASE64_DECODE 100
567 #define PEM_R_BAD_DECRYPT 101
568 #define PEM_R_BAD_END_LINE 102
569 #define PEM_R_BAD_IV_CHARS 103
570 #define PEM_R_BAD_PASSWORD_READ 104
571 #define PEM_R_NOT_DEK_INFO 105
572 #define PEM_R_NOT_ENCRYPTED 106
573 #define PEM_R_NOT_PROC_TYPE 107
574 #define PEM_R_NO_START_LINE 108
575 #define PEM_R_PROBLEMS_GETTING_PASSWORD 109
576 #define PEM_R_PUBLIC_KEY_NO_RSA 110
577 #define PEM_R_READ_KEY 111
578 #define PEM_R_SHORT_HEADER 112
579 #define PEM_R_UNSUPPORTED_CIPHER 113
580 #define PEM_R_UNSUPPORTED_ENCRYPTION 114