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