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/pkcs7.h> 66 #include <openssl/stack.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 #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ 117 static void *pem_read_##name##_d2i(void **x, const unsigned char **inp, \ 118 long len) { \ 119 return d2i_##asn1((type **)x, inp, len); \ 120 } \ 121 OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, \ 122 pem_password_cb *cb, void *u) { \ 123 return (type *)PEM_ASN1_read(pem_read_##name##_d2i, str, fp, (void **)x, \ 124 cb, u); \ 125 } 126 127 #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ 128 static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \ 129 return i2d_##asn1((type *)x, outp); \ 130 } \ 131 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x) { \ 132 return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, x, NULL, NULL, 0, \ 133 NULL, NULL); \ 134 } 135 136 #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ 137 static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \ 138 return i2d_##asn1((const type *)x, outp); \ 139 } \ 140 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x) { \ 141 return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, (void *)x, NULL, \ 142 NULL, 0, NULL, NULL); \ 143 } 144 145 #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ 146 static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \ 147 return i2d_##asn1((type *)x, outp); \ 148 } \ 149 OPENSSL_EXPORT int PEM_write_##name( \ 150 FILE *fp, type *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, \ 151 pem_password_cb *cb, void *u) { \ 152 return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, x, enc, kstr, klen, \ 153 cb, u); \ 154 } 155 156 #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ 157 static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \ 158 return i2d_##asn1((const type *)x, outp); \ 159 } \ 160 OPENSSL_EXPORT int PEM_write_##name( \ 161 FILE *fp, type *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, \ 162 pem_password_cb *cb, void *u) { \ 163 return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, x, enc, kstr, klen, \ 164 cb, u); \ 165 } 166 167 168 #define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ 169 static void *pem_read_bio_##name##_d2i(void **x, const unsigned char **inp, \ 170 long len) { \ 171 return d2i_##asn1((type **)x, inp, len); \ 172 } \ 173 OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, \ 174 pem_password_cb *cb, void *u) { \ 175 return (type *)PEM_ASN1_read_bio(pem_read_bio_##name##_d2i, str, bp, \ 176 (void **)x, cb, u); \ 177 } 178 179 #define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ 180 static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \ 181 return i2d_##asn1((type *)x, outp); \ 182 } \ 183 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x) { \ 184 return PEM_ASN1_write_bio(pem_write_bio_##name##_i2d, str, bp, x, NULL, \ 185 NULL, 0, NULL, NULL); \ 186 } 187 188 #define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ 189 static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \ 190 return i2d_##asn1((const type *)x, outp); \ 191 } \ 192 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x) { \ 193 return PEM_ASN1_write_bio(pem_write_bio_##name##_i2d, str, bp, (void *)x, \ 194 NULL, NULL, 0, NULL, NULL); \ 195 } 196 197 #define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ 198 static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \ 199 return i2d_##asn1((type *)x, outp); \ 200 } \ 201 OPENSSL_EXPORT int PEM_write_bio_##name( \ 202 BIO *bp, type *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, \ 203 pem_password_cb *cb, void *u) { \ 204 return PEM_ASN1_write_bio(pem_write_bio_##name##_i2d, str, bp, x, enc, \ 205 kstr, klen, cb, u); \ 206 } 207 208 #define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ 209 static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \ 210 return i2d_##asn1((const 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, (void *)x, \ 216 enc, kstr, klen, cb, u); \ 217 } 218 219 #define IMPLEMENT_PEM_write(name, type, str, asn1) \ 220 IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ 221 IMPLEMENT_PEM_write_fp(name, type, str, asn1) 222 223 #define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ 224 IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ 225 IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) 226 227 #define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ 228 IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ 229 IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) 230 231 #define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ 232 IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ 233 IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) 234 235 #define IMPLEMENT_PEM_read(name, type, str, asn1) \ 236 IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ 237 IMPLEMENT_PEM_read_fp(name, type, str, asn1) 238 239 #define IMPLEMENT_PEM_rw(name, type, str, asn1) \ 240 IMPLEMENT_PEM_read(name, type, str, asn1) \ 241 IMPLEMENT_PEM_write(name, type, str, asn1) 242 243 #define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ 244 IMPLEMENT_PEM_read(name, type, str, asn1) \ 245 IMPLEMENT_PEM_write_const(name, type, str, asn1) 246 247 #define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ 248 IMPLEMENT_PEM_read(name, type, str, asn1) \ 249 IMPLEMENT_PEM_write_cb(name, type, str, asn1) 250 251 // These are the same except they are for the declarations 252 253 #define DECLARE_PEM_read_fp(name, type) \ 254 OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, \ 255 pem_password_cb *cb, void *u); 256 257 #define DECLARE_PEM_write_fp(name, type) \ 258 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x); 259 260 #define DECLARE_PEM_write_fp_const(name, type) \ 261 OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x); 262 263 #define DECLARE_PEM_write_cb_fp(name, type) \ 264 OPENSSL_EXPORT int PEM_write_##name( \ 265 FILE *fp, type *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, \ 266 pem_password_cb *cb, void *u); 267 268 #define DECLARE_PEM_read_bio(name, type) \ 269 OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, \ 270 pem_password_cb *cb, void *u); 271 272 #define DECLARE_PEM_write_bio(name, type) \ 273 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x); 274 275 #define DECLARE_PEM_write_bio_const(name, type) \ 276 OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x); 277 278 #define DECLARE_PEM_write_cb_bio(name, type) \ 279 OPENSSL_EXPORT int PEM_write_bio_##name( \ 280 BIO *bp, type *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, \ 281 pem_password_cb *cb, void *u); 282 283 284 #define DECLARE_PEM_write(name, type) \ 285 DECLARE_PEM_write_bio(name, type) \ 286 DECLARE_PEM_write_fp(name, type) 287 288 #define DECLARE_PEM_write_const(name, type) \ 289 DECLARE_PEM_write_bio_const(name, type) \ 290 DECLARE_PEM_write_fp_const(name, type) 291 292 #define DECLARE_PEM_write_cb(name, type) \ 293 DECLARE_PEM_write_cb_bio(name, type) \ 294 DECLARE_PEM_write_cb_fp(name, type) 295 296 #define DECLARE_PEM_read(name, type) \ 297 DECLARE_PEM_read_bio(name, type) \ 298 DECLARE_PEM_read_fp(name, type) 299 300 #define DECLARE_PEM_rw(name, type) \ 301 DECLARE_PEM_read(name, type) \ 302 DECLARE_PEM_write(name, type) 303 304 #define DECLARE_PEM_rw_const(name, type) \ 305 DECLARE_PEM_read(name, type) \ 306 DECLARE_PEM_write_const(name, type) 307 308 #define DECLARE_PEM_rw_cb(name, type) \ 309 DECLARE_PEM_read(name, type) \ 310 DECLARE_PEM_write_cb(name, type) 311 312 // "userdata": new with OpenSSL 0.9.4 313 typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata); 314 315 OPENSSL_EXPORT int PEM_get_EVP_CIPHER_INFO(char *header, 316 EVP_CIPHER_INFO *cipher); 317 OPENSSL_EXPORT int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, 318 long *len, pem_password_cb *callback, void *u); 319 320 // PEM_read_bio reads from |bp|, until the next PEM block. If one is found, it 321 // returns one and sets |*name|, |*header|, and |*data| to newly-allocated 322 // buffers containing the PEM type, the header block, and the decoded data, 323 // respectively. |*name| and |*header| are NUL-terminated C strings, while 324 // |*data| has |*len| bytes. The caller must release each of |*name|, |*header|, 325 // and |*data| with |OPENSSL_free| when done. If no PEM block is found, this 326 // function returns zero and pushes |PEM_R_NO_START_LINE| to the error queue. If 327 // one is found, but there is an error decoding it, it returns zero and pushes 328 // some other error to the error queue. 329 OPENSSL_EXPORT int PEM_read_bio(BIO *bp, char **name, char **header, 330 unsigned char **data, long *len); 331 332 // PEM_write_bio writes a PEM block to |bp|, containing |len| bytes from |data| 333 // as data. |name| and |hdr| are NUL-terminated C strings containing the PEM 334 // type and header block, respectively. This function returns zero on error and 335 // the number of bytes written on success. 336 OPENSSL_EXPORT int PEM_write_bio(BIO *bp, const char *name, const char *hdr, 337 const unsigned char *data, long len); 338 339 OPENSSL_EXPORT int PEM_bytes_read_bio(unsigned char **pdata, long *plen, 340 char **pnm, const char *name, BIO *bp, 341 pem_password_cb *cb, void *u); 342 OPENSSL_EXPORT void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, 343 BIO *bp, void **x, pem_password_cb *cb, 344 void *u); 345 OPENSSL_EXPORT int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, 346 BIO *bp, void *x, const EVP_CIPHER *enc, 347 unsigned char *kstr, int klen, 348 pem_password_cb *cb, void *u); 349 350 OPENSSL_EXPORT STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio( 351 BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); 352 353 OPENSSL_EXPORT int PEM_read(FILE *fp, char **name, char **header, 354 unsigned char **data, long *len); 355 OPENSSL_EXPORT int PEM_write(FILE *fp, const char *name, const char *hdr, 356 const unsigned char *data, long len); 357 OPENSSL_EXPORT void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, 358 void **x, pem_password_cb *cb, void *u); 359 OPENSSL_EXPORT int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, 360 void *x, const EVP_CIPHER *enc, 361 unsigned char *kstr, int klen, 362 pem_password_cb *callback, void *u); 363 OPENSSL_EXPORT STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, 364 STACK_OF(X509_INFO) *sk, 365 pem_password_cb *cb, 366 void *u); 367 368 // PEM_def_callback treats |userdata| as a string and copies it into |buf|, 369 // assuming its |size| is sufficient. Returns the length of the string, or 0 370 // if there is not enough room. If either |buf| or |userdata| is NULL, 0 is 371 // returned. Note that this is different from OpenSSL, which prompts for a 372 // password. 373 OPENSSL_EXPORT int PEM_def_callback(char *buf, int size, int rwflag, 374 void *userdata); 375 376 377 DECLARE_PEM_rw(X509, X509) 378 379 DECLARE_PEM_rw(X509_AUX, X509) 380 381 DECLARE_PEM_rw(X509_REQ, X509_REQ) 382 DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) 383 384 DECLARE_PEM_rw(X509_CRL, X509_CRL) 385 386 DECLARE_PEM_rw(PKCS7, PKCS7) 387 DECLARE_PEM_rw(PKCS8, X509_SIG) 388 389 DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) 390 391 DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) 392 393 DECLARE_PEM_rw_const(RSAPublicKey, RSA) 394 DECLARE_PEM_rw(RSA_PUBKEY, RSA) 395 396 #ifndef OPENSSL_NO_DSA 397 398 DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) 399 400 DECLARE_PEM_rw(DSA_PUBKEY, DSA) 401 402 DECLARE_PEM_rw_const(DSAparams, DSA) 403 404 #endif 405 406 DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) 407 DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) 408 409 410 DECLARE_PEM_rw_const(DHparams, DH) 411 412 413 DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) 414 415 DECLARE_PEM_rw(PUBKEY, EVP_PKEY) 416 417 OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, const EVP_PKEY *x, 418 int nid, char *kstr, 419 int klen, 420 pem_password_cb *cb, 421 void *u); 422 OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey(BIO *, const EVP_PKEY *, 423 const EVP_CIPHER *, char *, 424 int, pem_password_cb *, 425 void *); 426 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_bio(BIO *bp, const EVP_PKEY *x, 427 const EVP_CIPHER *enc, char *kstr, 428 int klen, pem_password_cb *cb, 429 void *u); 430 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, const EVP_PKEY *x, 431 int nid, char *kstr, int klen, 432 pem_password_cb *cb, void *u); 433 OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, 434 pem_password_cb *cb, void *u); 435 436 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *x, 437 const EVP_CIPHER *enc, char *kstr, 438 int klen, pem_password_cb *cb, 439 void *u); 440 OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *x, 441 int nid, char *kstr, int klen, 442 pem_password_cb *cb, void *u); 443 OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey_nid(FILE *fp, const EVP_PKEY *x, 444 int nid, char *kstr, int klen, 445 pem_password_cb *cb, void *u); 446 447 OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, 448 pem_password_cb *cb, void *u); 449 450 OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey(FILE *fp, const EVP_PKEY *x, 451 const EVP_CIPHER *enc, char *kstr, 452 int klen, pem_password_cb *cd, 453 void *u); 454 455 456 #ifdef __cplusplus 457 } 458 #endif 459 460 #define PEM_R_BAD_BASE64_DECODE 100 461 #define PEM_R_BAD_DECRYPT 101 462 #define PEM_R_BAD_END_LINE 102 463 #define PEM_R_BAD_IV_CHARS 103 464 #define PEM_R_BAD_PASSWORD_READ 104 465 #define PEM_R_CIPHER_IS_NULL 105 466 #define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 106 467 #define PEM_R_NOT_DEK_INFO 107 468 #define PEM_R_NOT_ENCRYPTED 108 469 #define PEM_R_NOT_PROC_TYPE 109 470 #define PEM_R_NO_START_LINE 110 471 #define PEM_R_READ_KEY 111 472 #define PEM_R_SHORT_HEADER 112 473 #define PEM_R_UNSUPPORTED_CIPHER 113 474 #define PEM_R_UNSUPPORTED_ENCRYPTION 114 475 476 #endif // OPENSSL_HEADER_PEM_H 477