Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / boringssl / src / include / openssl / pem.h
1 /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
2  * All rights reserved.
3  *
4  * This package is an SSL implementation written
5  * by Eric Young (eay@cryptsoft.com).
6  * The implementation was written so as to conform with Netscapes SSL.
7  *
8  * This library is free for commercial and non-commercial use as long as
9  * the following conditions are aheared to.  The following conditions
10  * apply to all code found in this distribution, be it the RC4, RSA,
11  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
12  * included with this distribution is covered by the same copyright terms
13  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
14  *
15  * Copyright remains Eric Young's, and as such any Copyright notices in
16  * the code are not to be removed.
17  * If this package is used in a product, Eric Young should be given attribution
18  * as the author of the parts of the library used.
19  * This can be in the form of a textual message at program startup or
20  * in documentation (online or textual) provided with the package.
21  *
22  * Redistribution and use in source and binary forms, with or without
23  * modification, are permitted provided that the following conditions
24  * are met:
25  * 1. Redistributions of source code must retain the copyright
26  *    notice, this list of conditions and the following disclaimer.
27  * 2. Redistributions in binary form must reproduce the above copyright
28  *    notice, this list of conditions and the following disclaimer in the
29  *    documentation and/or other materials provided with the distribution.
30  * 3. All advertising materials mentioning features or use of this software
31  *    must display the following acknowledgement:
32  *    "This product includes cryptographic software written by
33  *     Eric Young (eay@cryptsoft.com)"
34  *    The word 'cryptographic' can be left out if the rouines from the library
35  *    being used are not cryptographic related :-).
36  * 4. If you include any Windows specific code (or a derivative thereof) from
37  *    the apps directory (application code) you must include an acknowledgement:
38  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
39  *
40  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
41  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50  * SUCH DAMAGE.
51  *
52  * The licence and distribution terms for any publically available version or
53  * derivative of this code cannot be changed.  i.e. this code cannot simply be
54  * copied and put under another distribution licence
55  * [including the GNU Public Licence.] */
56
57 #ifndef OPENSSL_HEADER_PEM_H
58 #define OPENSSL_HEADER_PEM_H
59
60 #include <openssl/base64.h>
61 #include <openssl/bio.h>
62 #include <openssl/cipher.h>
63 #include <openssl/digest.h>
64 #include <openssl/evp.h>
65 #include <openssl/stack.h>
66 #include <openssl/x509.h>
67
68 #ifdef  __cplusplus
69 extern "C" {
70 #endif
71
72
73 #define PEM_BUFSIZE             1024
74
75 #define PEM_OBJ_UNDEF           0
76 #define PEM_OBJ_X509            1
77 #define PEM_OBJ_X509_REQ        2
78 #define PEM_OBJ_CRL             3
79 #define PEM_OBJ_SSL_SESSION     4
80 #define PEM_OBJ_PRIV_KEY        10
81 #define PEM_OBJ_PRIV_RSA        11
82 #define PEM_OBJ_PRIV_DSA        12
83 #define PEM_OBJ_PRIV_DH         13
84 #define PEM_OBJ_PUB_RSA         14
85 #define PEM_OBJ_PUB_DSA         15
86 #define PEM_OBJ_PUB_DH          16
87 #define PEM_OBJ_DHPARAMS        17
88 #define PEM_OBJ_DSAPARAMS       18
89 #define PEM_OBJ_PRIV_RSA_PUBLIC 19
90 #define PEM_OBJ_PRIV_ECDSA      20
91 #define PEM_OBJ_PUB_ECDSA       21
92 #define PEM_OBJ_ECPARAMETERS    22
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_PAIR    "CERTIFICATE PAIR"
113 #define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
114 #define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
115 #define PEM_STRING_X509_REQ     "CERTIFICATE REQUEST"
116 #define PEM_STRING_X509_CRL     "X509 CRL"
117 #define PEM_STRING_EVP_PKEY     "ANY PRIVATE KEY"
118 #define PEM_STRING_PUBLIC       "PUBLIC KEY"
119 #define PEM_STRING_RSA          "RSA PRIVATE KEY"
120 #define PEM_STRING_RSA_PUBLIC   "RSA PUBLIC KEY"
121 #define PEM_STRING_DSA          "DSA PRIVATE KEY"
122 #define PEM_STRING_DSA_PUBLIC   "DSA PUBLIC KEY"
123 #define PEM_STRING_PKCS7        "PKCS7"
124 #define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
125 #define PEM_STRING_PKCS8        "ENCRYPTED PRIVATE KEY"
126 #define PEM_STRING_PKCS8INF     "PRIVATE KEY"
127 #define PEM_STRING_DHPARAMS     "DH PARAMETERS"
128 #define PEM_STRING_DHXPARAMS    "X9.42 DH PARAMETERS"
129 #define PEM_STRING_SSL_SESSION  "SSL SESSION PARAMETERS"
130 #define PEM_STRING_DSAPARAMS    "DSA PARAMETERS"
131 #define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
132 #define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
133 #define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
134 #define PEM_STRING_PARAMETERS   "PARAMETERS"
135 #define PEM_STRING_CMS          "CMS"
136
137   /* Note that this structure is initialised by PEM_SealInit and cleaned up
138      by PEM_SealFinal (at least for now) */
139 typedef struct PEM_Encode_Seal_st
140         {
141         EVP_ENCODE_CTX encode;
142         EVP_MD_CTX md;
143         EVP_CIPHER_CTX cipher;
144         } PEM_ENCODE_SEAL_CTX;
145
146 /* enc_type is one off */
147 #define PEM_TYPE_ENCRYPTED      10
148 #define PEM_TYPE_MIC_ONLY       20
149 #define PEM_TYPE_MIC_CLEAR      30
150 #define PEM_TYPE_CLEAR          40
151
152 typedef struct pem_recip_st
153         {
154         char *name;
155         X509_NAME *dn;
156
157         int cipher;
158         int key_enc;
159         /*      char iv[8]; unused and wrong size */
160         } PEM_USER;
161
162 typedef struct pem_ctx_st
163         {
164         int type;               /* what type of object */
165
166         struct  {
167                 int version;    
168                 int mode;               
169                 } proc_type;
170
171         char *domain;
172
173         struct  {
174                 int cipher;
175         /* unused, and wrong size
176            unsigned char iv[8]; */
177                 } DEK_info;
178                 
179         PEM_USER *originator;
180
181         int num_recipient;
182         PEM_USER **recipient;
183
184         EVP_MD *md;             /* signature type */
185
186         int md_enc;             /* is the md encrypted or not? */
187         int md_len;             /* length of md_data */
188         char *md_data;          /* message digest, could be pkey encrypted */
189
190         EVP_CIPHER *dec;        /* date encryption cipher */
191         int key_len;            /* key length */
192         unsigned char *key;     /* key */
193         /* unused, and wrong size
194            unsigned char iv[8]; */
195
196         
197         int  data_enc;          /* is the data encrypted */
198         int data_len;
199         unsigned char *data;
200         } PEM_CTX;
201
202 /* These macros make the PEM_read/PEM_write functions easier to maintain and
203  * write. Now they are all implemented with either:
204  * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...)
205  */
206
207 #ifdef OPENSSL_NO_FP_API
208
209 #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/
210 #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/
211 #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/
212 #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/
213 #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/
214
215 #else
216
217 #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
218 OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
219 { \
220 return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \
221
222
223 #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
224 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x) \
225 { \
226 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \
227 }
228
229 #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
230 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x) \
231 { \
232 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \
233 }
234
235 #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
236 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
237              unsigned char *kstr, int klen, pem_password_cb *cb, \
238                   void *u) \
239         { \
240         return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
241         }
242
243 #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
244 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
245              unsigned char *kstr, int klen, pem_password_cb *cb, \
246                   void *u) \
247         { \
248         return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
249         }
250
251 #endif
252
253 #define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
254 OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
255 { \
256 return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \
257 }
258
259 #define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
260 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x) \
261 { \
262 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \
263 }
264
265 #define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
266 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x) \
267 { \
268 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \
269 }
270
271 #define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
272 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
273              unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
274         { \
275         return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \
276         }
277
278 #define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
279 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
280              unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
281         { \
282         return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \
283         }
284
285 #define IMPLEMENT_PEM_write(name, type, str, asn1) \
286         IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
287         IMPLEMENT_PEM_write_fp(name, type, str, asn1) 
288
289 #define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
290         IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
291         IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) 
292
293 #define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
294         IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
295         IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) 
296
297 #define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
298         IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
299         IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) 
300
301 #define IMPLEMENT_PEM_read(name, type, str, asn1) \
302         IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
303         IMPLEMENT_PEM_read_fp(name, type, str, asn1) 
304
305 #define IMPLEMENT_PEM_rw(name, type, str, asn1) \
306         IMPLEMENT_PEM_read(name, type, str, asn1) \
307         IMPLEMENT_PEM_write(name, type, str, asn1)
308
309 #define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
310         IMPLEMENT_PEM_read(name, type, str, asn1) \
311         IMPLEMENT_PEM_write_const(name, type, str, asn1)
312
313 #define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
314         IMPLEMENT_PEM_read(name, type, str, asn1) \
315         IMPLEMENT_PEM_write_cb(name, type, str, asn1)
316
317 /* These are the same except they are for the declarations */
318
319 #if defined(OPENSSL_NO_FP_API)
320
321 #define DECLARE_PEM_read_fp(name, type) /**/
322 #define DECLARE_PEM_write_fp(name, type) /**/
323 #define DECLARE_PEM_write_cb_fp(name, type) /**/
324
325 #else
326
327 #define DECLARE_PEM_read_fp(name, type) \
328         OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);
329
330 #define DECLARE_PEM_write_fp(name, type) \
331         OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x);
332
333 #define DECLARE_PEM_write_fp_const(name, type) \
334         OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x);
335
336 #define DECLARE_PEM_write_cb_fp(name, type) \
337         OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
338              unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
339
340 #endif
341
342 #ifndef OPENSSL_NO_BIO
343 #define DECLARE_PEM_read_bio(name, type) \
344         OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);
345
346 #define DECLARE_PEM_write_bio(name, type) \
347         OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x);
348
349 #define DECLARE_PEM_write_bio_const(name, type) \
350         OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x);
351
352 #define DECLARE_PEM_write_cb_bio(name, type) \
353         OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
354              unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
355
356 #else
357
358 #define DECLARE_PEM_read_bio(name, type) /**/
359 #define DECLARE_PEM_write_bio(name, type) /**/
360 #define DECLARE_PEM_write_bio_const(name, type) /**/
361 #define DECLARE_PEM_write_cb_bio(name, type) /**/
362
363 #endif
364
365 #define DECLARE_PEM_write(name, type) \
366         DECLARE_PEM_write_bio(name, type) \
367         DECLARE_PEM_write_fp(name, type) 
368
369 #define DECLARE_PEM_write_const(name, type) \
370         DECLARE_PEM_write_bio_const(name, type) \
371         DECLARE_PEM_write_fp_const(name, type)
372
373 #define DECLARE_PEM_write_cb(name, type) \
374         DECLARE_PEM_write_cb_bio(name, type) \
375         DECLARE_PEM_write_cb_fp(name, type) 
376
377 #define DECLARE_PEM_read(name, type) \
378         DECLARE_PEM_read_bio(name, type) \
379         DECLARE_PEM_read_fp(name, type)
380
381 #define DECLARE_PEM_rw(name, type) \
382         DECLARE_PEM_read(name, type) \
383         DECLARE_PEM_write(name, type)
384
385 #define DECLARE_PEM_rw_const(name, type) \
386         DECLARE_PEM_read(name, type) \
387         DECLARE_PEM_write_const(name, type)
388
389 #define DECLARE_PEM_rw_cb(name, type) \
390         DECLARE_PEM_read(name, type) \
391         DECLARE_PEM_write_cb(name, type)
392
393 #if 1
394 /* "userdata": new with OpenSSL 0.9.4 */
395 typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);
396 #else
397 /* OpenSSL 0.9.3, 0.9.3a */
398 typedef int pem_password_cb(char *buf, int size, int rwflag);
399 #endif
400
401 OPENSSL_EXPORT int      PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
402 OPENSSL_EXPORT int      PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, pem_password_cb *callback,void *u);
403
404 #ifndef OPENSSL_NO_BIO
405 OPENSSL_EXPORT int      PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data,long *len);
406 OPENSSL_EXPORT int      PEM_write_bio(BIO *bp,const char *name, const char *hdr, const unsigned char *data, long len);
407 OPENSSL_EXPORT int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, pem_password_cb *cb, void *u);
408 OPENSSL_EXPORT void *   PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, pem_password_cb *cb, void *u);
409 OPENSSL_EXPORT int      PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp, void *x, const EVP_CIPHER *enc,unsigned char *kstr,int klen, pem_password_cb *cb, void *u);
410
411 OPENSSL_EXPORT STACK_OF(X509_INFO) *    PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
412 OPENSSL_EXPORT int      PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cd, void *u);
413 #endif
414
415 OPENSSL_EXPORT int      PEM_read(FILE *fp, char **name, char **header, unsigned char **data,long *len);
416 OPENSSL_EXPORT int      PEM_write(FILE *fp, const char *name, const char *hdr, const unsigned char *data, long len);
417 OPENSSL_EXPORT void *  PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, pem_password_cb *cb, void *u);
418 OPENSSL_EXPORT int      PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp, void *x,const EVP_CIPHER *enc,unsigned char *kstr, int klen,pem_password_cb *callback, void *u);
419 OPENSSL_EXPORT STACK_OF(X509_INFO) *    PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
420
421 OPENSSL_EXPORT int      PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type, unsigned char **ek, int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk);
422 OPENSSL_EXPORT void     PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, unsigned char *in, int inl);
423 OPENSSL_EXPORT int      PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl, unsigned char *out, int *outl, EVP_PKEY *priv);
424
425 OPENSSL_EXPORT void    PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
426 OPENSSL_EXPORT void    PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
427 OPENSSL_EXPORT int      PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, EVP_PKEY *pkey);
428
429 OPENSSL_EXPORT int      PEM_def_callback(char *buf, int num, int w, void *key);
430 OPENSSL_EXPORT void     PEM_proc_type(char *buf, int type);
431 OPENSSL_EXPORT void     PEM_dek_info(char *buf, const char *type, int len, char *str);
432
433
434 DECLARE_PEM_rw(X509, X509)
435
436 DECLARE_PEM_rw(X509_AUX, X509)
437
438 DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR)
439
440 DECLARE_PEM_rw(X509_REQ, X509_REQ)
441 DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
442
443 DECLARE_PEM_rw(X509_CRL, X509_CRL)
444
445 /* DECLARE_PEM_rw(PKCS7, PKCS7) */
446
447 DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
448
449 DECLARE_PEM_rw(PKCS8, X509_SIG)
450
451 DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
452
453 DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
454
455 DECLARE_PEM_rw_const(RSAPublicKey, RSA)
456 DECLARE_PEM_rw(RSA_PUBKEY, RSA)
457
458 #ifndef OPENSSL_NO_DSA
459
460 DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
461
462 DECLARE_PEM_rw(DSA_PUBKEY, DSA)
463
464 DECLARE_PEM_rw_const(DSAparams, DSA)
465
466 #endif
467
468 DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)
469 DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
470 DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
471
472
473 DECLARE_PEM_rw_const(DHparams, DH)
474 DECLARE_PEM_write_const(DHxparams, DH)
475
476
477 DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
478
479 DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
480
481 OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u);
482 OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, char *, int, pem_password_cb *, void *);
483 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u);
484 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u);
485 OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
486
487 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u);
488 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u);
489 OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u);
490
491 OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
492
493 OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, char *kstr,int klen, pem_password_cb *cd, void *u);
494
495 OPENSSL_EXPORT EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
496 OPENSSL_EXPORT int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
497
498
499 OPENSSL_EXPORT EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
500 OPENSSL_EXPORT EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
501 OPENSSL_EXPORT EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
502 OPENSSL_EXPORT EVP_PKEY *b2i_PublicKey_bio(BIO *in);
503 OPENSSL_EXPORT int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);
504 OPENSSL_EXPORT int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);
505 OPENSSL_EXPORT EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
506 OPENSSL_EXPORT int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel, pem_password_cb *cb, void *u);
507
508
509 void ERR_load_PEM_strings(void);
510
511
512 #ifdef  __cplusplus
513 }
514 #endif
515
516 #define PEM_F_PEM_read_bio_DHparams 100
517 #define PEM_F_load_iv 101
518 #define PEM_F_PEM_write 102
519 #define PEM_F_do_pk8pkey_fp 103
520 #define PEM_F_PEM_read_PrivateKey 104
521 #define PEM_F_PEM_read_DHparams 105
522 #define PEM_F_PEM_ASN1_read_bio 106
523 #define PEM_F_PEM_ASN1_read 107
524 #define PEM_F_PEM_get_EVP_CIPHER_INFO 108
525 #define PEM_F_PEM_X509_INFO_read 109
526 #define PEM_F_PEM_read_bio_Parameters 110
527 #define PEM_F_PEM_read 111
528 #define PEM_F_PEM_X509_INFO_read_bio 112
529 #define PEM_F_PEM_X509_INFO_write_bio 113
530 #define PEM_F_PEM_ASN1_write 114
531 #define PEM_F_d2i_PKCS8PrivateKey_bio 115
532 #define PEM_F_d2i_PKCS8PrivateKey_fp 116
533 #define PEM_F_PEM_read_bio_PrivateKey 117
534 #define PEM_F_PEM_write_PrivateKey 118
535 #define PEM_F_PEM_ASN1_write_bio 119
536 #define PEM_F_PEM_do_header 120
537 #define PEM_F_PEM_write_bio 121
538 #define PEM_F_do_pk8pkey 122
539 #define PEM_F_PEM_read_bio 123
540 #define PEM_R_NO_START_LINE 100
541 #define PEM_R_NOT_PROC_TYPE 101
542 #define PEM_R_SHORT_HEADER 102
543 #define PEM_R_BAD_IV_CHARS 103
544 #define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 104
545 #define PEM_R_BAD_END_LINE 105
546 #define PEM_R_CIPHER_IS_NULL 106
547 #define PEM_R_BAD_MAGIC_NUMBER 107
548 #define PEM_R_BAD_DECRYPT 108
549 #define PEM_R_UNSUPPORTED_ENCRYPTION 109
550 #define PEM_R_PVK_DATA_TOO_SHORT 110
551 #define PEM_R_PROBLEMS_GETTING_PASSWORD 111
552 #define PEM_R_KEYBLOB_HEADER_PARSE_ERROR 112
553 #define PEM_R_BIO_WRITE_FAILURE 113
554 #define PEM_R_INCONSISTENT_HEADER 114
555 #define PEM_R_PUBLIC_KEY_NO_RSA 115
556 #define PEM_R_EXPECTING_PUBLIC_KEY_BLOB 116
557 #define PEM_R_KEYBLOB_TOO_SHORT 117
558 #define PEM_R_BAD_BASE64_DECODE 118
559 #define PEM_R_READ_KEY 119
560 #define PEM_R_BAD_PASSWORD_READ 120
561 #define PEM_R_UNSUPPORTED_KEY_COMPONENTS 121
562 #define PEM_R_UNSUPPORTED_CIPHER 122
563 #define PEM_R_NOT_ENCRYPTED 123
564 #define PEM_R_NOT_DEK_INFO 124
565 #define PEM_R_BAD_VERSION_NUMBER 125
566 #define PEM_R_EXPECTING_PRIVATE_KEY_BLOB 126
567 #define PEM_R_PVK_TOO_SHORT 127
568
569 #endif  /* OPENSSL_HEADER_PEM_H */