]> git.ipfire.org Git - thirdparty/openssl.git/blob - include/openssl/pem.h
Fix no-stdio build
[thirdparty/openssl.git] / include / openssl / pem.h
1 /* crypto/pem/pem.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_PEM_H
60 # define HEADER_PEM_H
61
62 # include <openssl/e_os2.h>
63 # include <openssl/bio.h>
64 # include <openssl/stack.h>
65 # include <openssl/evp.h>
66 # include <openssl/x509.h>
67 # include <openssl/pem2.h>
68
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72
73 # define PEM_BUFSIZE 1024
74
75 # define PEM_STRING_X509_OLD "X509 CERTIFICATE"
76 # define PEM_STRING_X509 "CERTIFICATE"
77 # define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
78 # define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
79 # define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
80 # define PEM_STRING_X509_CRL "X509 CRL"
81 # define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"
82 # define PEM_STRING_PUBLIC "PUBLIC KEY"
83 # define PEM_STRING_RSA "RSA PRIVATE KEY"
84 # define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
85 # define PEM_STRING_DSA "DSA PRIVATE KEY"
86 # define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
87 # define PEM_STRING_PKCS7 "PKCS7"
88 # define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
89 # define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
90 # define PEM_STRING_PKCS8INF "PRIVATE KEY"
91 # define PEM_STRING_DHPARAMS "DH PARAMETERS"
92 # define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS"
93 # define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
94 # define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
95 # define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
96 # define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
97 # define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
98 # define PEM_STRING_PARAMETERS "PARAMETERS"
99 # define PEM_STRING_CMS "CMS"
100
101 /*
102 * Note that this structure is initialised by PEM_SealInit and cleaned up
103 * by PEM_SealFinal (at least for now)
104 */
105 typedef struct PEM_Encode_Seal_st {
106 EVP_ENCODE_CTX encode;
107 EVP_MD_CTX md;
108 EVP_CIPHER_CTX cipher;
109 } PEM_ENCODE_SEAL_CTX;
110
111 # define PEM_TYPE_ENCRYPTED 10
112 # define PEM_TYPE_MIC_ONLY 20
113 # define PEM_TYPE_MIC_CLEAR 30
114 # define PEM_TYPE_CLEAR 40
115
116 typedef struct pem_recip_st {
117 char *name;
118 X509_NAME *dn;
119 int cipher;
120 int key_enc;
121 /* char iv[8]; unused and wrong size */
122 } PEM_USER;
123
124 typedef struct pem_ctx_st {
125 int type; /* what type of object */
126 struct {
127 int version;
128 int mode;
129 } proc_type;
130
131 char *domain;
132
133 struct {
134 int cipher;
135 /*-
136 unused, and wrong size
137 unsigned char iv[8]; */
138 } DEK_info;
139
140 PEM_USER *originator;
141
142 int num_recipient;
143 PEM_USER **recipient;
144
145 /*-
146 XXX(ben): don#t think this is used!
147 STACK *x509_chain; / * certificate chain */
148 EVP_MD *md; /* signature type */
149
150 int md_enc; /* is the md encrypted or not? */
151 int md_len; /* length of md_data */
152 char *md_data; /* message digest, could be pkey encrypted */
153
154 EVP_CIPHER *dec; /* date encryption cipher */
155 int key_len; /* key length */
156 unsigned char *key; /* key */
157 /*-
158 unused, and wrong size
159 unsigned char iv[8]; */
160
161 int data_enc; /* is the data encrypted */
162 int data_len;
163 unsigned char *data;
164 } PEM_CTX;
165
166 /*
167 * These macros make the PEM_read/PEM_write functions easier to maintain and
168 * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or
169 * IMPLEMENT_PEM_rw_cb(...)
170 */
171
172 # ifdef OPENSSL_NO_STDIO
173
174 # define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/
175 # define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/
176 # define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/
177 # define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/
178 # define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/
179 # else
180
181 # define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
182 type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
183 { \
184 return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \
185 }
186
187 # define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
188 int PEM_write_##name(FILE *fp, type *x) \
189 { \
190 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \
191 }
192
193 # define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
194 int PEM_write_##name(FILE *fp, const type *x) \
195 { \
196 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \
197 }
198
199 # define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
200 int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
201 unsigned char *kstr, int klen, pem_password_cb *cb, \
202 void *u) \
203 { \
204 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
205 }
206
207 # define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
208 int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
209 unsigned char *kstr, int klen, pem_password_cb *cb, \
210 void *u) \
211 { \
212 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
213 }
214
215 # endif
216
217 # define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
218 type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
219 { \
220 return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \
221 }
222
223 # define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
224 int PEM_write_bio_##name(BIO *bp, type *x) \
225 { \
226 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \
227 }
228
229 # define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
230 int PEM_write_bio_##name(BIO *bp, const type *x) \
231 { \
232 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \
233 }
234
235 # define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
236 int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
237 unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
238 { \
239 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \
240 }
241
242 # define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
243 int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
244 unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
245 { \
246 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \
247 }
248
249 # define IMPLEMENT_PEM_write(name, type, str, asn1) \
250 IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
251 IMPLEMENT_PEM_write_fp(name, type, str, asn1)
252
253 # define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
254 IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
255 IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
256
257 # define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
258 IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
259 IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
260
261 # define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
262 IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
263 IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
264
265 # define IMPLEMENT_PEM_read(name, type, str, asn1) \
266 IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
267 IMPLEMENT_PEM_read_fp(name, type, str, asn1)
268
269 # define IMPLEMENT_PEM_rw(name, type, str, asn1) \
270 IMPLEMENT_PEM_read(name, type, str, asn1) \
271 IMPLEMENT_PEM_write(name, type, str, asn1)
272
273 # define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
274 IMPLEMENT_PEM_read(name, type, str, asn1) \
275 IMPLEMENT_PEM_write_const(name, type, str, asn1)
276
277 # define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
278 IMPLEMENT_PEM_read(name, type, str, asn1) \
279 IMPLEMENT_PEM_write_cb(name, type, str, asn1)
280
281 /* These are the same except they are for the declarations */
282
283 # if defined(OPENSSL_NO_STDIO)
284
285 # define DECLARE_PEM_read_fp(name, type) /**/
286 # define DECLARE_PEM_write_fp(name, type) /**/
287 # define DECLARE_PEM_write_fp_const(name, type) /**/
288 # define DECLARE_PEM_write_cb_fp(name, type) /**/
289 # else
290
291 # define DECLARE_PEM_read_fp(name, type) \
292 type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);
293
294 # define DECLARE_PEM_write_fp(name, type) \
295 int PEM_write_##name(FILE *fp, type *x);
296
297 # define DECLARE_PEM_write_fp_const(name, type) \
298 int PEM_write_##name(FILE *fp, const type *x);
299
300 # define DECLARE_PEM_write_cb_fp(name, type) \
301 int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
302 unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
303
304 # endif
305
306 # define DECLARE_PEM_read_bio(name, type) \
307 type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);
308
309 # define DECLARE_PEM_write_bio(name, type) \
310 int PEM_write_bio_##name(BIO *bp, type *x);
311
312 # define DECLARE_PEM_write_bio_const(name, type) \
313 int PEM_write_bio_##name(BIO *bp, const type *x);
314
315 # define DECLARE_PEM_write_cb_bio(name, type) \
316 int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
317 unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
318
319 # define DECLARE_PEM_write(name, type) \
320 DECLARE_PEM_write_bio(name, type) \
321 DECLARE_PEM_write_fp(name, type)
322 # define DECLARE_PEM_write_const(name, type) \
323 DECLARE_PEM_write_bio_const(name, type) \
324 DECLARE_PEM_write_fp_const(name, type)
325 # define DECLARE_PEM_write_cb(name, type) \
326 DECLARE_PEM_write_cb_bio(name, type) \
327 DECLARE_PEM_write_cb_fp(name, type)
328 # define DECLARE_PEM_read(name, type) \
329 DECLARE_PEM_read_bio(name, type) \
330 DECLARE_PEM_read_fp(name, type)
331 # define DECLARE_PEM_rw(name, type) \
332 DECLARE_PEM_read(name, type) \
333 DECLARE_PEM_write(name, type)
334 # define DECLARE_PEM_rw_const(name, type) \
335 DECLARE_PEM_read(name, type) \
336 DECLARE_PEM_write_const(name, type)
337 # define DECLARE_PEM_rw_cb(name, type) \
338 DECLARE_PEM_read(name, type) \
339 DECLARE_PEM_write_cb(name, type)
340 typedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata);
341
342 int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
343 int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,
344 pem_password_cb *callback, void *u);
345
346 int PEM_read_bio(BIO *bp, char **name, char **header,
347 unsigned char **data, long *len);
348 int PEM_write_bio(BIO *bp, const char *name, const char *hdr,
349 const unsigned char *data, long len);
350 int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
351 const char *name, BIO *bp, pem_password_cb *cb,
352 void *u);
353 void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,
354 pem_password_cb *cb, void *u);
355 int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,
356 const EVP_CIPHER *enc, unsigned char *kstr, int klen,
357 pem_password_cb *cb, void *u);
358
359 STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,
360 pem_password_cb *cb, void *u);
361 int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
362 unsigned char *kstr, int klen,
363 pem_password_cb *cd, void *u);
364
365 #ifndef OPENSSL_NO_STDIO
366 int PEM_read(FILE *fp, char **name, char **header,
367 unsigned char **data, long *len);
368 int PEM_write(FILE *fp, const char *name, const char *hdr,
369 const unsigned char *data, long len);
370 void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
371 pem_password_cb *cb, void *u);
372 int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
373 void *x, const EVP_CIPHER *enc, unsigned char *kstr,
374 int klen, pem_password_cb *callback, void *u);
375 STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
376 pem_password_cb *cb, void *u);
377 #endif
378
379 int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
380 EVP_MD *md_type, unsigned char **ek, int *ekl,
381 unsigned char *iv, EVP_PKEY **pubk, int npubk);
382 int PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
383 unsigned char *in, int inl);
384 int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,
385 unsigned char *out, int *outl, EVP_PKEY *priv);
386
387 int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
388 int PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);
389 int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
390 unsigned int *siglen, EVP_PKEY *pkey);
391
392 int PEM_def_callback(char *buf, int num, int w, void *key);
393 void PEM_proc_type(char *buf, int type);
394 void PEM_dek_info(char *buf, const char *type, int len, char *str);
395
396 # include <openssl/symhacks.h>
397
398 DECLARE_PEM_rw(X509, X509)
399 DECLARE_PEM_rw(X509_AUX, X509)
400 DECLARE_PEM_rw(X509_REQ, X509_REQ)
401 DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
402 DECLARE_PEM_rw(X509_CRL, X509_CRL)
403 DECLARE_PEM_rw(PKCS7, PKCS7)
404 DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
405 DECLARE_PEM_rw(PKCS8, X509_SIG)
406 DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
407 # ifndef OPENSSL_NO_RSA
408 DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
409 DECLARE_PEM_rw_const(RSAPublicKey, RSA)
410 DECLARE_PEM_rw(RSA_PUBKEY, RSA)
411 # endif
412 # ifndef OPENSSL_NO_DSA
413 DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
414 DECLARE_PEM_rw(DSA_PUBKEY, DSA)
415 DECLARE_PEM_rw_const(DSAparams, DSA)
416 # endif
417 # ifndef OPENSSL_NO_EC
418 DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)
419 DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
420 DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
421 # endif
422 # ifndef OPENSSL_NO_DH
423 DECLARE_PEM_rw_const(DHparams, DH)
424 DECLARE_PEM_write_const(DHxparams, DH)
425 # endif
426 DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
427 DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
428
429 int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
430 char *kstr, int klen,
431 pem_password_cb *cb, void *u);
432 int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
433 char *, int, pem_password_cb *, void *);
434 int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
435 char *kstr, int klen,
436 pem_password_cb *cb, void *u);
437 int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
438 char *kstr, int klen,
439 pem_password_cb *cb, void *u);
440 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
441 void *u);
442
443 #ifndef OPENSSL_NO_STDIO
444 int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
445 char *kstr, int klen,
446 pem_password_cb *cb, void *u);
447 int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
448 char *kstr, int klen,
449 pem_password_cb *cb, void *u);
450 int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
451 char *kstr, int klen,
452 pem_password_cb *cb, void *u);
453
454 EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
455 void *u);
456
457 int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
458 char *kstr, int klen, pem_password_cb *cd,
459 void *u);
460 #endif
461 EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
462 int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
463
464 EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
465 EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
466 EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
467 EVP_PKEY *b2i_PublicKey_bio(BIO *in);
468 int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);
469 int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);
470 # ifndef OPENSSL_NO_RC4
471 EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
472 int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,
473 pem_password_cb *cb, void *u);
474 # endif
475
476 /* BEGIN ERROR CODES */
477 /*
478 * The following lines are auto generated by the script mkerr.pl. Any changes
479 * made after this point may be overwritten when the script is next run.
480 */
481 void ERR_load_PEM_strings(void);
482
483 /* Error codes for the PEM functions. */
484
485 /* Function codes. */
486 # define PEM_F_B2I_DSS 127
487 # define PEM_F_B2I_PVK_BIO 128
488 # define PEM_F_B2I_RSA 129
489 # define PEM_F_CHECK_BITLEN_DSA 130
490 # define PEM_F_CHECK_BITLEN_RSA 131
491 # define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120
492 # define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121
493 # define PEM_F_DO_B2I 132
494 # define PEM_F_DO_B2I_BIO 133
495 # define PEM_F_DO_BLOB_HEADER 134
496 # define PEM_F_DO_PK8PKEY 126
497 # define PEM_F_DO_PK8PKEY_FP 125
498 # define PEM_F_DO_PVK_BODY 135
499 # define PEM_F_DO_PVK_HEADER 136
500 # define PEM_F_I2B_PVK 137
501 # define PEM_F_I2B_PVK_BIO 138
502 # define PEM_F_LOAD_IV 101
503 # define PEM_F_PEM_ASN1_READ 102
504 # define PEM_F_PEM_ASN1_READ_BIO 103
505 # define PEM_F_PEM_ASN1_WRITE 104
506 # define PEM_F_PEM_ASN1_WRITE_BIO 105
507 # define PEM_F_PEM_DEF_CALLBACK 100
508 # define PEM_F_PEM_DO_HEADER 106
509 # define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118
510 # define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
511 # define PEM_F_PEM_PK8PKEY 119
512 # define PEM_F_PEM_READ 108
513 # define PEM_F_PEM_READ_BIO 109
514 # define PEM_F_PEM_READ_BIO_DHPARAMS 141
515 # define PEM_F_PEM_READ_BIO_PARAMETERS 140
516 # define PEM_F_PEM_READ_BIO_PRIVATEKEY 123
517 # define PEM_F_PEM_READ_DHPARAMS 142
518 # define PEM_F_PEM_READ_PRIVATEKEY 124
519 # define PEM_F_PEM_SEALFINAL 110
520 # define PEM_F_PEM_SEALINIT 111
521 # define PEM_F_PEM_SIGNFINAL 112
522 # define PEM_F_PEM_WRITE 113
523 # define PEM_F_PEM_WRITE_BIO 114
524 # define PEM_F_PEM_WRITE_PRIVATEKEY 139
525 # define PEM_F_PEM_X509_INFO_READ 115
526 # define PEM_F_PEM_X509_INFO_READ_BIO 116
527 # define PEM_F_PEM_X509_INFO_WRITE_BIO 117
528
529 /* Reason codes. */
530 # define PEM_R_BAD_BASE64_DECODE 100
531 # define PEM_R_BAD_DECRYPT 101
532 # define PEM_R_BAD_END_LINE 102
533 # define PEM_R_BAD_IV_CHARS 103
534 # define PEM_R_BAD_MAGIC_NUMBER 116
535 # define PEM_R_BAD_PASSWORD_READ 104
536 # define PEM_R_BAD_VERSION_NUMBER 117
537 # define PEM_R_BIO_WRITE_FAILURE 118
538 # define PEM_R_CIPHER_IS_NULL 127
539 # define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115
540 # define PEM_R_EXPECTING_PRIVATE_KEY_BLOB 119
541 # define PEM_R_EXPECTING_PUBLIC_KEY_BLOB 120
542 # define PEM_R_INCONSISTENT_HEADER 121
543 # define PEM_R_KEYBLOB_HEADER_PARSE_ERROR 122
544 # define PEM_R_KEYBLOB_TOO_SHORT 123
545 # define PEM_R_NOT_DEK_INFO 105
546 # define PEM_R_NOT_ENCRYPTED 106
547 # define PEM_R_NOT_PROC_TYPE 107
548 # define PEM_R_NO_START_LINE 108
549 # define PEM_R_PROBLEMS_GETTING_PASSWORD 109
550 # define PEM_R_PUBLIC_KEY_NO_RSA 110
551 # define PEM_R_PVK_DATA_TOO_SHORT 124
552 # define PEM_R_PVK_TOO_SHORT 125
553 # define PEM_R_READ_KEY 111
554 # define PEM_R_SHORT_HEADER 112
555 # define PEM_R_UNSUPPORTED_CIPHER 113
556 # define PEM_R_UNSUPPORTED_ENCRYPTION 114
557 # define PEM_R_UNSUPPORTED_KEY_COMPONENTS 126
558
559 #ifdef __cplusplus
560 }
561 #endif
562 #endif