williamr@2
|
1 |
/* crypto/pem/pem.h */
|
williamr@2
|
2 |
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
*
|
williamr@2
|
5 |
* This package is an SSL implementation written
|
williamr@2
|
6 |
* by Eric Young (eay@cryptsoft.com).
|
williamr@2
|
7 |
* The implementation was written so as to conform with Netscapes SSL.
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* This library is free for commercial and non-commercial use as long as
|
williamr@2
|
10 |
* the following conditions are aheared to. The following conditions
|
williamr@2
|
11 |
* apply to all code found in this distribution, be it the RC4, RSA,
|
williamr@2
|
12 |
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
williamr@2
|
13 |
* included with this distribution is covered by the same copyright terms
|
williamr@2
|
14 |
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
williamr@2
|
15 |
*
|
williamr@2
|
16 |
* Copyright remains Eric Young's, and as such any Copyright notices in
|
williamr@2
|
17 |
* the code are not to be removed.
|
williamr@2
|
18 |
* If this package is used in a product, Eric Young should be given attribution
|
williamr@2
|
19 |
* as the author of the parts of the library used.
|
williamr@2
|
20 |
* This can be in the form of a textual message at program startup or
|
williamr@2
|
21 |
* in documentation (online or textual) provided with the package.
|
williamr@2
|
22 |
*
|
williamr@2
|
23 |
* Redistribution and use in source and binary forms, with or without
|
williamr@2
|
24 |
* modification, are permitted provided that the following conditions
|
williamr@2
|
25 |
* are met:
|
williamr@2
|
26 |
* 1. Redistributions of source code must retain the copyright
|
williamr@2
|
27 |
* notice, this list of conditions and the following disclaimer.
|
williamr@2
|
28 |
* 2. Redistributions in binary form must reproduce the above copyright
|
williamr@2
|
29 |
* notice, this list of conditions and the following disclaimer in the
|
williamr@2
|
30 |
* documentation and/or other materials provided with the distribution.
|
williamr@2
|
31 |
* 3. All advertising materials mentioning features or use of this software
|
williamr@2
|
32 |
* must display the following acknowledgement:
|
williamr@2
|
33 |
* "This product includes cryptographic software written by
|
williamr@2
|
34 |
* Eric Young (eay@cryptsoft.com)"
|
williamr@2
|
35 |
* The word 'cryptographic' can be left out if the rouines from the library
|
williamr@2
|
36 |
* being used are not cryptographic related :-).
|
williamr@2
|
37 |
* 4. If you include any Windows specific code (or a derivative thereof) from
|
williamr@2
|
38 |
* the apps directory (application code) you must include an acknowledgement:
|
williamr@2
|
39 |
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
williamr@2
|
40 |
*
|
williamr@2
|
41 |
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
williamr@2
|
42 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
williamr@2
|
43 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
williamr@2
|
44 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
williamr@2
|
45 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
williamr@2
|
46 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
williamr@2
|
47 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
williamr@2
|
48 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
williamr@2
|
49 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
williamr@2
|
50 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
williamr@2
|
51 |
* SUCH DAMAGE.
|
williamr@2
|
52 |
*
|
williamr@2
|
53 |
* The licence and distribution terms for any publically available version or
|
williamr@2
|
54 |
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
williamr@2
|
55 |
* copied and put under another distribution licence
|
williamr@2
|
56 |
* [including the GNU Public Licence.]
|
williamr@2
|
57 |
*/
|
williamr@2
|
58 |
/*
|
williamr@2
|
59 |
© Portions copyright (c) 2006 Nokia Corporation. All rights reserved.
|
williamr@2
|
60 |
*/
|
williamr@2
|
61 |
|
williamr@2
|
62 |
#ifndef HEADER_PEM_H
|
williamr@2
|
63 |
#define HEADER_PEM_H
|
williamr@2
|
64 |
|
williamr@2
|
65 |
#if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
|
williamr@2
|
66 |
#define SYMBIAN
|
williamr@2
|
67 |
#endif
|
williamr@2
|
68 |
|
williamr@2
|
69 |
#ifdef SYMBIAN
|
williamr@2
|
70 |
#include <e32def.h>
|
williamr@2
|
71 |
#endif
|
williamr@2
|
72 |
#include <openssl/e_os2.h>
|
williamr@2
|
73 |
#ifndef OPENSSL_NO_BIO
|
williamr@2
|
74 |
#include <openssl/bio.h>
|
williamr@2
|
75 |
#endif
|
williamr@2
|
76 |
#ifndef OPENSSL_NO_STACK
|
williamr@2
|
77 |
#include <openssl/stack.h>
|
williamr@2
|
78 |
#endif
|
williamr@2
|
79 |
#include <openssl/evp.h>
|
williamr@2
|
80 |
#include <openssl/x509.h>
|
williamr@2
|
81 |
#include <openssl/pem2.h>
|
williamr@2
|
82 |
|
williamr@2
|
83 |
#ifdef __cplusplus
|
williamr@2
|
84 |
extern "C" {
|
williamr@2
|
85 |
#endif
|
williamr@2
|
86 |
|
williamr@2
|
87 |
#define PEM_BUFSIZE 1024
|
williamr@2
|
88 |
|
williamr@2
|
89 |
#define PEM_OBJ_UNDEF 0
|
williamr@2
|
90 |
#define PEM_OBJ_X509 1
|
williamr@2
|
91 |
#define PEM_OBJ_X509_REQ 2
|
williamr@2
|
92 |
#define PEM_OBJ_CRL 3
|
williamr@2
|
93 |
#define PEM_OBJ_SSL_SESSION 4
|
williamr@2
|
94 |
#define PEM_OBJ_PRIV_KEY 10
|
williamr@2
|
95 |
#define PEM_OBJ_PRIV_RSA 11
|
williamr@2
|
96 |
#define PEM_OBJ_PRIV_DSA 12
|
williamr@2
|
97 |
#define PEM_OBJ_PRIV_DH 13
|
williamr@2
|
98 |
#define PEM_OBJ_PUB_RSA 14
|
williamr@2
|
99 |
#define PEM_OBJ_PUB_DSA 15
|
williamr@2
|
100 |
#define PEM_OBJ_PUB_DH 16
|
williamr@2
|
101 |
#define PEM_OBJ_DHPARAMS 17
|
williamr@2
|
102 |
#define PEM_OBJ_DSAPARAMS 18
|
williamr@2
|
103 |
#define PEM_OBJ_PRIV_RSA_PUBLIC 19
|
williamr@2
|
104 |
#define PEM_OBJ_PRIV_ECDSA 20
|
williamr@2
|
105 |
#define PEM_OBJ_PUB_ECDSA 21
|
williamr@2
|
106 |
#define PEM_OBJ_ECPARAMETERS 22
|
williamr@2
|
107 |
|
williamr@2
|
108 |
#define PEM_ERROR 30
|
williamr@2
|
109 |
#define PEM_DEK_DES_CBC 40
|
williamr@2
|
110 |
#define PEM_DEK_IDEA_CBC 45
|
williamr@2
|
111 |
#define PEM_DEK_DES_EDE 50
|
williamr@2
|
112 |
#define PEM_DEK_DES_ECB 60
|
williamr@2
|
113 |
#define PEM_DEK_RSA 70
|
williamr@2
|
114 |
#define PEM_DEK_RSA_MD2 80
|
williamr@2
|
115 |
#define PEM_DEK_RSA_MD5 90
|
williamr@2
|
116 |
|
williamr@2
|
117 |
#define PEM_MD_MD2 NID_md2
|
williamr@2
|
118 |
#define PEM_MD_MD5 NID_md5
|
williamr@2
|
119 |
#define PEM_MD_SHA NID_sha
|
williamr@2
|
120 |
#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption
|
williamr@2
|
121 |
#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption
|
williamr@2
|
122 |
#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption
|
williamr@2
|
123 |
|
williamr@2
|
124 |
#define PEM_STRING_X509_OLD "X509 CERTIFICATE"
|
williamr@2
|
125 |
#define PEM_STRING_X509 "CERTIFICATE"
|
williamr@2
|
126 |
#define PEM_STRING_X509_PAIR "CERTIFICATE PAIR"
|
williamr@2
|
127 |
#define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
|
williamr@2
|
128 |
#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
|
williamr@2
|
129 |
#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
|
williamr@2
|
130 |
#define PEM_STRING_X509_CRL "X509 CRL"
|
williamr@2
|
131 |
#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"
|
williamr@2
|
132 |
#define PEM_STRING_PUBLIC "PUBLIC KEY"
|
williamr@2
|
133 |
#define PEM_STRING_RSA "RSA PRIVATE KEY"
|
williamr@2
|
134 |
#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
|
williamr@2
|
135 |
#define PEM_STRING_DSA "DSA PRIVATE KEY"
|
williamr@2
|
136 |
#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
|
williamr@2
|
137 |
#define PEM_STRING_PKCS7 "PKCS7"
|
williamr@2
|
138 |
#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
|
williamr@2
|
139 |
#define PEM_STRING_PKCS8INF "PRIVATE KEY"
|
williamr@2
|
140 |
#define PEM_STRING_DHPARAMS "DH PARAMETERS"
|
williamr@2
|
141 |
#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
|
williamr@2
|
142 |
#define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
|
williamr@2
|
143 |
#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
|
williamr@2
|
144 |
#define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
|
williamr@2
|
145 |
#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
|
williamr@2
|
146 |
|
williamr@2
|
147 |
/* Note that this structure is initialised by PEM_SealInit and cleaned up
|
williamr@2
|
148 |
by PEM_SealFinal (at least for now) */
|
williamr@2
|
149 |
typedef struct PEM_Encode_Seal_st
|
williamr@2
|
150 |
{
|
williamr@2
|
151 |
EVP_ENCODE_CTX encode;
|
williamr@2
|
152 |
EVP_MD_CTX md;
|
williamr@2
|
153 |
EVP_CIPHER_CTX cipher;
|
williamr@2
|
154 |
} PEM_ENCODE_SEAL_CTX;
|
williamr@2
|
155 |
|
williamr@2
|
156 |
/* enc_type is one off */
|
williamr@2
|
157 |
#define PEM_TYPE_ENCRYPTED 10
|
williamr@2
|
158 |
#define PEM_TYPE_MIC_ONLY 20
|
williamr@2
|
159 |
#define PEM_TYPE_MIC_CLEAR 30
|
williamr@2
|
160 |
#define PEM_TYPE_CLEAR 40
|
williamr@2
|
161 |
|
williamr@2
|
162 |
typedef struct pem_recip_st
|
williamr@2
|
163 |
{
|
williamr@2
|
164 |
char *name;
|
williamr@2
|
165 |
X509_NAME *dn;
|
williamr@2
|
166 |
|
williamr@2
|
167 |
int cipher;
|
williamr@2
|
168 |
int key_enc;
|
williamr@2
|
169 |
/* char iv[8]; unused and wrong size */
|
williamr@2
|
170 |
} PEM_USER;
|
williamr@2
|
171 |
|
williamr@2
|
172 |
typedef struct pem_ctx_st
|
williamr@2
|
173 |
{
|
williamr@2
|
174 |
int type; /* what type of object */
|
williamr@2
|
175 |
|
williamr@2
|
176 |
struct {
|
williamr@2
|
177 |
int version;
|
williamr@2
|
178 |
int mode;
|
williamr@2
|
179 |
} proc_type;
|
williamr@2
|
180 |
|
williamr@2
|
181 |
char *domain;
|
williamr@2
|
182 |
|
williamr@2
|
183 |
struct {
|
williamr@2
|
184 |
int cipher;
|
williamr@2
|
185 |
/* unused, and wrong size
|
williamr@2
|
186 |
unsigned char iv[8]; */
|
williamr@2
|
187 |
} DEK_info;
|
williamr@2
|
188 |
|
williamr@2
|
189 |
PEM_USER *originator;
|
williamr@2
|
190 |
|
williamr@2
|
191 |
int num_recipient;
|
williamr@2
|
192 |
PEM_USER **recipient;
|
williamr@2
|
193 |
|
williamr@2
|
194 |
#ifndef OPENSSL_NO_STACK
|
williamr@2
|
195 |
STACK *x509_chain; /* certificate chain */
|
williamr@2
|
196 |
#else
|
williamr@2
|
197 |
char *x509_chain; /* certificate chain */
|
williamr@2
|
198 |
#endif
|
williamr@2
|
199 |
EVP_MD *md; /* signature type */
|
williamr@2
|
200 |
|
williamr@2
|
201 |
int md_enc; /* is the md encrypted or not? */
|
williamr@2
|
202 |
int md_len; /* length of md_data */
|
williamr@2
|
203 |
char *md_data; /* message digest, could be pkey encrypted */
|
williamr@2
|
204 |
|
williamr@2
|
205 |
EVP_CIPHER *dec; /* date encryption cipher */
|
williamr@2
|
206 |
int key_len; /* key length */
|
williamr@2
|
207 |
unsigned char *key; /* key */
|
williamr@2
|
208 |
/* unused, and wrong size
|
williamr@2
|
209 |
unsigned char iv[8]; */
|
williamr@2
|
210 |
|
williamr@2
|
211 |
|
williamr@2
|
212 |
int data_enc; /* is the data encrypted */
|
williamr@2
|
213 |
int data_len;
|
williamr@2
|
214 |
unsigned char *data;
|
williamr@2
|
215 |
} PEM_CTX;
|
williamr@2
|
216 |
|
williamr@2
|
217 |
/* These macros make the PEM_read/PEM_write functions easier to maintain and
|
williamr@2
|
218 |
* write. Now they are all implemented with either:
|
williamr@2
|
219 |
* IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...)
|
williamr@2
|
220 |
*/
|
williamr@2
|
221 |
|
williamr@2
|
222 |
#ifdef OPENSSL_NO_FP_API
|
williamr@2
|
223 |
|
williamr@2
|
224 |
#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/
|
williamr@2
|
225 |
#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/
|
williamr@2
|
226 |
#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/
|
williamr@2
|
227 |
|
williamr@2
|
228 |
#else
|
williamr@2
|
229 |
|
williamr@2
|
230 |
#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
|
williamr@2
|
231 |
EXPORT_C type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
|
williamr@2
|
232 |
{ \
|
williamr@2
|
233 |
return (type*)PEM_ASN1_read(CHECKED_D2I_OF(type, d2i_##asn1), \
|
williamr@2
|
234 |
str, fp, \
|
williamr@2
|
235 |
CHECKED_PPTR_OF(type, x), \
|
williamr@2
|
236 |
cb, u); \
|
williamr@2
|
237 |
}
|
williamr@2
|
238 |
|
williamr@2
|
239 |
#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
|
williamr@2
|
240 |
EXPORT_C int PEM_write_##name(FILE *fp, type *x) \
|
williamr@2
|
241 |
{ \
|
williamr@2
|
242 |
return PEM_ASN1_write(CHECKED_I2D_OF(type, i2d_##asn1), \
|
williamr@2
|
243 |
str, fp, \
|
williamr@2
|
244 |
CHECKED_PTR_OF(type, x), \
|
williamr@2
|
245 |
NULL, NULL, 0, NULL, NULL); \
|
williamr@2
|
246 |
}
|
williamr@2
|
247 |
|
williamr@2
|
248 |
#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
|
williamr@2
|
249 |
EXPORT_C int PEM_write_##name(FILE *fp, const type *x) \
|
williamr@2
|
250 |
{ \
|
williamr@2
|
251 |
return PEM_ASN1_write(CHECKED_I2D_OF(const type, i2d_##asn1), \
|
williamr@2
|
252 |
str, fp, \
|
williamr@2
|
253 |
CHECKED_PTR_OF(const type, x), \
|
williamr@2
|
254 |
NULL, NULL, 0, NULL, NULL); \
|
williamr@2
|
255 |
}
|
williamr@2
|
256 |
|
williamr@2
|
257 |
#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
|
williamr@2
|
258 |
EXPORT_C int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
|
williamr@2
|
259 |
unsigned char *kstr, int klen, pem_password_cb *cb, \
|
williamr@2
|
260 |
void *u) \
|
williamr@2
|
261 |
{ \
|
williamr@2
|
262 |
return PEM_ASN1_write(CHECKED_I2D_OF(type, i2d_##asn1), \
|
williamr@2
|
263 |
str, fp, \
|
williamr@2
|
264 |
CHECKED_PTR_OF(type, x), \
|
williamr@2
|
265 |
enc, kstr, klen, cb, u); \
|
williamr@2
|
266 |
}
|
williamr@2
|
267 |
|
williamr@2
|
268 |
#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
|
williamr@2
|
269 |
EXPORT_C int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
|
williamr@2
|
270 |
unsigned char *kstr, int klen, pem_password_cb *cb, \
|
williamr@2
|
271 |
void *u) \
|
williamr@2
|
272 |
{ \
|
williamr@2
|
273 |
return PEM_ASN1_write(CHECKED_I2D_OF(const type, i2d_##asn1), \
|
williamr@2
|
274 |
str, fp, \
|
williamr@2
|
275 |
CHECKED_PTR_OF(const type, x), \
|
williamr@2
|
276 |
enc, kstr, klen, cb, u); \
|
williamr@2
|
277 |
}
|
williamr@2
|
278 |
|
williamr@2
|
279 |
#endif
|
williamr@2
|
280 |
|
williamr@2
|
281 |
#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
|
williamr@2
|
282 |
EXPORT_C type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
|
williamr@2
|
283 |
{ \
|
williamr@2
|
284 |
return (type*)PEM_ASN1_read_bio(CHECKED_D2I_OF(type, d2i_##asn1), \
|
williamr@2
|
285 |
str, bp, \
|
williamr@2
|
286 |
CHECKED_PPTR_OF(type, x), \
|
williamr@2
|
287 |
cb, u); \
|
williamr@2
|
288 |
}
|
williamr@2
|
289 |
|
williamr@2
|
290 |
#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
|
williamr@2
|
291 |
EXPORT_C int PEM_write_bio_##name(BIO *bp, type *x) \
|
williamr@2
|
292 |
{ \
|
williamr@2
|
293 |
return PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d_##asn1), \
|
williamr@2
|
294 |
str, bp, \
|
williamr@2
|
295 |
CHECKED_PTR_OF(type, x), \
|
williamr@2
|
296 |
NULL, NULL, 0, NULL, NULL); \
|
williamr@2
|
297 |
}
|
williamr@2
|
298 |
|
williamr@2
|
299 |
#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
|
williamr@2
|
300 |
EXPORT_C int PEM_write_bio_##name(BIO *bp, const type *x) \
|
williamr@2
|
301 |
{ \
|
williamr@2
|
302 |
return PEM_ASN1_write_bio(CHECKED_I2D_OF(const type, i2d_##asn1), \
|
williamr@2
|
303 |
str, bp, \
|
williamr@2
|
304 |
CHECKED_PTR_OF(const type, x), \
|
williamr@2
|
305 |
NULL, NULL, 0, NULL, NULL); \
|
williamr@2
|
306 |
}
|
williamr@2
|
307 |
|
williamr@2
|
308 |
#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
|
williamr@2
|
309 |
EXPORT_C int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
|
williamr@2
|
310 |
unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
|
williamr@2
|
311 |
{ \
|
williamr@2
|
312 |
return PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d_##asn1), \
|
williamr@2
|
313 |
str, bp, \
|
williamr@2
|
314 |
CHECKED_PTR_OF(type, x), \
|
williamr@2
|
315 |
enc, kstr, klen, cb, u); \
|
williamr@2
|
316 |
}
|
williamr@2
|
317 |
|
williamr@2
|
318 |
#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
|
williamr@2
|
319 |
EXPORT_C int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
|
williamr@2
|
320 |
unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
|
williamr@2
|
321 |
{ \
|
williamr@2
|
322 |
return PEM_ASN1_write_bio(CHECKED_I2D_OF(const type, i2d_##asn1), \
|
williamr@2
|
323 |
str, bp, \
|
williamr@2
|
324 |
CHECKED_PTR_OF(const type, x), \
|
williamr@2
|
325 |
enc, kstr, klen, cb, u); \
|
williamr@2
|
326 |
}
|
williamr@2
|
327 |
|
williamr@2
|
328 |
#define IMPLEMENT_PEM_write(name, type, str, asn1) \
|
williamr@2
|
329 |
IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
|
williamr@2
|
330 |
IMPLEMENT_PEM_write_fp(name, type, str, asn1)
|
williamr@2
|
331 |
|
williamr@2
|
332 |
#define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
|
williamr@2
|
333 |
IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
|
williamr@2
|
334 |
IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
|
williamr@2
|
335 |
|
williamr@2
|
336 |
#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
|
williamr@2
|
337 |
IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
|
williamr@2
|
338 |
IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
|
williamr@2
|
339 |
|
williamr@2
|
340 |
#define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
|
williamr@2
|
341 |
IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
|
williamr@2
|
342 |
IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
|
williamr@2
|
343 |
|
williamr@2
|
344 |
#define IMPLEMENT_PEM_read(name, type, str, asn1) \
|
williamr@2
|
345 |
IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
|
williamr@2
|
346 |
IMPLEMENT_PEM_read_fp(name, type, str, asn1)
|
williamr@2
|
347 |
|
williamr@2
|
348 |
#define IMPLEMENT_PEM_rw(name, type, str, asn1) \
|
williamr@2
|
349 |
IMPLEMENT_PEM_read(name, type, str, asn1) \
|
williamr@2
|
350 |
IMPLEMENT_PEM_write(name, type, str, asn1)
|
williamr@2
|
351 |
|
williamr@2
|
352 |
#define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
|
williamr@2
|
353 |
IMPLEMENT_PEM_read(name, type, str, asn1) \
|
williamr@2
|
354 |
IMPLEMENT_PEM_write_const(name, type, str, asn1)
|
williamr@2
|
355 |
|
williamr@2
|
356 |
#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
|
williamr@2
|
357 |
IMPLEMENT_PEM_read(name, type, str, asn1) \
|
williamr@2
|
358 |
IMPLEMENT_PEM_write_cb(name, type, str, asn1)
|
williamr@2
|
359 |
|
williamr@2
|
360 |
/* These are the same except they are for the declarations */
|
williamr@2
|
361 |
|
williamr@2
|
362 |
#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API)
|
williamr@2
|
363 |
|
williamr@2
|
364 |
#define DECLARE_PEM_read_fp(name, type) /**/
|
williamr@2
|
365 |
#define DECLARE_PEM_write_fp(name, type) /**/
|
williamr@2
|
366 |
#define DECLARE_PEM_write_cb_fp(name, type) /**/
|
williamr@2
|
367 |
|
williamr@2
|
368 |
#else
|
williamr@2
|
369 |
|
williamr@2
|
370 |
#define DECLARE_PEM_read_fp(name, type) \
|
williamr@2
|
371 |
IMPORT_C type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);
|
williamr@2
|
372 |
|
williamr@2
|
373 |
#define DECLARE_PEM_write_fp(name, type) \
|
williamr@2
|
374 |
IMPORT_C int PEM_write_##name(FILE *fp, type *x);
|
williamr@2
|
375 |
|
williamr@2
|
376 |
#define DECLARE_PEM_write_fp_const(name, type) \
|
williamr@2
|
377 |
IMPORT_C int PEM_write_##name(FILE *fp, const type *x);
|
williamr@2
|
378 |
|
williamr@2
|
379 |
#define DECLARE_PEM_write_cb_fp(name, type) \
|
williamr@2
|
380 |
IMPORT_C int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
|
williamr@2
|
381 |
unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
|
williamr@2
|
382 |
|
williamr@2
|
383 |
#endif
|
williamr@2
|
384 |
|
williamr@2
|
385 |
#ifndef OPENSSL_NO_BIO
|
williamr@2
|
386 |
#define DECLARE_PEM_read_bio(name, type) \
|
williamr@2
|
387 |
IMPORT_C type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);
|
williamr@2
|
388 |
|
williamr@2
|
389 |
#define DECLARE_PEM_write_bio(name, type) \
|
williamr@2
|
390 |
IMPORT_C int PEM_write_bio_##name(BIO *bp, type *x);
|
williamr@2
|
391 |
|
williamr@2
|
392 |
#define DECLARE_PEM_write_bio_const(name, type) \
|
williamr@2
|
393 |
IMPORT_C int PEM_write_bio_##name(BIO *bp, const type *x);
|
williamr@2
|
394 |
|
williamr@2
|
395 |
#define DECLARE_PEM_write_cb_bio(name, type) \
|
williamr@2
|
396 |
IMPORT_C int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
|
williamr@2
|
397 |
unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
|
williamr@2
|
398 |
|
williamr@2
|
399 |
#else
|
williamr@2
|
400 |
|
williamr@2
|
401 |
#define DECLARE_PEM_read_bio(name, type) /**/
|
williamr@2
|
402 |
#define DECLARE_PEM_write_bio(name, type) /**/
|
williamr@2
|
403 |
#define DECLARE_PEM_write_cb_bio(name, type) /**/
|
williamr@2
|
404 |
|
williamr@2
|
405 |
#endif
|
williamr@2
|
406 |
|
williamr@2
|
407 |
#define DECLARE_PEM_write(name, type) \
|
williamr@2
|
408 |
DECLARE_PEM_write_bio(name, type) \
|
williamr@2
|
409 |
DECLARE_PEM_write_fp(name, type)
|
williamr@2
|
410 |
|
williamr@2
|
411 |
#define DECLARE_PEM_write_const(name, type) \
|
williamr@2
|
412 |
DECLARE_PEM_write_bio_const(name, type) \
|
williamr@2
|
413 |
DECLARE_PEM_write_fp_const(name, type)
|
williamr@2
|
414 |
|
williamr@2
|
415 |
#define DECLARE_PEM_write_cb(name, type) \
|
williamr@2
|
416 |
DECLARE_PEM_write_cb_bio(name, type) \
|
williamr@2
|
417 |
DECLARE_PEM_write_cb_fp(name, type)
|
williamr@2
|
418 |
|
williamr@2
|
419 |
#define DECLARE_PEM_read(name, type) \
|
williamr@2
|
420 |
DECLARE_PEM_read_bio(name, type) \
|
williamr@2
|
421 |
DECLARE_PEM_read_fp(name, type)
|
williamr@2
|
422 |
|
williamr@2
|
423 |
#define DECLARE_PEM_rw(name, type) \
|
williamr@2
|
424 |
DECLARE_PEM_read(name, type) \
|
williamr@2
|
425 |
DECLARE_PEM_write(name, type)
|
williamr@2
|
426 |
|
williamr@2
|
427 |
#define DECLARE_PEM_rw_const(name, type) \
|
williamr@2
|
428 |
DECLARE_PEM_read(name, type) \
|
williamr@2
|
429 |
DECLARE_PEM_write_const(name, type)
|
williamr@2
|
430 |
|
williamr@2
|
431 |
#define DECLARE_PEM_rw_cb(name, type) \
|
williamr@2
|
432 |
DECLARE_PEM_read(name, type) \
|
williamr@2
|
433 |
DECLARE_PEM_write_cb(name, type)
|
williamr@2
|
434 |
|
williamr@2
|
435 |
#ifdef SSLEAY_MACROS
|
williamr@2
|
436 |
|
williamr@2
|
437 |
#define PEM_write_SSL_SESSION(fp,x) \
|
williamr@2
|
438 |
PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \
|
williamr@2
|
439 |
PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL)
|
williamr@2
|
440 |
#define PEM_write_X509(fp,x) \
|
williamr@2
|
441 |
PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \
|
williamr@2
|
442 |
(char *)x, NULL,NULL,0,NULL,NULL)
|
williamr@2
|
443 |
#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \
|
williamr@2
|
444 |
(int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \
|
williamr@2
|
445 |
NULL,NULL,0,NULL,NULL)
|
williamr@2
|
446 |
#define PEM_write_X509_CRL(fp,x) \
|
williamr@2
|
447 |
PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \
|
williamr@2
|
448 |
fp,(char *)x, NULL,NULL,0,NULL,NULL)
|
williamr@2
|
449 |
#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \
|
williamr@2
|
450 |
PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\
|
williamr@2
|
451 |
(char *)x,enc,kstr,klen,cb,u)
|
williamr@2
|
452 |
#define PEM_write_RSAPublicKey(fp,x) \
|
williamr@2
|
453 |
PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\
|
williamr@2
|
454 |
PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL)
|
williamr@2
|
455 |
#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \
|
williamr@2
|
456 |
PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\
|
williamr@2
|
457 |
(char *)x,enc,kstr,klen,cb,u)
|
williamr@2
|
458 |
#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb,u) \
|
williamr@2
|
459 |
PEM_ASN1_write((int (*)())i2d_PrivateKey,\
|
williamr@2
|
460 |
(((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
|
williamr@2
|
461 |
bp,(char *)x,enc,kstr,klen,cb,u)
|
williamr@2
|
462 |
#define PEM_write_PKCS7(fp,x) \
|
williamr@2
|
463 |
PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \
|
williamr@2
|
464 |
(char *)x, NULL,NULL,0,NULL,NULL)
|
williamr@2
|
465 |
#define PEM_write_DHparams(fp,x) \
|
williamr@2
|
466 |
PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\
|
williamr@2
|
467 |
(char *)x,NULL,NULL,0,NULL,NULL)
|
williamr@2
|
468 |
|
williamr@2
|
469 |
#define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \
|
williamr@2
|
470 |
PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
|
williamr@2
|
471 |
PEM_STRING_X509,fp, \
|
williamr@2
|
472 |
(char *)x, NULL,NULL,0,NULL,NULL)
|
williamr@2
|
473 |
|
williamr@2
|
474 |
#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \
|
williamr@2
|
475 |
(char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u)
|
williamr@2
|
476 |
#define PEM_read_X509(fp,x,cb,u) (X509 *)PEM_ASN1_read( \
|
williamr@2
|
477 |
(char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb,u)
|
williamr@2
|
478 |
#define PEM_read_X509_REQ(fp,x,cb,u) (X509_REQ *)PEM_ASN1_read( \
|
williamr@2
|
479 |
(char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb,u)
|
williamr@2
|
480 |
#define PEM_read_X509_CRL(fp,x,cb,u) (X509_CRL *)PEM_ASN1_read( \
|
williamr@2
|
481 |
(char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb,u)
|
williamr@2
|
482 |
#define PEM_read_RSAPrivateKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \
|
williamr@2
|
483 |
(char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb,u)
|
williamr@2
|
484 |
#define PEM_read_RSAPublicKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \
|
williamr@2
|
485 |
(char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb,u)
|
williamr@2
|
486 |
#define PEM_read_DSAPrivateKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \
|
williamr@2
|
487 |
(char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb,u)
|
williamr@2
|
488 |
#define PEM_read_PrivateKey(fp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read( \
|
williamr@2
|
489 |
(char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb,u)
|
williamr@2
|
490 |
#define PEM_read_PKCS7(fp,x,cb,u) (PKCS7 *)PEM_ASN1_read( \
|
williamr@2
|
491 |
(char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb,u)
|
williamr@2
|
492 |
#define PEM_read_DHparams(fp,x,cb,u) (DH *)PEM_ASN1_read( \
|
williamr@2
|
493 |
(char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb,u)
|
williamr@2
|
494 |
|
williamr@2
|
495 |
#define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb,u) \
|
williamr@2
|
496 |
(NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \
|
williamr@2
|
497 |
(char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\
|
williamr@2
|
498 |
(char **)x,cb,u)
|
williamr@2
|
499 |
|
williamr@2
|
500 |
#define PEM_write_bio_X509(bp,x) \
|
williamr@2
|
501 |
PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \
|
williamr@2
|
502 |
(char *)x, NULL,NULL,0,NULL,NULL)
|
williamr@2
|
503 |
#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \
|
williamr@2
|
504 |
(int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \
|
williamr@2
|
505 |
NULL,NULL,0,NULL,NULL)
|
williamr@2
|
506 |
#define PEM_write_bio_X509_CRL(bp,x) \
|
williamr@2
|
507 |
PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\
|
williamr@2
|
508 |
bp,(char *)x, NULL,NULL,0,NULL,NULL)
|
williamr@2
|
509 |
#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
|
williamr@2
|
510 |
PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\
|
williamr@2
|
511 |
bp,(char *)x,enc,kstr,klen,cb,u)
|
williamr@2
|
512 |
#define PEM_write_bio_RSAPublicKey(bp,x) \
|
williamr@2
|
513 |
PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \
|
williamr@2
|
514 |
PEM_STRING_RSA_PUBLIC,\
|
williamr@2
|
515 |
bp,(char *)x,NULL,NULL,0,NULL,NULL)
|
williamr@2
|
516 |
#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
|
williamr@2
|
517 |
PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\
|
williamr@2
|
518 |
bp,(char *)x,enc,kstr,klen,cb,u)
|
williamr@2
|
519 |
#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb,u) \
|
williamr@2
|
520 |
PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\
|
williamr@2
|
521 |
(((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
|
williamr@2
|
522 |
bp,(char *)x,enc,kstr,klen,cb,u)
|
williamr@2
|
523 |
#define PEM_write_bio_PKCS7(bp,x) \
|
williamr@2
|
524 |
PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \
|
williamr@2
|
525 |
(char *)x, NULL,NULL,0,NULL,NULL)
|
williamr@2
|
526 |
#define PEM_write_bio_DHparams(bp,x) \
|
williamr@2
|
527 |
PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\
|
williamr@2
|
528 |
bp,(char *)x,NULL,NULL,0,NULL,NULL)
|
williamr@2
|
529 |
#define PEM_write_bio_DSAparams(bp,x) \
|
williamr@2
|
530 |
PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \
|
williamr@2
|
531 |
PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL,NULL)
|
williamr@2
|
532 |
|
williamr@2
|
533 |
#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \
|
williamr@2
|
534 |
PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \
|
williamr@2
|
535 |
PEM_STRING_X509,bp, \
|
williamr@2
|
536 |
(char *)x, NULL,NULL,0,NULL,NULL)
|
williamr@2
|
537 |
|
williamr@2
|
538 |
#define PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \
|
williamr@2
|
539 |
(char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u)
|
williamr@2
|
540 |
#define PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \
|
williamr@2
|
541 |
(char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb,u)
|
williamr@2
|
542 |
#define PEM_read_bio_X509_CRL(bp,x,cb,u) (X509_CRL *)PEM_ASN1_read_bio( \
|
williamr@2
|
543 |
(char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb,u)
|
williamr@2
|
544 |
#define PEM_read_bio_RSAPrivateKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \
|
williamr@2
|
545 |
(char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb,u)
|
williamr@2
|
546 |
#define PEM_read_bio_RSAPublicKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \
|
williamr@2
|
547 |
(char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb,u)
|
williamr@2
|
548 |
#define PEM_read_bio_DSAPrivateKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
|
williamr@2
|
549 |
(char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb,u)
|
williamr@2
|
550 |
#define PEM_read_bio_PrivateKey(bp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read_bio( \
|
williamr@2
|
551 |
(char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb,u)
|
williamr@2
|
552 |
|
williamr@2
|
553 |
#define PEM_read_bio_PKCS7(bp,x,cb,u) (PKCS7 *)PEM_ASN1_read_bio( \
|
williamr@2
|
554 |
(char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb,u)
|
williamr@2
|
555 |
#define PEM_read_bio_DHparams(bp,x,cb,u) (DH *)PEM_ASN1_read_bio( \
|
williamr@2
|
556 |
(char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb,u)
|
williamr@2
|
557 |
#define PEM_read_bio_DSAparams(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
|
williamr@2
|
558 |
(char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb,u)
|
williamr@2
|
559 |
|
williamr@2
|
560 |
#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb,u) \
|
williamr@2
|
561 |
(NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \
|
williamr@2
|
562 |
(char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\
|
williamr@2
|
563 |
(char **)x,cb,u)
|
williamr@2
|
564 |
|
williamr@2
|
565 |
#endif
|
williamr@2
|
566 |
|
williamr@2
|
567 |
#if 1
|
williamr@2
|
568 |
/* "userdata": new with OpenSSL 0.9.4 */
|
williamr@2
|
569 |
typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);
|
williamr@2
|
570 |
#else
|
williamr@2
|
571 |
/* OpenSSL 0.9.3, 0.9.3a */
|
williamr@2
|
572 |
typedef int pem_password_cb(char *buf, int size, int rwflag);
|
williamr@2
|
573 |
#endif
|
williamr@2
|
574 |
|
williamr@2
|
575 |
IMPORT_C int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
|
williamr@2
|
576 |
IMPORT_C int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
|
williamr@2
|
577 |
pem_password_cb *callback,void *u);
|
williamr@2
|
578 |
|
williamr@2
|
579 |
#ifndef OPENSSL_NO_BIO
|
williamr@2
|
580 |
IMPORT_C int PEM_read_bio(BIO *bp, char **name, char **header,
|
williamr@2
|
581 |
unsigned char **data,long *len);
|
williamr@2
|
582 |
IMPORT_C int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data,
|
williamr@2
|
583 |
long len);
|
williamr@2
|
584 |
IMPORT_C int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp,
|
williamr@2
|
585 |
pem_password_cb *cb, void *u);
|
williamr@2
|
586 |
IMPORT_C void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp,
|
williamr@2
|
587 |
void **x, pem_password_cb *cb, void *u);
|
williamr@2
|
588 |
|
williamr@2
|
589 |
#define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \
|
williamr@2
|
590 |
((type*)PEM_ASN1_read_bio(CHECKED_D2I_OF(type, d2i), \
|
williamr@2
|
591 |
name, bp, \
|
williamr@2
|
592 |
CHECKED_PPTR_OF(type, x), \
|
williamr@2
|
593 |
cb, u))
|
williamr@2
|
594 |
|
williamr@2
|
595 |
IMPORT_C int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x,
|
williamr@2
|
596 |
const EVP_CIPHER *enc,unsigned char *kstr,int klen,
|
williamr@2
|
597 |
pem_password_cb *cb, void *u);
|
williamr@2
|
598 |
|
williamr@2
|
599 |
#define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \
|
williamr@2
|
600 |
(PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d), \
|
williamr@2
|
601 |
name, bp, \
|
williamr@2
|
602 |
CHECKED_PTR_OF(type, x), \
|
williamr@2
|
603 |
enc, kstr, klen, cb, u))
|
williamr@2
|
604 |
|
williamr@2
|
605 |
IMPORT_C STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
|
williamr@2
|
606 |
IMPORT_C int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
|
williamr@2
|
607 |
unsigned char *kstr, int klen, pem_password_cb *cd, void *u);
|
williamr@2
|
608 |
#endif
|
williamr@2
|
609 |
|
williamr@2
|
610 |
#ifndef OPENSSL_SYS_WIN16
|
williamr@2
|
611 |
IMPORT_C int PEM_read(FILE *fp, char **name, char **header,
|
williamr@2
|
612 |
unsigned char **data,long *len);
|
williamr@2
|
613 |
IMPORT_C int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
|
williamr@2
|
614 |
IMPORT_C void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
|
williamr@2
|
615 |
pem_password_cb *cb, void *u);
|
williamr@2
|
616 |
IMPORT_C int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp,
|
williamr@2
|
617 |
char *x,const EVP_CIPHER *enc,unsigned char *kstr,
|
williamr@2
|
618 |
int klen,pem_password_cb *callback, void *u);
|
williamr@2
|
619 |
IMPORT_C STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
|
williamr@2
|
620 |
pem_password_cb *cb, void *u);
|
williamr@2
|
621 |
#endif
|
williamr@2
|
622 |
|
williamr@2
|
623 |
IMPORT_C int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
|
williamr@2
|
624 |
EVP_MD *md_type, unsigned char **ek, int *ekl,
|
williamr@2
|
625 |
unsigned char *iv, EVP_PKEY **pubk, int npubk);
|
williamr@2
|
626 |
IMPORT_C void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
|
williamr@2
|
627 |
unsigned char *in, int inl);
|
williamr@2
|
628 |
IMPORT_C int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl,
|
williamr@2
|
629 |
unsigned char *out, int *outl, EVP_PKEY *priv);
|
williamr@2
|
630 |
|
williamr@2
|
631 |
IMPORT_C void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
|
williamr@2
|
632 |
IMPORT_C void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
|
williamr@2
|
633 |
IMPORT_C int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
|
williamr@2
|
634 |
unsigned int *siglen, EVP_PKEY *pkey);
|
williamr@2
|
635 |
|
williamr@2
|
636 |
IMPORT_C int PEM_def_callback(char *buf, int num, int w, void *key);
|
williamr@2
|
637 |
IMPORT_C void PEM_proc_type(char *buf, int type);
|
williamr@2
|
638 |
IMPORT_C void PEM_dek_info(char *buf, const char *type, int len, char *str);
|
williamr@2
|
639 |
|
williamr@2
|
640 |
#ifndef SSLEAY_MACROS
|
williamr@2
|
641 |
|
williamr@2
|
642 |
#include <openssl/symhacks.h>
|
williamr@2
|
643 |
|
williamr@2
|
644 |
DECLARE_PEM_rw(X509, X509)
|
williamr@2
|
645 |
|
williamr@2
|
646 |
DECLARE_PEM_rw(X509_AUX, X509)
|
williamr@2
|
647 |
|
williamr@2
|
648 |
DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR)
|
williamr@2
|
649 |
|
williamr@2
|
650 |
DECLARE_PEM_rw(X509_REQ, X509_REQ)
|
williamr@2
|
651 |
DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
|
williamr@2
|
652 |
|
williamr@2
|
653 |
DECLARE_PEM_rw(X509_CRL, X509_CRL)
|
williamr@2
|
654 |
|
williamr@2
|
655 |
DECLARE_PEM_rw(PKCS7, PKCS7)
|
williamr@2
|
656 |
|
williamr@2
|
657 |
DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
|
williamr@2
|
658 |
|
williamr@2
|
659 |
DECLARE_PEM_rw(PKCS8, X509_SIG)
|
williamr@2
|
660 |
|
williamr@2
|
661 |
DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
|
williamr@2
|
662 |
|
williamr@2
|
663 |
#ifndef OPENSSL_NO_RSA
|
williamr@2
|
664 |
|
williamr@2
|
665 |
DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
|
williamr@2
|
666 |
|
williamr@2
|
667 |
DECLARE_PEM_rw_const(RSAPublicKey, RSA)
|
williamr@2
|
668 |
DECLARE_PEM_rw(RSA_PUBKEY, RSA)
|
williamr@2
|
669 |
|
williamr@2
|
670 |
#endif
|
williamr@2
|
671 |
|
williamr@2
|
672 |
#ifndef OPENSSL_NO_DSA
|
williamr@2
|
673 |
|
williamr@2
|
674 |
DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
|
williamr@2
|
675 |
|
williamr@2
|
676 |
DECLARE_PEM_rw(DSA_PUBKEY, DSA)
|
williamr@2
|
677 |
|
williamr@2
|
678 |
DECLARE_PEM_rw_const(DSAparams, DSA)
|
williamr@2
|
679 |
|
williamr@2
|
680 |
#endif
|
williamr@2
|
681 |
|
williamr@2
|
682 |
#ifndef OPENSSL_NO_EC
|
williamr@2
|
683 |
DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)
|
williamr@2
|
684 |
DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
|
williamr@2
|
685 |
DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
|
williamr@2
|
686 |
#endif
|
williamr@2
|
687 |
|
williamr@2
|
688 |
#ifndef OPENSSL_NO_DH
|
williamr@2
|
689 |
|
williamr@2
|
690 |
DECLARE_PEM_rw_const(DHparams, DH)
|
williamr@2
|
691 |
|
williamr@2
|
692 |
#endif
|
williamr@2
|
693 |
|
williamr@2
|
694 |
DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
|
williamr@2
|
695 |
|
williamr@2
|
696 |
DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
|
williamr@2
|
697 |
|
williamr@2
|
698 |
IMPORT_C int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
|
williamr@2
|
699 |
char *kstr, int klen,
|
williamr@2
|
700 |
pem_password_cb *cb, void *u);
|
williamr@2
|
701 |
IMPORT_C int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
|
williamr@2
|
702 |
char *, int, pem_password_cb *, void *);
|
williamr@2
|
703 |
IMPORT_C int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
|
williamr@2
|
704 |
char *kstr, int klen,
|
williamr@2
|
705 |
pem_password_cb *cb, void *u);
|
williamr@2
|
706 |
IMPORT_C int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
|
williamr@2
|
707 |
char *kstr, int klen,
|
williamr@2
|
708 |
pem_password_cb *cb, void *u);
|
williamr@2
|
709 |
IMPORT_C EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
|
williamr@2
|
710 |
|
williamr@2
|
711 |
IMPORT_C int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
|
williamr@2
|
712 |
char *kstr, int klen,
|
williamr@2
|
713 |
pem_password_cb *cb, void *u);
|
williamr@2
|
714 |
IMPORT_C int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
|
williamr@2
|
715 |
char *kstr, int klen,
|
williamr@2
|
716 |
pem_password_cb *cb, void *u);
|
williamr@2
|
717 |
IMPORT_C int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
|
williamr@2
|
718 |
char *kstr, int klen,
|
williamr@2
|
719 |
pem_password_cb *cb, void *u);
|
williamr@2
|
720 |
|
williamr@2
|
721 |
IMPORT_C EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
|
williamr@2
|
722 |
|
williamr@2
|
723 |
IMPORT_C int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
|
williamr@2
|
724 |
char *kstr,int klen, pem_password_cb *cd, void *u);
|
williamr@2
|
725 |
|
williamr@2
|
726 |
#endif /* SSLEAY_MACROS */
|
williamr@2
|
727 |
|
williamr@2
|
728 |
|
williamr@2
|
729 |
/* BEGIN ERROR CODES */
|
williamr@2
|
730 |
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
williamr@2
|
731 |
* made after this point may be overwritten when the script is next run.
|
williamr@2
|
732 |
*/
|
williamr@2
|
733 |
IMPORT_C void ERR_load_PEM_strings(void);
|
williamr@2
|
734 |
|
williamr@2
|
735 |
/* Error codes for the PEM functions. */
|
williamr@2
|
736 |
|
williamr@2
|
737 |
/* Function codes. */
|
williamr@2
|
738 |
#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120
|
williamr@2
|
739 |
#define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121
|
williamr@2
|
740 |
#define PEM_F_DO_PK8PKEY 126
|
williamr@2
|
741 |
#define PEM_F_DO_PK8PKEY_FP 125
|
williamr@2
|
742 |
#define PEM_F_LOAD_IV 101
|
williamr@2
|
743 |
#define PEM_F_PEM_ASN1_READ 102
|
williamr@2
|
744 |
#define PEM_F_PEM_ASN1_READ_BIO 103
|
williamr@2
|
745 |
#define PEM_F_PEM_ASN1_WRITE 104
|
williamr@2
|
746 |
#define PEM_F_PEM_ASN1_WRITE_BIO 105
|
williamr@2
|
747 |
#define PEM_F_PEM_DEF_CALLBACK 100
|
williamr@2
|
748 |
#define PEM_F_PEM_DO_HEADER 106
|
williamr@2
|
749 |
#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118
|
williamr@2
|
750 |
#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
|
williamr@2
|
751 |
#define PEM_F_PEM_PK8PKEY 119
|
williamr@2
|
752 |
#define PEM_F_PEM_READ 108
|
williamr@2
|
753 |
#define PEM_F_PEM_READ_BIO 109
|
williamr@2
|
754 |
#define PEM_F_PEM_READ_BIO_PRIVATEKEY 123
|
williamr@2
|
755 |
#define PEM_F_PEM_READ_PRIVATEKEY 124
|
williamr@2
|
756 |
#define PEM_F_PEM_SEALFINAL 110
|
williamr@2
|
757 |
#define PEM_F_PEM_SEALINIT 111
|
williamr@2
|
758 |
#define PEM_F_PEM_SIGNFINAL 112
|
williamr@2
|
759 |
#define PEM_F_PEM_WRITE 113
|
williamr@2
|
760 |
#define PEM_F_PEM_WRITE_BIO 114
|
williamr@2
|
761 |
#define PEM_F_PEM_X509_INFO_READ 115
|
williamr@2
|
762 |
#define PEM_F_PEM_X509_INFO_READ_BIO 116
|
williamr@2
|
763 |
#define PEM_F_PEM_X509_INFO_WRITE_BIO 117
|
williamr@2
|
764 |
|
williamr@2
|
765 |
/* Reason codes. */
|
williamr@2
|
766 |
#define PEM_R_BAD_BASE64_DECODE 100
|
williamr@2
|
767 |
#define PEM_R_BAD_DECRYPT 101
|
williamr@2
|
768 |
#define PEM_R_BAD_END_LINE 102
|
williamr@2
|
769 |
#define PEM_R_BAD_IV_CHARS 103
|
williamr@2
|
770 |
#define PEM_R_BAD_PASSWORD_READ 104
|
williamr@2
|
771 |
#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115
|
williamr@2
|
772 |
#define PEM_R_NOT_DEK_INFO 105
|
williamr@2
|
773 |
#define PEM_R_NOT_ENCRYPTED 106
|
williamr@2
|
774 |
#define PEM_R_NOT_PROC_TYPE 107
|
williamr@2
|
775 |
#define PEM_R_NO_START_LINE 108
|
williamr@2
|
776 |
#define PEM_R_PROBLEMS_GETTING_PASSWORD 109
|
williamr@2
|
777 |
#define PEM_R_PUBLIC_KEY_NO_RSA 110
|
williamr@2
|
778 |
#define PEM_R_READ_KEY 111
|
williamr@2
|
779 |
#define PEM_R_SHORT_HEADER 112
|
williamr@2
|
780 |
#define PEM_R_UNSUPPORTED_CIPHER 113
|
williamr@2
|
781 |
#define PEM_R_UNSUPPORTED_ENCRYPTION 114
|
williamr@2
|
782 |
|
williamr@2
|
783 |
#ifdef __cplusplus
|
williamr@2
|
784 |
}
|
williamr@2
|
785 |
#endif
|
williamr@2
|
786 |
#endif
|