]> git.ipfire.org Git - thirdparty/openssl.git/blob - include/openssl/pem.h
Deprecate RSA harder
[thirdparty/openssl.git] / include / openssl / pem.h
1 /*
2 * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10 #ifndef OPENSSL_PEM_H
11 # define OPENSSL_PEM_H
12 # pragma once
13
14 # include <openssl/macros.h>
15 # ifndef OPENSSL_NO_DEPRECATED_3_0
16 # define HEADER_PEM_H
17 # endif
18
19 # include <openssl/e_os2.h>
20 # include <openssl/bio.h>
21 # include <openssl/safestack.h>
22 # include <openssl/evp.h>
23 # include <openssl/x509.h>
24 # include <openssl/pemerr.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 # define PEM_BUFSIZE 1024
31
32 # define PEM_STRING_X509_OLD "X509 CERTIFICATE"
33 # define PEM_STRING_X509 "CERTIFICATE"
34 # define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
35 # define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
36 # define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
37 # define PEM_STRING_X509_CRL "X509 CRL"
38 # define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"
39 # define PEM_STRING_PUBLIC "PUBLIC KEY"
40 # define PEM_STRING_RSA "RSA PRIVATE KEY"
41 # define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
42 # define PEM_STRING_DSA "DSA PRIVATE KEY"
43 # define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
44 # define PEM_STRING_PKCS7 "PKCS7"
45 # define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
46 # define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
47 # define PEM_STRING_PKCS8INF "PRIVATE KEY"
48 # define PEM_STRING_DHPARAMS "DH PARAMETERS"
49 # define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS"
50 # define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
51 # define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
52 # define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
53 # define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
54 # define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
55 # define PEM_STRING_PARAMETERS "PARAMETERS"
56 # define PEM_STRING_CMS "CMS"
57
58 # define PEM_TYPE_ENCRYPTED 10
59 # define PEM_TYPE_MIC_ONLY 20
60 # define PEM_TYPE_MIC_CLEAR 30
61 # define PEM_TYPE_CLEAR 40
62
63 /*
64 * These macros make the PEM_read/PEM_write functions easier to maintain and
65 * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or
66 * IMPLEMENT_PEM_rw_cb(...)
67 */
68
69 # define PEM_write_fnsig(name, type, OUTTYPE, writename) \
70 int PEM_##writename##_##name(OUTTYPE *out, const type *x)
71 # define PEM_write_cb_fnsig(name, type, OUTTYPE, writename) \
72 int PEM_##writename##_##name(OUTTYPE *out, const type *x, \
73 const EVP_CIPHER *enc, \
74 const unsigned char *kstr, int klen, \
75 pem_password_cb *cb, void *u)
76
77 # ifdef OPENSSL_NO_STDIO
78
79 # define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/
80 # define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/
81 # ifndef OPENSSL_NO_DEPRECATED_3_0
82 # define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/
83 # endif
84 # define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/
85 # ifndef OPENSSL_NO_DEPRECATED_3_0
86 # define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/
87 # endif
88 # else
89
90 # define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
91 type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u) \
92 { \
93 return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str, fp, \
94 (void **)x, cb, u); \
95 }
96
97 # define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
98 PEM_write_fnsig(name, type, FILE, write) \
99 { \
100 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out, \
101 x, NULL, NULL, 0, NULL, NULL); \
102 }
103
104 # ifndef OPENSSL_NO_DEPRECATED_3_0
105 # define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
106 IMPLEMENT_PEM_write_fp(name, type, str, asn1)
107 # endif
108
109 # define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
110 PEM_write_cb_fnsig(name, type, FILE, write) \
111 { \
112 return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out, \
113 x, enc, kstr, klen, cb, u); \
114 }
115
116 # ifndef OPENSSL_NO_DEPRECATED_3_0
117 # define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
118 IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
119 # endif
120 # endif
121
122 # define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
123 type *PEM_read_bio_##name(BIO *bp, type **x, \
124 pem_password_cb *cb, void *u) \
125 { \
126 return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str, bp, \
127 (void **)x, cb, u); \
128 }
129
130 # define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
131 PEM_write_fnsig(name, type, BIO, write_bio) \
132 { \
133 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out, \
134 x, NULL,NULL,0,NULL,NULL); \
135 }
136
137 # ifndef OPENSSL_NO_DEPRECATED_3_0
138 # define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
139 IMPLEMENT_PEM_write_bio(name, type, str, asn1)
140 # endif
141
142 # define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
143 PEM_write_cb_fnsig(name, type, BIO, write_bio) \
144 { \
145 return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out, \
146 x, enc, kstr, klen, cb, u); \
147 }
148
149 # ifndef OPENSSL_NO_DEPRECATED_3_0
150 # define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
151 IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1)
152 # endif
153
154 # define IMPLEMENT_PEM_write(name, type, str, asn1) \
155 IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
156 IMPLEMENT_PEM_write_fp(name, type, str, asn1)
157
158 # ifndef OPENSSL_NO_DEPRECATED_3_0
159 # define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
160 IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
161 IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
162 # endif
163
164 # define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
165 IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
166 IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
167
168 # ifndef OPENSSL_NO_DEPRECATED_3_0
169 # define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
170 IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
171 IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
172 # endif
173
174 # define IMPLEMENT_PEM_read(name, type, str, asn1) \
175 IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
176 IMPLEMENT_PEM_read_fp(name, type, str, asn1)
177
178 # define IMPLEMENT_PEM_rw(name, type, str, asn1) \
179 IMPLEMENT_PEM_read(name, type, str, asn1) \
180 IMPLEMENT_PEM_write(name, type, str, asn1)
181
182 # ifndef OPENSSL_NO_DEPRECATED_3_0
183 # define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
184 IMPLEMENT_PEM_read(name, type, str, asn1) \
185 IMPLEMENT_PEM_write_const(name, type, str, asn1)
186 # endif
187
188 # define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
189 IMPLEMENT_PEM_read(name, type, str, asn1) \
190 IMPLEMENT_PEM_write_cb(name, type, str, asn1)
191
192 /* These are the same except they are for the declarations */
193
194 /*
195 * The mysterious 'extern' that's passed to some macros is innocuous,
196 * and is there to quiet pre-C99 compilers that may complain about empty
197 * arguments in macro calls.
198 */
199 # if defined(OPENSSL_NO_STDIO)
200
201 # define DECLARE_PEM_read_fp_attr(attr, name, type) /**/
202 # define DECLARE_PEM_write_fp_attr(attr, name, type) /**/
203 # define DECLARE_PEM_write_fp_attr(attr, name, type) /**/
204 # ifndef OPENSSL_NO_DEPRECATED_3_0
205 # define DECLARE_PEM_write_fp_const_attr(attr, name, type) /**/
206 # endif
207 # define DECLARE_PEM_write_cb_fp_attr(attr, name, type) /**/
208
209 # else
210
211 # define DECLARE_PEM_read_fp_attr(attr, name, type) \
212 attr type *PEM_read_##name(FILE *fp, type **x, \
213 pem_password_cb *cb, void *u);
214 # define DECLARE_PEM_write_fp_attr(attr, name, type) \
215 attr PEM_write_fnsig(name, type, FILE, write);
216 # ifndef OPENSSL_NO_DEPRECATED_3_0
217 # define DECLARE_PEM_write_fp_const_attr(attr, name, type) \
218 attr PEM_write_fnsig(name, type, FILE, write);
219 # endif
220 # define DECLARE_PEM_write_cb_fp_attr(attr, name, type) \
221 attr PEM_write_cb_fnsig(name, type, FILE, write);
222
223 # endif
224
225 # define DECLARE_PEM_read_fp(name, type) \
226 DECLARE_PEM_read_fp_attr(extern, name, type)
227 # define DECLARE_PEM_write_fp(name, type) \
228 DECLARE_PEM_write_fp_attr(extern, name, type)
229 # ifndef OPENSSL_NO_DEPRECATED_3_0
230 # define DECLARE_PEM_write_fp_const(name, type) \
231 DECLARE_PEM_write_fp_const_attr(extern, name, type)
232 # endif
233 # define DECLARE_PEM_write_cb_fp(name, type) \
234 DECLARE_PEM_write_cb_fp_attr(extern, name, type)
235
236 # define DECLARE_PEM_read_bio_attr(attr, name, type) \
237 attr type *PEM_read_bio_##name(BIO *bp, type **x, \
238 pem_password_cb *cb, void *u);
239 # define DECLARE_PEM_read_bio(name, type) \
240 DECLARE_PEM_read_bio_attr(extern, name, type)
241
242 # define DECLARE_PEM_write_bio_attr(attr, name, type) \
243 attr PEM_write_fnsig(name, type, BIO, write_bio);
244 # define DECLARE_PEM_write_bio(name, type) \
245 DECLARE_PEM_write_bio_attr(extern, name, type)
246
247 # ifndef OPENSSL_NO_DEPRECATED_3_0
248 # define DECLARE_PEM_write_bio_const_attr(attr, name, type) \
249 attr PEM_write_fnsig(name, type, BIO, write_bio);
250 # define DECLARE_PEM_write_bio_const(name, type) \
251 DECLARE_PEM_write_bio_const_attr(extern, name, type)
252 # endif
253
254 # define DECLARE_PEM_write_cb_bio_attr(attr, name, type) \
255 attr PEM_write_cb_fnsig(name, type, BIO, write_bio);
256 # define DECLARE_PEM_write_cb_bio(name, type) \
257 DECLARE_PEM_write_cb_bio_attr(extern, name, type)
258
259 # define DECLARE_PEM_write_attr(attr, name, type) \
260 DECLARE_PEM_write_bio_attr(attr, name, type) \
261 DECLARE_PEM_write_fp_attr(attr, name, type)
262 # define DECLARE_PEM_write(name, type) \
263 DECLARE_PEM_write_attr(extern, name, type)
264 # ifndef OPENSSL_NO_DEPRECATED_3_0
265 # define DECLARE_PEM_write_const_attr(attr, name, type) \
266 DECLARE_PEM_write_bio_const_attr(attr, name, type) \
267 DECLARE_PEM_write_fp_const_attr(attr, name, type)
268 # define DECLARE_PEM_write_const(name, type) \
269 DECLARE_PEM_write_const_attr(extern, name, type)
270 # endif
271 # define DECLARE_PEM_write_cb_attr(attr, name, type) \
272 DECLARE_PEM_write_cb_bio_attr(attr, name, type) \
273 DECLARE_PEM_write_cb_fp_attr(attr, name, type)
274 # define DECLARE_PEM_write_cb(name, type) \
275 DECLARE_PEM_write_cb_attr(extern, name, type)
276 # define DECLARE_PEM_read_attr(attr, name, type) \
277 DECLARE_PEM_read_bio_attr(attr, name, type) \
278 DECLARE_PEM_read_fp_attr(attr, name, type)
279 # define DECLARE_PEM_read(name, type) \
280 DECLARE_PEM_read_attr(extern, name, type)
281 # define DECLARE_PEM_rw_attr(attr, name, type) \
282 DECLARE_PEM_read_attr(attr, name, type) \
283 DECLARE_PEM_write_attr(attr, name, type)
284 # define DECLARE_PEM_rw(name, type) \
285 DECLARE_PEM_rw_attr(extern, name, type)
286 # ifndef OPENSSL_NO_DEPRECATED_3_0
287 # define DECLARE_PEM_rw_const_attr(attr, name, type) \
288 DECLARE_PEM_read_attr(attr, name, type) \
289 DECLARE_PEM_write_const_attr(attr, name, type)
290 # define DECLARE_PEM_rw_const(name, type) \
291 DECLARE_PEM_rw_const_attr(extern, name, type)
292 # endif
293 # define DECLARE_PEM_rw_cb_attr(attr, name, type) \
294 DECLARE_PEM_read_attr(attr, name, type) \
295 DECLARE_PEM_write_cb_attr(attr, name, type)
296 # define DECLARE_PEM_rw_cb(name, type) \
297 DECLARE_PEM_rw_cb_attr(extern, name, type)
298
299 int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
300 int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,
301 pem_password_cb *callback, void *u);
302
303 int PEM_read_bio(BIO *bp, char **name, char **header,
304 unsigned char **data, long *len);
305 # define PEM_FLAG_SECURE 0x1
306 # define PEM_FLAG_EAY_COMPATIBLE 0x2
307 # define PEM_FLAG_ONLY_B64 0x4
308 int PEM_read_bio_ex(BIO *bp, char **name, char **header,
309 unsigned char **data, long *len, unsigned int flags);
310 int PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm,
311 const char *name, BIO *bp, pem_password_cb *cb,
312 void *u);
313 int PEM_write_bio(BIO *bp, const char *name, const char *hdr,
314 const unsigned char *data, long len);
315 int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
316 const char *name, BIO *bp, pem_password_cb *cb,
317 void *u);
318 void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,
319 pem_password_cb *cb, void *u);
320 int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp,
321 const void *x, const EVP_CIPHER *enc,
322 const unsigned char *kstr, int klen,
323 pem_password_cb *cb, void *u);
324
325 STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,
326 pem_password_cb *cb, void *u);
327 STACK_OF(X509_INFO)
328 *PEM_X509_INFO_read_bio_ex(BIO *bp, STACK_OF(X509_INFO) *sk,
329 pem_password_cb *cb, void *u, OSSL_LIB_CTX *libctx,
330 const char *propq);
331
332 int PEM_X509_INFO_write_bio(BIO *bp, const X509_INFO *xi, EVP_CIPHER *enc,
333 const unsigned char *kstr, int klen,
334 pem_password_cb *cd, void *u);
335
336 #ifndef OPENSSL_NO_STDIO
337 int PEM_read(FILE *fp, char **name, char **header,
338 unsigned char **data, long *len);
339 int PEM_write(FILE *fp, const char *name, const char *hdr,
340 const unsigned char *data, long len);
341 void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
342 pem_password_cb *cb, void *u);
343 int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
344 const void *x, const EVP_CIPHER *enc,
345 const unsigned char *kstr, int klen,
346 pem_password_cb *callback, void *u);
347 STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
348 pem_password_cb *cb, void *u);
349 STACK_OF(X509_INFO)
350 *PEM_X509_INFO_read_ex(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb,
351 void *u, OSSL_LIB_CTX *libctx, const char *propq);
352 #endif
353
354 int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
355 int PEM_SignUpdate(EVP_MD_CTX *ctx, const unsigned char *d, unsigned int cnt);
356 int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
357 unsigned int *siglen, EVP_PKEY *pkey);
358
359 /* The default pem_password_cb that's used internally */
360 int PEM_def_callback(char *buf, int num, int rwflag, void *userdata);
361 void PEM_proc_type(char *buf, int type);
362 void PEM_dek_info(char *buf, const char *type, int len, const char *str);
363
364 # include <openssl/symhacks.h>
365
366 DECLARE_PEM_rw(X509, X509)
367 DECLARE_PEM_rw(X509_AUX, X509)
368 DECLARE_PEM_rw(X509_REQ, X509_REQ)
369 DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
370 DECLARE_PEM_rw(X509_CRL, X509_CRL)
371 DECLARE_PEM_rw(X509_PUBKEY, X509_PUBKEY)
372 DECLARE_PEM_rw(PKCS7, PKCS7)
373 DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
374 DECLARE_PEM_rw(PKCS8, X509_SIG)
375 DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
376 # ifndef OPENSSL_NO_DEPRECATED_3_0
377 # ifndef OPENSSL_NO_RSA
378 DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, RSAPrivateKey, RSA)
379 DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSAPublicKey, RSA)
380 DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSA_PUBKEY, RSA)
381 # endif
382 # endif
383 # ifndef OPENSSL_NO_DSA
384 DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
385 DECLARE_PEM_rw(DSA_PUBKEY, DSA)
386 DECLARE_PEM_rw(DSAparams, DSA)
387 # endif
388 # ifndef OPENSSL_NO_EC
389 DECLARE_PEM_rw(ECPKParameters, EC_GROUP)
390 DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
391 DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
392 # endif
393 # ifndef OPENSSL_NO_DH
394 DECLARE_PEM_rw(DHparams, DH)
395 DECLARE_PEM_write(DHxparams, DH)
396 # endif
397 DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
398 EVP_PKEY *PEM_read_bio_PrivateKey_ex(BIO *bp, EVP_PKEY **x,
399 pem_password_cb *cb, void *u,
400 OSSL_LIB_CTX *libctx, const char *propq);
401 # ifndef OPENSSL_NO_STDIO
402 EVP_PKEY *PEM_read_PrivateKey_ex(FILE *fp, EVP_PKEY **x,
403 pem_password_cb *cb, void *u,
404 OSSL_LIB_CTX *libctx, const char *propq);
405 # endif
406 DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
407 EVP_PKEY *PEM_read_bio_PUBKEY_ex(BIO *bp, EVP_PKEY **x,
408 pem_password_cb *cb, void *u,
409 OSSL_LIB_CTX *libctx, const char *propq);
410 # ifndef OPENSSL_NO_STDIO
411 EVP_PKEY *PEM_read_PUBKEY_ex(FILE *fp, EVP_PKEY **x,
412 pem_password_cb *cb, void *u,
413 OSSL_LIB_CTX *libctx, const char *propq);
414 # endif
415
416 int PEM_write_bio_PrivateKey_traditional(BIO *bp, const EVP_PKEY *x,
417 const EVP_CIPHER *enc,
418 const unsigned char *kstr, int klen,
419 pem_password_cb *cb, void *u);
420
421 /* Why do these take a signed char *kstr? */
422 int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, const EVP_PKEY *x, int nid,
423 const char *kstr, int klen,
424 pem_password_cb *cb, void *u);
425 int PEM_write_bio_PKCS8PrivateKey(BIO *, const EVP_PKEY *, const EVP_CIPHER *,
426 const char *kstr, int klen,
427 pem_password_cb *cb, void *u);
428 int i2d_PKCS8PrivateKey_bio(BIO *bp, const EVP_PKEY *x, const EVP_CIPHER *enc,
429 const char *kstr, int klen,
430 pem_password_cb *cb, void *u);
431 int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, const EVP_PKEY *x, int nid,
432 const char *kstr, int klen,
433 pem_password_cb *cb, void *u);
434 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
435 void *u);
436
437 # ifndef OPENSSL_NO_STDIO
438 int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc,
439 const char *kstr, int klen,
440 pem_password_cb *cb, void *u);
441 int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *x, int nid,
442 const char *kstr, int klen,
443 pem_password_cb *cb, void *u);
444 int PEM_write_PKCS8PrivateKey_nid(FILE *fp, const EVP_PKEY *x, int nid,
445 const char *kstr, int klen,
446 pem_password_cb *cb, void *u);
447
448 EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
449 void *u);
450
451 int PEM_write_PKCS8PrivateKey(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc,
452 const char *kstr, int klen,
453 pem_password_cb *cd, void *u);
454 # endif
455 EVP_PKEY *PEM_read_bio_Parameters_ex(BIO *bp, EVP_PKEY **x,
456 OSSL_LIB_CTX *libctx, const char *propq);
457 EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
458 int PEM_write_bio_Parameters(BIO *bp, const EVP_PKEY *x);
459
460 # ifndef OPENSSL_NO_DSA
461 EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
462 EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
463 EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
464 EVP_PKEY *b2i_PublicKey_bio(BIO *in);
465 int i2b_PrivateKey_bio(BIO *out, const EVP_PKEY *pk);
466 int i2b_PublicKey_bio(BIO *out, const EVP_PKEY *pk);
467 # ifndef OPENSSL_NO_RC4
468 EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
469 int i2b_PVK_bio(BIO *out, const EVP_PKEY *pk, int enclevel,
470 pem_password_cb *cb, void *u);
471 # endif
472 # endif
473
474 # ifdef __cplusplus
475 }
476 # endif
477 #endif