]>
Commit | Line | Data |
---|---|---|
21dcbebc RS |
1 | /* |
2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. | |
d02b48c6 | 3 | * |
21dcbebc RS |
4 | * Licensed under the OpenSSL license (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 | |
d02b48c6 RE |
8 | */ |
9 | ||
d02b48c6 | 10 | #ifndef HEADER_PEM_H |
0f113f3e MC |
11 | # define HEADER_PEM_H |
12 | ||
13 | # include <openssl/e_os2.h> | |
a00ae6c4 RS |
14 | # include <openssl/bio.h> |
15 | # include <openssl/stack.h> | |
0f113f3e MC |
16 | # include <openssl/evp.h> |
17 | # include <openssl/x509.h> | |
18 | # include <openssl/pem2.h> | |
d02b48c6 | 19 | |
82271cee RL |
20 | #ifdef __cplusplus |
21 | extern "C" { | |
22 | #endif | |
23 | ||
0f113f3e MC |
24 | # define PEM_BUFSIZE 1024 |
25 | ||
0f113f3e MC |
26 | # define PEM_STRING_X509_OLD "X509 CERTIFICATE" |
27 | # define PEM_STRING_X509 "CERTIFICATE" | |
0f113f3e MC |
28 | # define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE" |
29 | # define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" | |
30 | # define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" | |
31 | # define PEM_STRING_X509_CRL "X509 CRL" | |
32 | # define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" | |
33 | # define PEM_STRING_PUBLIC "PUBLIC KEY" | |
34 | # define PEM_STRING_RSA "RSA PRIVATE KEY" | |
35 | # define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" | |
36 | # define PEM_STRING_DSA "DSA PRIVATE KEY" | |
37 | # define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" | |
38 | # define PEM_STRING_PKCS7 "PKCS7" | |
39 | # define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA" | |
40 | # define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" | |
41 | # define PEM_STRING_PKCS8INF "PRIVATE KEY" | |
42 | # define PEM_STRING_DHPARAMS "DH PARAMETERS" | |
43 | # define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS" | |
44 | # define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" | |
45 | # define PEM_STRING_DSAPARAMS "DSA PARAMETERS" | |
46 | # define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" | |
47 | # define PEM_STRING_ECPARAMETERS "EC PARAMETERS" | |
48 | # define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" | |
49 | # define PEM_STRING_PARAMETERS "PARAMETERS" | |
50 | # define PEM_STRING_CMS "CMS" | |
51 | ||
0f113f3e MC |
52 | # define PEM_TYPE_ENCRYPTED 10 |
53 | # define PEM_TYPE_MIC_ONLY 20 | |
54 | # define PEM_TYPE_MIC_CLEAR 30 | |
55 | # define PEM_TYPE_CLEAR 40 | |
56 | ||
0f113f3e MC |
57 | /* |
58 | * These macros make the PEM_read/PEM_write functions easier to maintain and | |
59 | * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or | |
60 | * IMPLEMENT_PEM_rw_cb(...) | |
f62676b9 DSH |
61 | */ |
62 | ||
0f113f3e | 63 | # ifdef OPENSSL_NO_STDIO |
f62676b9 | 64 | |
0f113f3e MC |
65 | # define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ |
66 | # define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ | |
67 | # define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/ | |
68 | # define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ | |
69 | # define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/ | |
70 | # else | |
f62676b9 | 71 | |
0f113f3e | 72 | # define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ |
74678cc2 | 73 | type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ |
f62676b9 | 74 | { \ |
297e6f19 | 75 | return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \ |
0f113f3e | 76 | } |
f62676b9 | 77 | |
0f113f3e | 78 | # define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ |
f62676b9 DSH |
79 | int PEM_write_##name(FILE *fp, type *x) \ |
80 | { \ | |
297e6f19 | 81 | return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \ |
41a15c4f BL |
82 | } |
83 | ||
0f113f3e | 84 | # define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ |
67ffa18c | 85 | int PEM_write_##name(FILE *fp, const type *x) \ |
41a15c4f | 86 | { \ |
297e6f19 | 87 | return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \ |
a2400fca | 88 | } |
f62676b9 | 89 | |
0f113f3e | 90 | # define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ |
f62676b9 | 91 | int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ |
0f113f3e MC |
92 | unsigned char *kstr, int klen, pem_password_cb *cb, \ |
93 | void *u) \ | |
94 | { \ | |
95 | return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ | |
96 | } | |
41a15c4f | 97 | |
0f113f3e | 98 | # define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ |
41a15c4f | 99 | int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ |
0f113f3e MC |
100 | unsigned char *kstr, int klen, pem_password_cb *cb, \ |
101 | void *u) \ | |
102 | { \ | |
103 | return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ | |
104 | } | |
f62676b9 | 105 | |
0f113f3e | 106 | # endif |
f62676b9 | 107 | |
0f113f3e | 108 | # define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ |
74678cc2 | 109 | type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ |
f62676b9 | 110 | { \ |
297e6f19 | 111 | return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \ |
f62676b9 DSH |
112 | } |
113 | ||
0f113f3e | 114 | # define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ |
f62676b9 DSH |
115 | int PEM_write_bio_##name(BIO *bp, type *x) \ |
116 | { \ | |
297e6f19 | 117 | return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \ |
41a15c4f BL |
118 | } |
119 | ||
0f113f3e | 120 | # define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ |
67ffa18c | 121 | int PEM_write_bio_##name(BIO *bp, const type *x) \ |
41a15c4f | 122 | { \ |
297e6f19 | 123 | return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \ |
f62676b9 DSH |
124 | } |
125 | ||
0f113f3e | 126 | # define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ |
f62676b9 | 127 | int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ |
0f113f3e MC |
128 | unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ |
129 | { \ | |
130 | return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \ | |
131 | } | |
41a15c4f | 132 | |
0f113f3e | 133 | # define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ |
41a15c4f | 134 | int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ |
0f113f3e MC |
135 | unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ |
136 | { \ | |
137 | return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \ | |
138 | } | |
f62676b9 | 139 | |
0f113f3e MC |
140 | # define IMPLEMENT_PEM_write(name, type, str, asn1) \ |
141 | IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ | |
142 | IMPLEMENT_PEM_write_fp(name, type, str, asn1) | |
f62676b9 | 143 | |
0f113f3e MC |
144 | # define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ |
145 | IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ | |
146 | IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) | |
41a15c4f | 147 | |
0f113f3e MC |
148 | # define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ |
149 | IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ | |
150 | IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) | |
f62676b9 | 151 | |
0f113f3e MC |
152 | # define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ |
153 | IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ | |
154 | IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) | |
41a15c4f | 155 | |
0f113f3e MC |
156 | # define IMPLEMENT_PEM_read(name, type, str, asn1) \ |
157 | IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ | |
158 | IMPLEMENT_PEM_read_fp(name, type, str, asn1) | |
f62676b9 | 159 | |
0f113f3e MC |
160 | # define IMPLEMENT_PEM_rw(name, type, str, asn1) \ |
161 | IMPLEMENT_PEM_read(name, type, str, asn1) \ | |
162 | IMPLEMENT_PEM_write(name, type, str, asn1) | |
f62676b9 | 163 | |
0f113f3e MC |
164 | # define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ |
165 | IMPLEMENT_PEM_read(name, type, str, asn1) \ | |
166 | IMPLEMENT_PEM_write_const(name, type, str, asn1) | |
41a15c4f | 167 | |
0f113f3e MC |
168 | # define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ |
169 | IMPLEMENT_PEM_read(name, type, str, asn1) \ | |
170 | IMPLEMENT_PEM_write_cb(name, type, str, asn1) | |
f62676b9 | 171 | |
dbd665c2 DSH |
172 | /* These are the same except they are for the declarations */ |
173 | ||
0f113f3e MC |
174 | # if defined(OPENSSL_NO_STDIO) |
175 | ||
176 | # define DECLARE_PEM_read_fp(name, type) /**/ | |
177 | # define DECLARE_PEM_write_fp(name, type) /**/ | |
984d6c60 | 178 | # define DECLARE_PEM_write_fp_const(name, type) /**/ |
0f113f3e MC |
179 | # define DECLARE_PEM_write_cb_fp(name, type) /**/ |
180 | # else | |
181 | ||
182 | # define DECLARE_PEM_read_fp(name, type) \ | |
183 | type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u); | |
184 | ||
185 | # define DECLARE_PEM_write_fp(name, type) \ | |
186 | int PEM_write_##name(FILE *fp, type *x); | |
187 | ||
188 | # define DECLARE_PEM_write_fp_const(name, type) \ | |
189 | int PEM_write_##name(FILE *fp, const type *x); | |
190 | ||
191 | # define DECLARE_PEM_write_cb_fp(name, type) \ | |
192 | int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ | |
193 | unsigned char *kstr, int klen, pem_password_cb *cb, void *u); | |
194 | ||
195 | # endif | |
196 | ||
0f113f3e MC |
197 | # define DECLARE_PEM_read_bio(name, type) \ |
198 | type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); | |
199 | ||
200 | # define DECLARE_PEM_write_bio(name, type) \ | |
201 | int PEM_write_bio_##name(BIO *bp, type *x); | |
202 | ||
203 | # define DECLARE_PEM_write_bio_const(name, type) \ | |
204 | int PEM_write_bio_##name(BIO *bp, const type *x); | |
205 | ||
206 | # define DECLARE_PEM_write_cb_bio(name, type) \ | |
207 | int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ | |
208 | unsigned char *kstr, int klen, pem_password_cb *cb, void *u); | |
209 | ||
0f113f3e MC |
210 | # define DECLARE_PEM_write(name, type) \ |
211 | DECLARE_PEM_write_bio(name, type) \ | |
212 | DECLARE_PEM_write_fp(name, type) | |
213 | # define DECLARE_PEM_write_const(name, type) \ | |
214 | DECLARE_PEM_write_bio_const(name, type) \ | |
215 | DECLARE_PEM_write_fp_const(name, type) | |
216 | # define DECLARE_PEM_write_cb(name, type) \ | |
217 | DECLARE_PEM_write_cb_bio(name, type) \ | |
218 | DECLARE_PEM_write_cb_fp(name, type) | |
219 | # define DECLARE_PEM_read(name, type) \ | |
220 | DECLARE_PEM_read_bio(name, type) \ | |
221 | DECLARE_PEM_read_fp(name, type) | |
222 | # define DECLARE_PEM_rw(name, type) \ | |
223 | DECLARE_PEM_read(name, type) \ | |
224 | DECLARE_PEM_write(name, type) | |
225 | # define DECLARE_PEM_rw_const(name, type) \ | |
226 | DECLARE_PEM_read(name, type) \ | |
227 | DECLARE_PEM_write_const(name, type) | |
228 | # define DECLARE_PEM_rw_cb(name, type) \ | |
229 | DECLARE_PEM_read(name, type) \ | |
230 | DECLARE_PEM_write_cb(name, type) | |
0f113f3e | 231 | typedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata); |
0f113f3e MC |
232 | |
233 | int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); | |
234 | int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len, | |
235 | pem_password_cb *callback, void *u); | |
236 | ||
0f113f3e MC |
237 | int PEM_read_bio(BIO *bp, char **name, char **header, |
238 | unsigned char **data, long *len); | |
239 | int PEM_write_bio(BIO *bp, const char *name, const char *hdr, | |
240 | const unsigned char *data, long len); | |
241 | int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, | |
242 | const char *name, BIO *bp, pem_password_cb *cb, | |
243 | void *u); | |
244 | void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, | |
245 | pem_password_cb *cb, void *u); | |
246 | int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x, | |
247 | const EVP_CIPHER *enc, unsigned char *kstr, int klen, | |
248 | pem_password_cb *cb, void *u); | |
249 | ||
250 | STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, | |
251 | pem_password_cb *cb, void *u); | |
252 | int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, | |
253 | unsigned char *kstr, int klen, | |
254 | pem_password_cb *cd, void *u); | |
0f113f3e | 255 | |
984d6c60 | 256 | #ifndef OPENSSL_NO_STDIO |
0f113f3e MC |
257 | int PEM_read(FILE *fp, char **name, char **header, |
258 | unsigned char **data, long *len); | |
259 | int PEM_write(FILE *fp, const char *name, const char *hdr, | |
260 | const unsigned char *data, long len); | |
261 | void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, | |
262 | pem_password_cb *cb, void *u); | |
263 | int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, | |
264 | void *x, const EVP_CIPHER *enc, unsigned char *kstr, | |
265 | int klen, pem_password_cb *callback, void *u); | |
266 | STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, | |
267 | pem_password_cb *cb, void *u); | |
984d6c60 | 268 | #endif |
0f113f3e | 269 | |
0f113f3e MC |
270 | int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); |
271 | int PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt); | |
272 | int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, | |
273 | unsigned int *siglen, EVP_PKEY *pkey); | |
274 | ||
275 | int PEM_def_callback(char *buf, int num, int w, void *key); | |
276 | void PEM_proc_type(char *buf, int type); | |
277 | void PEM_dek_info(char *buf, const char *type, int len, char *str); | |
278 | ||
279 | # include <openssl/symhacks.h> | |
8c197cc5 | 280 | |
dbd665c2 | 281 | DECLARE_PEM_rw(X509, X509) |
ce1b4fe1 | 282 | DECLARE_PEM_rw(X509_AUX, X509) |
a8fe430a MC |
283 | DECLARE_PEM_rw(X509_REQ, X509_REQ) |
284 | DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) | |
dbd665c2 | 285 | DECLARE_PEM_rw(X509_CRL, X509_CRL) |
dbd665c2 | 286 | DECLARE_PEM_rw(PKCS7, PKCS7) |
dbd665c2 | 287 | DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) |
dbd665c2 | 288 | DECLARE_PEM_rw(PKCS8, X509_SIG) |
dbd665c2 | 289 | DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) |
0f113f3e | 290 | # ifndef OPENSSL_NO_RSA |
dbd665c2 | 291 | DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) |
a8fe430a MC |
292 | DECLARE_PEM_rw_const(RSAPublicKey, RSA) |
293 | DECLARE_PEM_rw(RSA_PUBKEY, RSA) | |
0f113f3e MC |
294 | # endif |
295 | # ifndef OPENSSL_NO_DSA | |
dbd665c2 | 296 | DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) |
a8fe430a MC |
297 | DECLARE_PEM_rw(DSA_PUBKEY, DSA) |
298 | DECLARE_PEM_rw_const(DSAparams, DSA) | |
0f113f3e MC |
299 | # endif |
300 | # ifndef OPENSSL_NO_EC | |
67ffa18c | 301 | DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP) |
a8fe430a MC |
302 | DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) |
303 | DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) | |
0f113f3e MC |
304 | # endif |
305 | # ifndef OPENSSL_NO_DH | |
a8fe430a MC |
306 | DECLARE_PEM_rw_const(DHparams, DH) |
307 | DECLARE_PEM_write_const(DHxparams, DH) | |
0f113f3e | 308 | # endif |
a8fe430a MC |
309 | DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) |
310 | DECLARE_PEM_rw(PUBKEY, EVP_PKEY) | |
52664f50 | 311 | |
05dba815 DSH |
312 | int PEM_write_bio_PrivateKey_traditional(BIO *bp, EVP_PKEY *x, |
313 | const EVP_CIPHER *enc, | |
314 | unsigned char *kstr, int klen, | |
315 | pem_password_cb *cb, void *u); | |
316 | ||
525f51f6 | 317 | int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, |
0f113f3e MC |
318 | char *kstr, int klen, |
319 | pem_password_cb *cb, void *u); | |
1d5edd08 RE |
320 | int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, |
321 | char *, int, pem_password_cb *, void *); | |
525f51f6 | 322 | int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, |
0f113f3e MC |
323 | char *kstr, int klen, |
324 | pem_password_cb *cb, void *u); | |
525f51f6 | 325 | int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, |
0f113f3e MC |
326 | char *kstr, int klen, |
327 | pem_password_cb *cb, void *u); | |
328 | EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, | |
329 | void *u); | |
525f51f6 | 330 | |
04e381ff | 331 | # ifndef OPENSSL_NO_STDIO |
525f51f6 | 332 | int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, |
0f113f3e MC |
333 | char *kstr, int klen, |
334 | pem_password_cb *cb, void *u); | |
525f51f6 | 335 | int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, |
0f113f3e MC |
336 | char *kstr, int klen, |
337 | pem_password_cb *cb, void *u); | |
525f51f6 | 338 | int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, |
0f113f3e MC |
339 | char *kstr, int klen, |
340 | pem_password_cb *cb, void *u); | |
525f51f6 | 341 | |
0f113f3e MC |
342 | EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, |
343 | void *u); | |
525f51f6 | 344 | |
0f113f3e MC |
345 | int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, |
346 | char *kstr, int klen, pem_password_cb *cd, | |
347 | void *u); | |
04e381ff | 348 | # endif |
3e4585c8 DSH |
349 | EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x); |
350 | int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x); | |
351 | ||
54c010ab | 352 | # ifndef OPENSSL_NO_DSA |
a0156a92 DSH |
353 | EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length); |
354 | EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length); | |
355 | EVP_PKEY *b2i_PrivateKey_bio(BIO *in); | |
356 | EVP_PKEY *b2i_PublicKey_bio(BIO *in); | |
357 | int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk); | |
358 | int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk); | |
54c010ab | 359 | # ifndef OPENSSL_NO_RC4 |
a0156a92 DSH |
360 | EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u); |
361 | int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel, | |
0f113f3e | 362 | pem_password_cb *cb, void *u); |
54c010ab | 363 | # endif |
0f113f3e | 364 | # endif |
a0156a92 | 365 | |
d02b48c6 | 366 | /* BEGIN ERROR CODES */ |
0f113f3e MC |
367 | /* |
368 | * The following lines are auto generated by the script mkerr.pl. Any changes | |
6d311938 DSH |
369 | * made after this point may be overwritten when the script is next run. |
370 | */ | |
0cd0a820 | 371 | |
69588edb | 372 | int ERR_load_PEM_strings(void); |
6d311938 | 373 | |
d02b48c6 RE |
374 | /* Error codes for the PEM functions. */ |
375 | ||
376 | /* Function codes. */ | |
0f113f3e MC |
377 | # define PEM_F_B2I_DSS 127 |
378 | # define PEM_F_B2I_PVK_BIO 128 | |
379 | # define PEM_F_B2I_RSA 129 | |
380 | # define PEM_F_CHECK_BITLEN_DSA 130 | |
381 | # define PEM_F_CHECK_BITLEN_RSA 131 | |
382 | # define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 | |
383 | # define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 | |
384 | # define PEM_F_DO_B2I 132 | |
385 | # define PEM_F_DO_B2I_BIO 133 | |
386 | # define PEM_F_DO_BLOB_HEADER 134 | |
387 | # define PEM_F_DO_PK8PKEY 126 | |
388 | # define PEM_F_DO_PK8PKEY_FP 125 | |
389 | # define PEM_F_DO_PVK_BODY 135 | |
390 | # define PEM_F_DO_PVK_HEADER 136 | |
391 | # define PEM_F_I2B_PVK 137 | |
392 | # define PEM_F_I2B_PVK_BIO 138 | |
393 | # define PEM_F_LOAD_IV 101 | |
394 | # define PEM_F_PEM_ASN1_READ 102 | |
395 | # define PEM_F_PEM_ASN1_READ_BIO 103 | |
396 | # define PEM_F_PEM_ASN1_WRITE 104 | |
397 | # define PEM_F_PEM_ASN1_WRITE_BIO 105 | |
398 | # define PEM_F_PEM_DEF_CALLBACK 100 | |
399 | # define PEM_F_PEM_DO_HEADER 106 | |
0f113f3e | 400 | # define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 |
0f113f3e MC |
401 | # define PEM_F_PEM_READ 108 |
402 | # define PEM_F_PEM_READ_BIO 109 | |
403 | # define PEM_F_PEM_READ_BIO_DHPARAMS 141 | |
404 | # define PEM_F_PEM_READ_BIO_PARAMETERS 140 | |
405 | # define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 | |
406 | # define PEM_F_PEM_READ_DHPARAMS 142 | |
407 | # define PEM_F_PEM_READ_PRIVATEKEY 124 | |
0f113f3e MC |
408 | # define PEM_F_PEM_SIGNFINAL 112 |
409 | # define PEM_F_PEM_WRITE 113 | |
410 | # define PEM_F_PEM_WRITE_BIO 114 | |
411 | # define PEM_F_PEM_WRITE_PRIVATEKEY 139 | |
412 | # define PEM_F_PEM_X509_INFO_READ 115 | |
413 | # define PEM_F_PEM_X509_INFO_READ_BIO 116 | |
414 | # define PEM_F_PEM_X509_INFO_WRITE_BIO 117 | |
d02b48c6 RE |
415 | |
416 | /* Reason codes. */ | |
0f113f3e MC |
417 | # define PEM_R_BAD_BASE64_DECODE 100 |
418 | # define PEM_R_BAD_DECRYPT 101 | |
419 | # define PEM_R_BAD_END_LINE 102 | |
420 | # define PEM_R_BAD_IV_CHARS 103 | |
421 | # define PEM_R_BAD_MAGIC_NUMBER 116 | |
422 | # define PEM_R_BAD_PASSWORD_READ 104 | |
423 | # define PEM_R_BAD_VERSION_NUMBER 117 | |
424 | # define PEM_R_BIO_WRITE_FAILURE 118 | |
425 | # define PEM_R_CIPHER_IS_NULL 127 | |
426 | # define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 | |
427 | # define PEM_R_EXPECTING_PRIVATE_KEY_BLOB 119 | |
428 | # define PEM_R_EXPECTING_PUBLIC_KEY_BLOB 120 | |
a5a3722b | 429 | # define PEM_R_HEADER_TOO_LONG 128 |
0f113f3e MC |
430 | # define PEM_R_INCONSISTENT_HEADER 121 |
431 | # define PEM_R_KEYBLOB_HEADER_PARSE_ERROR 122 | |
432 | # define PEM_R_KEYBLOB_TOO_SHORT 123 | |
a5a3722b | 433 | # define PEM_R_MISSING_DEK_IV 129 |
0f113f3e MC |
434 | # define PEM_R_NOT_DEK_INFO 105 |
435 | # define PEM_R_NOT_ENCRYPTED 106 | |
436 | # define PEM_R_NOT_PROC_TYPE 107 | |
437 | # define PEM_R_NO_START_LINE 108 | |
438 | # define PEM_R_PROBLEMS_GETTING_PASSWORD 109 | |
0f113f3e MC |
439 | # define PEM_R_PVK_DATA_TOO_SHORT 124 |
440 | # define PEM_R_PVK_TOO_SHORT 125 | |
441 | # define PEM_R_READ_KEY 111 | |
442 | # define PEM_R_SHORT_HEADER 112 | |
a5a3722b | 443 | # define PEM_R_UNEXPECTED_DEK_IV 130 |
0f113f3e MC |
444 | # define PEM_R_UNSUPPORTED_CIPHER 113 |
445 | # define PEM_R_UNSUPPORTED_ENCRYPTION 114 | |
446 | # define PEM_R_UNSUPPORTED_KEY_COMPONENTS 126 | |
6d311938 | 447 | |
0cd0a820 | 448 | # ifdef __cplusplus |
d02b48c6 | 449 | } |
0cd0a820 | 450 | # endif |
d02b48c6 | 451 | #endif |