]>
Commit | Line | Data |
---|---|---|
169cc7a1 | 1 | /* crypto/pem/pem.h */ |
d02b48c6 RE |
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 | ||
d02b48c6 RE |
59 | #ifndef HEADER_PEM_H |
60 | #define HEADER_PEM_H | |
61 | ||
62 | #ifdef __cplusplus | |
63 | extern "C" { | |
64 | #endif | |
65 | ||
ec577822 BM |
66 | #include <openssl/evp.h> |
67 | #include <openssl/x509.h> | |
68 | #include <openssl/pem2.h> | |
d02b48c6 RE |
69 | |
70 | #define PEM_OBJ_UNDEF 0 | |
71 | #define PEM_OBJ_X509 1 | |
72 | #define PEM_OBJ_X509_REQ 2 | |
73 | #define PEM_OBJ_CRL 3 | |
74 | #define PEM_OBJ_SSL_SESSION 4 | |
75 | #define PEM_OBJ_PRIV_KEY 10 | |
76 | #define PEM_OBJ_PRIV_RSA 11 | |
77 | #define PEM_OBJ_PRIV_DSA 12 | |
78 | #define PEM_OBJ_PRIV_DH 13 | |
79 | #define PEM_OBJ_PUB_RSA 14 | |
80 | #define PEM_OBJ_PUB_DSA 15 | |
81 | #define PEM_OBJ_PUB_DH 16 | |
82 | #define PEM_OBJ_DHPARAMS 17 | |
83 | #define PEM_OBJ_DSAPARAMS 18 | |
84 | #define PEM_OBJ_PRIV_RSA_PUBLIC 19 | |
85 | ||
86 | #define PEM_ERROR 30 | |
87 | #define PEM_DEK_DES_CBC 40 | |
88 | #define PEM_DEK_IDEA_CBC 45 | |
89 | #define PEM_DEK_DES_EDE 50 | |
90 | #define PEM_DEK_DES_ECB 60 | |
91 | #define PEM_DEK_RSA 70 | |
92 | #define PEM_DEK_RSA_MD2 80 | |
93 | #define PEM_DEK_RSA_MD5 90 | |
94 | ||
95 | #define PEM_MD_MD2 NID_md2 | |
96 | #define PEM_MD_MD5 NID_md5 | |
97 | #define PEM_MD_SHA NID_sha | |
98 | #define PEM_MD_MD2_RSA NID_md2WithRSAEncryption | |
99 | #define PEM_MD_MD5_RSA NID_md5WithRSAEncryption | |
100 | #define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption | |
101 | ||
102 | #define PEM_STRING_X509_OLD "X509 CERTIFICATE" | |
103 | #define PEM_STRING_X509 "CERTIFICATE" | |
104 | #define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" | |
105 | #define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" | |
106 | #define PEM_STRING_X509_CRL "X509 CRL" | |
107 | #define PEM_STRING_EVP_PKEY "PRIVATE KEY" | |
108 | #define PEM_STRING_RSA "RSA PRIVATE KEY" | |
109 | #define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" | |
110 | #define PEM_STRING_DSA "DSA PRIVATE KEY" | |
111 | #define PEM_STRING_PKCS7 "PKCS7" | |
112 | #define PEM_STRING_DHPARAMS "DH PARAMETERS" | |
113 | #define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" | |
114 | #define PEM_STRING_DSAPARAMS "DSA PARAMETERS" | |
115 | ||
d02b48c6 RE |
116 | |
117 | typedef struct PEM_Encode_Seal_st | |
118 | { | |
119 | EVP_ENCODE_CTX encode; | |
120 | EVP_MD_CTX md; | |
121 | EVP_CIPHER_CTX cipher; | |
122 | } PEM_ENCODE_SEAL_CTX; | |
123 | ||
124 | /* enc_type is one off */ | |
125 | #define PEM_TYPE_ENCRYPTED 10 | |
126 | #define PEM_TYPE_MIC_ONLY 20 | |
127 | #define PEM_TYPE_MIC_CLEAR 30 | |
128 | #define PEM_TYPE_CLEAR 40 | |
129 | ||
130 | typedef struct pem_recip_st | |
131 | { | |
132 | char *name; | |
133 | X509_NAME *dn; | |
134 | ||
135 | int cipher; | |
136 | int key_enc; | |
137 | char iv[8]; | |
138 | } PEM_USER; | |
139 | ||
140 | typedef struct pem_ctx_st | |
141 | { | |
142 | int type; /* what type of object */ | |
143 | ||
144 | struct { | |
145 | int version; | |
146 | int mode; | |
147 | } proc_type; | |
148 | ||
149 | char *domain; | |
150 | ||
151 | struct { | |
152 | int cipher; | |
153 | unsigned char iv[8]; | |
154 | } DEK_info; | |
155 | ||
156 | PEM_USER *originator; | |
157 | ||
158 | int num_recipient; | |
159 | PEM_USER **recipient; | |
160 | ||
161 | #ifdef HEADER_STACK_H | |
162 | STACK *x509_chain; /* certificate chain */ | |
163 | #else | |
164 | char *x509_chain; /* certificate chain */ | |
165 | #endif | |
166 | EVP_MD *md; /* signature type */ | |
167 | ||
168 | int md_enc; /* is the md encrypted or not? */ | |
169 | int md_len; /* length of md_data */ | |
170 | char *md_data; /* message digest, could be pkey encrypted */ | |
171 | ||
172 | EVP_CIPHER *dec; /* date encryption cipher */ | |
173 | int key_len; /* key length */ | |
174 | unsigned char *key; /* key */ | |
175 | unsigned char iv[8]; /* the iv */ | |
176 | ||
177 | ||
178 | int data_enc; /* is the data encrypted */ | |
179 | int data_len; | |
180 | unsigned char *data; | |
181 | } PEM_CTX; | |
182 | ||
183 | #ifdef SSLEAY_MACROS | |
184 | ||
185 | #define PEM_write_SSL_SESSION(fp,x) \ | |
186 | PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ | |
187 | PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL) | |
188 | #define PEM_write_X509(fp,x) \ | |
189 | PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \ | |
190 | (char *)x, NULL,NULL,0,NULL) | |
191 | #define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \ | |
192 | (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \ | |
193 | NULL,NULL,0,NULL) | |
194 | #define PEM_write_X509_CRL(fp,x) \ | |
195 | PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \ | |
196 | fp,(char *)x, NULL,NULL,0,NULL) | |
197 | #define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb) \ | |
198 | PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\ | |
199 | (char *)x,enc,kstr,klen,cb) | |
200 | #define PEM_write_RSAPublicKey(fp,x) \ | |
201 | PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\ | |
202 | PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL) | |
203 | #define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb) \ | |
204 | PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\ | |
205 | (char *)x,enc,kstr,klen,cb) | |
206 | #define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb) \ | |
207 | PEM_ASN1_write((int (*)())i2d_PrivateKey,\ | |
208 | (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ | |
209 | bp,(char *)x,enc,kstr,klen,cb) | |
210 | #define PEM_write_PKCS7(fp,x) \ | |
211 | PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \ | |
212 | (char *)x, NULL,NULL,0,NULL) | |
213 | #define PEM_write_DHparams(fp,x) \ | |
214 | PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\ | |
215 | (char *)x,NULL,NULL,0,NULL) | |
216 | ||
92c046ca DSH |
217 | #define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \ |
218 | PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ | |
219 | PEM_STRING_X509,fp, \ | |
220 | (char *)x, NULL,NULL,0,NULL) | |
221 | ||
d02b48c6 RE |
222 | #define PEM_read_SSL_SESSION(fp,x,cb) (SSL_SESSION *)PEM_ASN1_read( \ |
223 | (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb) | |
224 | #define PEM_read_X509(fp,x,cb) (X509 *)PEM_ASN1_read( \ | |
225 | (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb) | |
226 | #define PEM_read_X509_REQ(fp,x,cb) (X509_REQ *)PEM_ASN1_read( \ | |
227 | (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb) | |
228 | #define PEM_read_X509_CRL(fp,x,cb) (X509_CRL *)PEM_ASN1_read( \ | |
229 | (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb) | |
230 | #define PEM_read_RSAPrivateKey(fp,x,cb) (RSA *)PEM_ASN1_read( \ | |
231 | (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb) | |
232 | #define PEM_read_RSAPublicKey(fp,x,cb) (RSA *)PEM_ASN1_read( \ | |
233 | (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb) | |
234 | #define PEM_read_DSAPrivateKey(fp,x,cb) (DSA *)PEM_ASN1_read( \ | |
235 | (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb) | |
236 | #define PEM_read_PrivateKey(fp,x,cb) (EVP_PKEY *)PEM_ASN1_read( \ | |
237 | (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb) | |
238 | #define PEM_read_PKCS7(fp,x,cb) (PKCS7 *)PEM_ASN1_read( \ | |
239 | (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb) | |
240 | #define PEM_read_DHparams(fp,x,cb) (DH *)PEM_ASN1_read( \ | |
241 | (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb) | |
242 | ||
92c046ca DSH |
243 | #define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb) \ |
244 | (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \ | |
245 | (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\ | |
246 | (char **)x,cb) | |
247 | ||
d02b48c6 RE |
248 | #define PEM_write_bio_SSL_SESSION(bp,x) \ |
249 | PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \ | |
250 | PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL) | |
251 | #define PEM_write_bio_X509(bp,x) \ | |
252 | PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \ | |
253 | (char *)x, NULL,NULL,0,NULL) | |
254 | #define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \ | |
255 | (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \ | |
256 | NULL,NULL,0,NULL) | |
257 | #define PEM_write_bio_X509_CRL(bp,x) \ | |
258 | PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\ | |
259 | bp,(char *)x, NULL,NULL,0,NULL) | |
260 | #define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb) \ | |
261 | PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\ | |
262 | bp,(char *)x,enc,kstr,klen,cb) | |
263 | #define PEM_write_bio_RSAPublicKey(bp,x) \ | |
264 | PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \ | |
265 | PEM_STRING_RSA_PUBLIC,\ | |
266 | bp,(char *)x,NULL,NULL,0,NULL) | |
267 | #define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb) \ | |
268 | PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\ | |
269 | bp,(char *)x,enc,kstr,klen,cb) | |
270 | #define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb) \ | |
271 | PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\ | |
272 | (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ | |
273 | bp,(char *)x,enc,kstr,klen,cb) | |
274 | #define PEM_write_bio_PKCS7(bp,x) \ | |
275 | PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \ | |
276 | (char *)x, NULL,NULL,0,NULL) | |
277 | #define PEM_write_bio_DHparams(bp,x) \ | |
278 | PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\ | |
279 | bp,(char *)x,NULL,NULL,0,NULL) | |
280 | #define PEM_write_bio_DSAparams(bp,x) \ | |
281 | PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \ | |
282 | PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL) | |
283 | ||
92c046ca DSH |
284 | #define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \ |
285 | PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ | |
286 | PEM_STRING_X509,bp, \ | |
287 | (char *)x, NULL,NULL,0,NULL) | |
288 | ||
d02b48c6 RE |
289 | #define PEM_read_bio_SSL_SESSION(bp,x,cb) (SSL_SESSION *)PEM_ASN1_read_bio( \ |
290 | (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,(char **)x,cb) | |
291 | #define PEM_read_bio_X509(bp,x,cb) (X509 *)PEM_ASN1_read_bio( \ | |
292 | (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb) | |
293 | #define PEM_read_bio_X509_REQ(bp,x,cb) (X509_REQ *)PEM_ASN1_read_bio( \ | |
294 | (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb) | |
295 | #define PEM_read_bio_X509_CRL(bp,x,cb) (X509_CRL *)PEM_ASN1_read_bio( \ | |
296 | (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb) | |
297 | #define PEM_read_bio_RSAPrivateKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \ | |
298 | (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb) | |
299 | #define PEM_read_bio_RSAPublicKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \ | |
300 | (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb) | |
301 | #define PEM_read_bio_DSAPrivateKey(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \ | |
302 | (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb) | |
303 | #define PEM_read_bio_PrivateKey(bp,x,cb) (EVP_PKEY *)PEM_ASN1_read_bio( \ | |
304 | (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb) | |
305 | ||
306 | #define PEM_read_bio_PKCS7(bp,x,cb) (PKCS7 *)PEM_ASN1_read_bio( \ | |
307 | (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb) | |
308 | #define PEM_read_bio_DHparams(bp,x,cb) (DH *)PEM_ASN1_read_bio( \ | |
309 | (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb) | |
310 | #define PEM_read_bio_DSAparams(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \ | |
311 | (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb) | |
312 | ||
92c046ca DSH |
313 | #define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb) \ |
314 | (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \ | |
315 | (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\ | |
316 | (char **)x,cb) | |
317 | ||
d02b48c6 RE |
318 | #endif |
319 | ||
d02b48c6 RE |
320 | int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); |
321 | int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, | |
322 | int (*callback)()); | |
323 | ||
324 | #ifdef HEADER_BIO_H | |
325 | int PEM_read_bio(BIO *bp, char **name, char **header, | |
326 | unsigned char **data,long *len); | |
8de421b6 | 327 | int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data, |
d02b48c6 | 328 | long len); |
8de421b6 | 329 | char * PEM_ASN1_read_bio(char *(*d2i)(),const char *name,BIO *bp,char **x, |
d02b48c6 | 330 | int (*cb)()); |
8de421b6 BL |
331 | int PEM_ASN1_write_bio(int (*i2d)(),const char *name,BIO *bp,char *x, |
332 | const EVP_CIPHER *enc,unsigned char *kstr,int klen, | |
333 | int (*callback)()); | |
d02b48c6 RE |
334 | STACK * PEM_X509_INFO_read_bio(BIO *bp, STACK *sk, int (*cb)()); |
335 | int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, | |
336 | unsigned char *kstr, int klen, int (*cb)()); | |
337 | #endif | |
338 | ||
339 | #ifndef WIN16 | |
340 | int PEM_read(FILE *fp, char **name, char **header, | |
341 | unsigned char **data,long *len); | |
342 | int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); | |
8de421b6 | 343 | char * PEM_ASN1_read(char *(*d2i)(),const char *name,FILE *fp,char **x, |
d02b48c6 | 344 | int (*cb)()); |
8de421b6 BL |
345 | int PEM_ASN1_write(int (*i2d)(),const char *name,FILE *fp,char *x, |
346 | const EVP_CIPHER *enc,unsigned char *kstr,int klen, | |
347 | int (*callback)()); | |
d02b48c6 RE |
348 | STACK * PEM_X509_INFO_read(FILE *fp, STACK *sk, int (*cb)()); |
349 | #endif | |
350 | ||
351 | int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, | |
352 | EVP_MD *md_type, unsigned char **ek, int *ekl, | |
353 | unsigned char *iv, EVP_PKEY **pubk, int npubk); | |
354 | void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, | |
355 | unsigned char *in, int inl); | |
356 | int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl, | |
357 | unsigned char *out, int *outl, EVP_PKEY *priv); | |
358 | ||
359 | void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); | |
360 | void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt); | |
361 | int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, | |
362 | unsigned int *siglen, EVP_PKEY *pkey); | |
363 | ||
c74b3a60 DSH |
364 | void ERR_load_PEM_strings(void); |
365 | ||
d02b48c6 | 366 | void PEM_proc_type(char *buf, int type); |
8de421b6 | 367 | void PEM_dek_info(char *buf, const char *type, int len, char *str); |
d02b48c6 RE |
368 | |
369 | #ifndef SSLEAY_MACROS | |
370 | ||
371 | #ifndef WIN16 | |
372 | X509 *PEM_read_X509(FILE *fp,X509 **x,int (*cb)()); | |
373 | X509_REQ *PEM_read_X509_REQ(FILE *fp,X509_REQ **x,int (*cb)()); | |
374 | X509_CRL *PEM_read_X509_CRL(FILE *fp,X509_CRL **x,int (*cb)()); | |
f5d7a031 | 375 | #ifndef NO_RSA |
d02b48c6 RE |
376 | RSA *PEM_read_RSAPrivateKey(FILE *fp,RSA **x,int (*cb)()); |
377 | RSA *PEM_read_RSAPublicKey(FILE *fp,RSA **x,int (*cb)()); | |
f5d7a031 UM |
378 | #endif |
379 | #ifndef NO_DSA | |
d02b48c6 | 380 | DSA *PEM_read_DSAPrivateKey(FILE *fp,DSA **x,int (*cb)()); |
f5d7a031 UM |
381 | DSA *PEM_read_DSAparams(FILE *fp,DSA **x,int (*cb)()); |
382 | #endif | |
383 | #ifndef NO_DH | |
384 | DH *PEM_read_DHparams(FILE *fp,DH **x,int (*cb)()); | |
385 | #endif | |
d02b48c6 RE |
386 | EVP_PKEY *PEM_read_PrivateKey(FILE *fp,EVP_PKEY **x,int (*cb)()); |
387 | PKCS7 *PEM_read_PKCS7(FILE *fp,PKCS7 **x,int (*cb)()); | |
92c046ca | 388 | NETSCAPE_CERT_SEQUENCE *PEM_read_NETSCAPE_CERT_SEQUENCE(FILE *fp,NETSCAPE_CERT_SEQUENCE **x,int (*cb)()); |
d02b48c6 RE |
389 | int PEM_write_X509(FILE *fp,X509 *x); |
390 | int PEM_write_X509_REQ(FILE *fp,X509_REQ *x); | |
391 | int PEM_write_X509_CRL(FILE *fp,X509_CRL *x); | |
f5d7a031 | 392 | #ifndef NO_RSA |
d02b48c6 RE |
393 | int PEM_write_RSAPrivateKey(FILE *fp,RSA *x,EVP_CIPHER *enc,unsigned char *kstr, |
394 | int klen,int (*cb)()); | |
395 | int PEM_write_RSAPublicKey(FILE *fp,RSA *x); | |
f5d7a031 UM |
396 | #endif |
397 | #ifndef NO_DSA | |
8de421b6 BL |
398 | int PEM_write_DSAPrivateKey(FILE *fp,DSA *x,const EVP_CIPHER *enc, |
399 | unsigned char *kstr, | |
d02b48c6 | 400 | int klen,int (*cb)()); |
f5d7a031 | 401 | #endif |
d02b48c6 RE |
402 | int PEM_write_PrivateKey(FILE *fp,EVP_PKEY *x,EVP_CIPHER *enc, |
403 | unsigned char *kstr,int klen,int (*cb)()); | |
404 | int PEM_write_PKCS7(FILE *fp,PKCS7 *x); | |
f5d7a031 | 405 | #ifndef NO_DH |
d02b48c6 | 406 | int PEM_write_DHparams(FILE *fp,DH *x); |
f5d7a031 UM |
407 | #endif |
408 | #ifndef NO_DSA | |
d02b48c6 | 409 | int PEM_write_DSAparams(FILE *fp,DSA *x); |
f5d7a031 | 410 | #endif |
92c046ca | 411 | int PEM_write_NETSCAPE_CERT_SEQUENCE(FILE *fp,NETSCAPE_CERT_SEQUENCE *x); |
d02b48c6 RE |
412 | #endif |
413 | ||
414 | #ifdef HEADER_BIO_H | |
415 | X509 *PEM_read_bio_X509(BIO *bp,X509 **x,int (*cb)()); | |
416 | X509_REQ *PEM_read_bio_X509_REQ(BIO *bp,X509_REQ **x,int (*cb)()); | |
417 | X509_CRL *PEM_read_bio_X509_CRL(BIO *bp,X509_CRL **x,int (*cb)()); | |
f5d7a031 | 418 | #ifndef NO_RSA |
d02b48c6 RE |
419 | RSA *PEM_read_bio_RSAPrivateKey(BIO *bp,RSA **x,int (*cb)()); |
420 | RSA *PEM_read_bio_RSAPublicKey(BIO *bp,RSA **x,int (*cb)()); | |
f5d7a031 UM |
421 | #endif |
422 | #ifndef NO_DSA | |
d02b48c6 | 423 | DSA *PEM_read_bio_DSAPrivateKey(BIO *bp,DSA **x,int (*cb)()); |
f5d7a031 | 424 | #endif |
d02b48c6 RE |
425 | EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp,EVP_PKEY **x,int (*cb)()); |
426 | PKCS7 *PEM_read_bio_PKCS7(BIO *bp,PKCS7 **x,int (*cb)()); | |
f5d7a031 | 427 | #ifndef NO_DH |
d02b48c6 | 428 | DH *PEM_read_bio_DHparams(BIO *bp,DH **x,int (*cb)()); |
f5d7a031 | 429 | #endif |
92c046ca | 430 | NETSCAPE_CERT_SEQUENCE *PEM_read_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp,NETSCAPE_CERT_SEQUENCE **x,int (*cb)()); |
f5d7a031 | 431 | #ifndef NO_DSA |
d02b48c6 | 432 | DSA *PEM_read_bio_DSAparams(BIO *bp,DSA **x,int (*cb)()); |
f5d7a031 | 433 | #endif |
d02b48c6 RE |
434 | int PEM_write_bio_X509(BIO *bp,X509 *x); |
435 | int PEM_write_bio_X509_REQ(BIO *bp,X509_REQ *x); | |
436 | int PEM_write_bio_X509_CRL(BIO *bp,X509_CRL *x); | |
f5d7a031 | 437 | #ifndef NO_RSA |
8de421b6 | 438 | int PEM_write_bio_RSAPrivateKey(BIO *fp,RSA *x,const EVP_CIPHER *enc, |
d02b48c6 RE |
439 | unsigned char *kstr,int klen,int (*cb)()); |
440 | int PEM_write_bio_RSAPublicKey(BIO *fp,RSA *x); | |
f5d7a031 UM |
441 | #endif |
442 | #ifndef NO_DSA | |
8de421b6 | 443 | int PEM_write_bio_DSAPrivateKey(BIO *fp,DSA *x,const EVP_CIPHER *enc, |
d02b48c6 | 444 | unsigned char *kstr,int klen,int (*cb)()); |
f5d7a031 | 445 | #endif |
d02b48c6 RE |
446 | int PEM_write_bio_PrivateKey(BIO *fp,EVP_PKEY *x,EVP_CIPHER *enc, |
447 | unsigned char *kstr,int klen,int (*cb)()); | |
448 | int PEM_write_bio_PKCS7(BIO *bp,PKCS7 *x); | |
f5d7a031 | 449 | #ifndef NO_DH |
d02b48c6 | 450 | int PEM_write_bio_DHparams(BIO *bp,DH *x); |
f5d7a031 UM |
451 | #endif |
452 | #ifndef NO_DSA | |
d02b48c6 | 453 | int PEM_write_bio_DSAparams(BIO *bp,DSA *x); |
f5d7a031 | 454 | #endif |
92c046ca | 455 | int PEM_write_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp,NETSCAPE_CERT_SEQUENCE *x); |
d02b48c6 RE |
456 | #endif |
457 | ||
458 | #endif /* SSLEAY_MACROS */ | |
459 | ||
460 | ||
d02b48c6 | 461 | /* BEGIN ERROR CODES */ |
6d311938 DSH |
462 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
463 | * made after this point may be overwritten when the script is next run. | |
464 | */ | |
465 | ||
d02b48c6 RE |
466 | /* Error codes for the PEM functions. */ |
467 | ||
468 | /* Function codes. */ | |
469 | #define PEM_F_DEF_CALLBACK 100 | |
470 | #define PEM_F_LOAD_IV 101 | |
471 | #define PEM_F_PEM_ASN1_READ 102 | |
472 | #define PEM_F_PEM_ASN1_READ_BIO 103 | |
473 | #define PEM_F_PEM_ASN1_WRITE 104 | |
474 | #define PEM_F_PEM_ASN1_WRITE_BIO 105 | |
475 | #define PEM_F_PEM_DO_HEADER 106 | |
476 | #define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 | |
477 | #define PEM_F_PEM_READ 108 | |
478 | #define PEM_F_PEM_READ_BIO 109 | |
479 | #define PEM_F_PEM_SEALFINAL 110 | |
480 | #define PEM_F_PEM_SEALINIT 111 | |
481 | #define PEM_F_PEM_SIGNFINAL 112 | |
482 | #define PEM_F_PEM_WRITE 113 | |
483 | #define PEM_F_PEM_WRITE_BIO 114 | |
484 | #define PEM_F_PEM_X509_INFO_READ 115 | |
485 | #define PEM_F_PEM_X509_INFO_READ_BIO 116 | |
486 | #define PEM_F_PEM_X509_INFO_WRITE_BIO 117 | |
487 | ||
488 | /* Reason codes. */ | |
489 | #define PEM_R_BAD_BASE64_DECODE 100 | |
490 | #define PEM_R_BAD_DECRYPT 101 | |
491 | #define PEM_R_BAD_END_LINE 102 | |
492 | #define PEM_R_BAD_IV_CHARS 103 | |
493 | #define PEM_R_BAD_PASSWORD_READ 104 | |
494 | #define PEM_R_NOT_DEK_INFO 105 | |
495 | #define PEM_R_NOT_ENCRYPTED 106 | |
496 | #define PEM_R_NOT_PROC_TYPE 107 | |
497 | #define PEM_R_NO_START_LINE 108 | |
498 | #define PEM_R_PROBLEMS_GETTING_PASSWORD 109 | |
499 | #define PEM_R_PUBLIC_KEY_NO_RSA 110 | |
500 | #define PEM_R_READ_KEY 111 | |
501 | #define PEM_R_SHORT_HEADER 112 | |
502 | #define PEM_R_UNSUPPORTED_CIPHER 113 | |
503 | #define PEM_R_UNSUPPORTED_ENCRYPTION 114 | |
6d311938 | 504 | |
d02b48c6 RE |
505 | #ifdef __cplusplus |
506 | } | |
507 | #endif | |
508 | #endif | |
509 |