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. 7 * 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). 14 * 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. 21 * 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 :-). 36 * 4. If you include any Windows specific code (or a derivative thereof) from 37 * the apps directory (application code) you must include an acknowledgement: 38 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 39 * 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. 51 * 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 #ifndef OPENSSL_HEADER_PEM_H 58 #define OPENSSL_HEADER_PEM_H 59 60 #include <openssl/base64.h> 61 #include <openssl/bio.h> 62 #include <openssl/cipher.h> 63 #include <openssl/digest.h> 64 #include <openssl/evp.h> 65 #include <openssl/stack.h> 66 #include <openssl/pkcs7.h> 67 #include <openssl/x509.h> 68 69 /* For compatibility with open-iscsi, which assumes that it can get 70 * |OPENSSL_malloc| from pem.h or err.h */ 71 #include <openssl/crypto.h> 72 73 #ifdef __cplusplus 74 extern "C" { 75 #endif 76 77 78 #define PEM_BUFSIZE 1024 79 80 #define PEM_STRING_X509_OLD "X509 CERTIFICATE" 81 #define PEM_STRING_X509 "CERTIFICATE" 82 #define PEM_STRING_X509_PAIR "CERTIFICATE PAIR" 83 #define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE" 84 #define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" 85 #define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" 86 #define PEM_STRING_X509_CRL "X509 CRL" 87 #define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" 88 #define PEM_STRING_PUBLIC "PUBLIC KEY" 89 #define PEM_STRING_RSA "RSA PRIVATE KEY" 90 #define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" 91 #define PEM_STRING_DSA "DSA PRIVATE KEY" 92 #define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" 93 #define PEM_STRING_EC "EC PRIVATE KEY" 94 #define PEM_STRING_PKCS7 "PKCS7" 95 #define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA" 96 #define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" 97 #define PEM_STRING_PKCS8INF "PRIVATE KEY" 98 #define PEM_STRING_DHPARAMS "DH PARAMETERS" 99 #define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" 100 #define PEM_STRING_DSAPARAMS "DSA PARAMETERS" 101 #define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" 102 #define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" 103 #define PEM_STRING_CMS "CMS" 104 105 /* enc_type is one off */ 106 #define PEM_TYPE_ENCRYPTED 10 107 #define PEM_TYPE_MIC_ONLY 20 108 #define PEM_TYPE_MIC_CLEAR 30 109 #define PEM_TYPE_CLEAR 40 110 111 /* These macros make the PEM_read/PEM_write functions easier to maintain and 112 * write. Now they are all implemented with either: 113 * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...) 114 */ 115 116 #ifdef OPENSSL_NO_FP_API 117 118 #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ 119 #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ 120 #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/ 121 #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ 122 #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/ 123 124 #else 125 126 #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ 127 static void *pem_read_##name##_d2i(void **x, const unsigned char **inp, \ 128 long len) { \ 129 return d2i_##asn1((type **)x, inp, len); \ 130 } \ 131 OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, \ 132 pem_password_cb *cb, void *u) { \ 133 return (type *)PEM_ASN1_read(pem_read_##name##_d2i, str, fp, (void **)x, \ 134 cb, u); \ 135 } 136 137 #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ 138 static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \ 139 return i2d_##asn1((type *)x, outp); \ 140 } \ 141 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x) { \ 142 return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, x, NULL, NULL, 0, \ 143 NULL, NULL); \ 144 } 145 146 #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ 147 static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \ 148 return i2d_##asn1((const type *)x, outp); \ 149 } \ 150 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x) { \ 151 return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, (void *)x, NULL, \ 152 NULL, 0, NULL, NULL); \ 153 } 154 155 #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ 156 static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \ 157 return i2d_##asn1((type *)x, outp); \ 158 } \ 159 OPENSSL_EXPORT int PEM_write_##name( \ 160 FILE *fp, type *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, \ 161 pem_password_cb *cb, void *u) { \ 162 return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, x, enc, kstr, klen, \ 163 cb, u); \ 164 } 165 166 #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ 167 static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \ 168 return i2d_##asn1((const type *)x, outp); \ 169 } \ 170 OPENSSL_EXPORT int PEM_write_##name( \ 171 FILE *fp, type *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, \ 172 pem_password_cb *cb, void *u) { \ 173 return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, x, enc, kstr, klen, \ 174 cb, u); \ 175 } 176 177 #endif 178 179 #define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ 180 static void *pem_read_bio_##name##_d2i(void **x, const unsigned char **inp, \ 181 long len) { \ 182 return d2i_##asn1((type **)x, inp, len); \ 183 } \ 184 OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, \ 185 pem_password_cb *cb, void *u) { \ 186 return (type *)PEM_ASN1_read_bio(pem_read_bio_##name##_d2i, str, bp, \ 187 (void **)x, cb, u); \ 188 } 189 190 #define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ 191 static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \ 192 return i2d_##asn1((type *)x, outp); \ 193 } \ 194 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x) { \ 195 return PEM_ASN1_write_bio(pem_write_bio_##name##_i2d, str, bp, x, NULL, \ 196 NULL, 0, NULL, NULL); \ 197 } 198 199 #define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ 200 static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \ 201 return i2d_##asn1((const type *)x, outp); \ 202 } \ 203 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x) { \ 204 return PEM_ASN1_write_bio(pem_write_bio_##name##_i2d, str, bp, (void *)x, \ 205 NULL, NULL, 0, NULL, NULL); \ 206 } 207 208 #define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ 209 static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \ 210 return i2d_##asn1((type *)x, outp); \ 211 } \ 212 OPENSSL_EXPORT int PEM_write_bio_##name( \ 213 BIO *bp, type *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, \ 214 pem_password_cb *cb, void *u) { \ 215 return PEM_ASN1_write_bio(pem_write_bio_##name##_i2d, str, bp, x, enc, \ 216 kstr, klen, cb, u); \ 217 } 218 219 #define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ 220 static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \ 221 return i2d_##asn1((const type *)x, outp); \ 222 } \ 223 OPENSSL_EXPORT int PEM_write_bio_##name( \ 224 BIO *bp, type *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, \ 225 pem_password_cb *cb, void *u) { \ 226 return PEM_ASN1_write_bio(pem_write_bio_##name##_i2d, str, bp, (void *)x, \ 227 enc, kstr, klen, cb, u); \ 228 } 229 230 #define IMPLEMENT_PEM_write(name, type, str, asn1) \ 231 IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ 232 IMPLEMENT_PEM_write_fp(name, type, str, asn1) 233 234 #define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ 235 IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ 236 IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) 237 238 #define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ 239 IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ 240 IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) 241 242 #define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ 243 IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ 244 IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) 245 246 #define IMPLEMENT_PEM_read(name, type, str, asn1) \ 247 IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ 248 IMPLEMENT_PEM_read_fp(name, type, str, asn1) 249 250 #define IMPLEMENT_PEM_rw(name, type, str, asn1) \ 251 IMPLEMENT_PEM_read(name, type, str, asn1) \ 252 IMPLEMENT_PEM_write(name, type, str, asn1) 253 254 #define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ 255 IMPLEMENT_PEM_read(name, type, str, asn1) \ 256 IMPLEMENT_PEM_write_const(name, type, str, asn1) 257 258 #define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ 259 IMPLEMENT_PEM_read(name, type, str, asn1) \ 260 IMPLEMENT_PEM_write_cb(name, type, str, asn1) 261 262 /* These are the same except they are for the declarations */ 263 264 #if defined(OPENSSL_NO_FP_API) 265 266 #define DECLARE_PEM_read_fp(name, type) /**/ 267 #define DECLARE_PEM_write_fp(name, type) /**/ 268 #define DECLARE_PEM_write_cb_fp(name, type) /**/ 269 270 #else 271 272 #define DECLARE_PEM_read_fp(name, type) \ 273 OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u); 274 275 #define DECLARE_PEM_write_fp(name, type) \ 276 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x); 277 278 #define DECLARE_PEM_write_fp_const(name, type) \ 279 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x); 280 281 #define DECLARE_PEM_write_cb_fp(name, type) \ 282 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ 283 unsigned char *kstr, int klen, pem_password_cb *cb, void *u); 284 285 #endif 286 287 #define DECLARE_PEM_read_bio(name, type) \ 288 OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); 289 290 #define DECLARE_PEM_write_bio(name, type) \ 291 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x); 292 293 #define DECLARE_PEM_write_bio_const(name, type) \ 294 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x); 295 296 #define DECLARE_PEM_write_cb_bio(name, type) \ 297 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ 298 unsigned char *kstr, int klen, pem_password_cb *cb, void *u); 299 300 301 #define DECLARE_PEM_write(name, type) \ 302 DECLARE_PEM_write_bio(name, type) \ 303 DECLARE_PEM_write_fp(name, type) 304 305 #define DECLARE_PEM_write_const(name, type) \ 306 DECLARE_PEM_write_bio_const(name, type) \ 307 DECLARE_PEM_write_fp_const(name, type) 308 309 #define DECLARE_PEM_write_cb(name, type) \ 310 DECLARE_PEM_write_cb_bio(name, type) \ 311 DECLARE_PEM_write_cb_fp(name, type) 312 313 #define DECLARE_PEM_read(name, type) \ 314 DECLARE_PEM_read_bio(name, type) \ 315 DECLARE_PEM_read_fp(name, type) 316 317 #define DECLARE_PEM_rw(name, type) \ 318 DECLARE_PEM_read(name, type) \ 319 DECLARE_PEM_write(name, type) 320 321 #define DECLARE_PEM_rw_const(name, type) \ 322 DECLARE_PEM_read(name, type) \ 323 DECLARE_PEM_write_const(name, type) 324 325 #define DECLARE_PEM_rw_cb(name, type) \ 326 DECLARE_PEM_read(name, type) \ 327 DECLARE_PEM_write_cb(name, type) 328 329 /* "userdata": new with OpenSSL 0.9.4 */ 330 typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata); 331 332 OPENSSL_EXPORT int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); 333 OPENSSL_EXPORT int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, pem_password_cb *callback,void *u); 334 335 OPENSSL_EXPORT int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data,long *len); 336 OPENSSL_EXPORT int PEM_write_bio(BIO *bp,const char *name, const char *hdr, const unsigned char *data, long len); 337 OPENSSL_EXPORT int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, pem_password_cb *cb, void *u); 338 OPENSSL_EXPORT void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, pem_password_cb *cb, void *u); 339 OPENSSL_EXPORT int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp, void *x, const EVP_CIPHER *enc,unsigned char *kstr,int klen, pem_password_cb *cb, void *u); 340 341 OPENSSL_EXPORT STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); 342 OPENSSL_EXPORT int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cd, void *u); 343 344 OPENSSL_EXPORT int PEM_read(FILE *fp, char **name, char **header, unsigned char **data,long *len); 345 OPENSSL_EXPORT int PEM_write(FILE *fp, const char *name, const char *hdr, const unsigned char *data, long len); 346 OPENSSL_EXPORT void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, pem_password_cb *cb, void *u); 347 OPENSSL_EXPORT int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp, void *x,const EVP_CIPHER *enc,unsigned char *kstr, int klen,pem_password_cb *callback, void *u); 348 OPENSSL_EXPORT STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); 349 350 /* PEM_def_callback treats |userdata| as a string and copies it into |buf|, 351 * assuming its |size| is sufficient. Returns the length of the string, or 0 352 * if there is not enough room. If either |buf| or |userdata| is NULL, 0 is 353 * returned. Note that this is different from OpenSSL, which prompts for a 354 * password. */ 355 OPENSSL_EXPORT int PEM_def_callback(char *buf, int size, int rwflag, void *userdata); 356 OPENSSL_EXPORT void PEM_proc_type(char *buf, int type); 357 OPENSSL_EXPORT void PEM_dek_info(char *buf, const char *type, int len, char *str); 358 359 360 DECLARE_PEM_rw(X509, X509) 361 362 DECLARE_PEM_rw(X509_AUX, X509) 363 364 DECLARE_PEM_rw(X509_REQ, X509_REQ) 365 DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) 366 367 DECLARE_PEM_rw(X509_CRL, X509_CRL) 368 369 DECLARE_PEM_rw(PKCS7, PKCS7) 370 DECLARE_PEM_rw(PKCS8, X509_SIG) 371 372 DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) 373 374 DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) 375 376 DECLARE_PEM_rw_const(RSAPublicKey, RSA) 377 DECLARE_PEM_rw(RSA_PUBKEY, RSA) 378 379 #ifndef OPENSSL_NO_DSA 380 381 DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) 382 383 DECLARE_PEM_rw(DSA_PUBKEY, DSA) 384 385 DECLARE_PEM_rw_const(DSAparams, DSA) 386 387 #endif 388 389 DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) 390 DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) 391 392 393 DECLARE_PEM_rw_const(DHparams, DH) 394 395 396 DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) 397 398 DECLARE_PEM_rw(PUBKEY, EVP_PKEY) 399 400 OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u); 401 OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, char *, int, pem_password_cb *, void *); 402 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u); 403 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u); 404 OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); 405 406 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u); 407 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u); 408 OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u); 409 410 OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); 411 412 OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, char *kstr,int klen, pem_password_cb *cd, void *u); 413 414 415 #ifdef __cplusplus 416 } 417 #endif 418 419 #define PEM_R_BAD_BASE64_DECODE 100 420 #define PEM_R_BAD_DECRYPT 101 421 #define PEM_R_BAD_END_LINE 102 422 #define PEM_R_BAD_IV_CHARS 103 423 #define PEM_R_BAD_PASSWORD_READ 104 424 #define PEM_R_CIPHER_IS_NULL 105 425 #define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 106 426 #define PEM_R_NOT_DEK_INFO 107 427 #define PEM_R_NOT_ENCRYPTED 108 428 #define PEM_R_NOT_PROC_TYPE 109 429 #define PEM_R_NO_START_LINE 110 430 #define PEM_R_READ_KEY 111 431 #define PEM_R_SHORT_HEADER 112 432 #define PEM_R_UNSUPPORTED_CIPHER 113 433 #define PEM_R_UNSUPPORTED_ENCRYPTION 114 434 435 #endif /* OPENSSL_HEADER_PEM_H */ 436