Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

436 linhas
20 KiB

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