You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

546 rivejä
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/x509.h>
  65. #ifdef __cplusplus
  66. extern "C" {
  67. #endif
  68. #define PEM_BUFSIZE 1024
  69. #define PEM_OBJ_UNDEF 0
  70. #define PEM_OBJ_X509 1
  71. #define PEM_OBJ_X509_REQ 2
  72. #define PEM_OBJ_CRL 3
  73. #define PEM_OBJ_SSL_SESSION 4
  74. #define PEM_OBJ_PRIV_KEY 10
  75. #define PEM_OBJ_PRIV_RSA 11
  76. #define PEM_OBJ_PRIV_DSA 12
  77. #define PEM_OBJ_PRIV_DH 13
  78. #define PEM_OBJ_PUB_RSA 14
  79. #define PEM_OBJ_PUB_DSA 15
  80. #define PEM_OBJ_PUB_DH 16
  81. #define PEM_OBJ_DHPARAMS 17
  82. #define PEM_OBJ_DSAPARAMS 18
  83. #define PEM_OBJ_PRIV_RSA_PUBLIC 19
  84. #define PEM_OBJ_PRIV_ECDSA 20
  85. #define PEM_OBJ_PUB_ECDSA 21
  86. #define PEM_OBJ_ECPARAMETERS 22
  87. #define PEM_ERROR 30
  88. #define PEM_DEK_DES_CBC 40
  89. #define PEM_DEK_IDEA_CBC 45
  90. #define PEM_DEK_DES_EDE 50
  91. #define PEM_DEK_DES_ECB 60
  92. #define PEM_DEK_RSA 70
  93. #define PEM_DEK_RSA_MD2 80
  94. #define PEM_DEK_RSA_MD5 90
  95. #define PEM_MD_MD2 NID_md2
  96. #define PEM_MD_MD5 NID_md5
  97. #define PEM_MD_SHA NID_sha
  98. #define PEM_MD_MD2_RSA NID_md2WithRSAEncryption
  99. #define PEM_MD_MD5_RSA NID_md5WithRSAEncryption
  100. #define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption
  101. #define PEM_STRING_X509_OLD "X509 CERTIFICATE"
  102. #define PEM_STRING_X509 "CERTIFICATE"
  103. #define PEM_STRING_X509_PAIR "CERTIFICATE PAIR"
  104. #define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
  105. #define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
  106. #define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
  107. #define PEM_STRING_X509_CRL "X509 CRL"
  108. #define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"
  109. #define PEM_STRING_PUBLIC "PUBLIC KEY"
  110. #define PEM_STRING_RSA "RSA PRIVATE KEY"
  111. #define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
  112. #define PEM_STRING_DSA "DSA PRIVATE KEY"
  113. #define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
  114. #define PEM_STRING_PKCS7 "PKCS7"
  115. #define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
  116. #define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
  117. #define PEM_STRING_PKCS8INF "PRIVATE KEY"
  118. #define PEM_STRING_DHPARAMS "DH PARAMETERS"
  119. #define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS"
  120. #define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
  121. #define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
  122. #define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
  123. #define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
  124. #define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
  125. #define PEM_STRING_PARAMETERS "PARAMETERS"
  126. #define PEM_STRING_CMS "CMS"
  127. /* Note that this structure is initialised by PEM_SealInit and cleaned up
  128. by PEM_SealFinal (at least for now) */
  129. typedef struct PEM_Encode_Seal_st
  130. {
  131. EVP_ENCODE_CTX encode;
  132. EVP_MD_CTX md;
  133. EVP_CIPHER_CTX cipher;
  134. } PEM_ENCODE_SEAL_CTX;
  135. /* enc_type is one off */
  136. #define PEM_TYPE_ENCRYPTED 10
  137. #define PEM_TYPE_MIC_ONLY 20
  138. #define PEM_TYPE_MIC_CLEAR 30
  139. #define PEM_TYPE_CLEAR 40
  140. typedef struct pem_recip_st
  141. {
  142. char *name;
  143. X509_NAME *dn;
  144. int cipher;
  145. int key_enc;
  146. /* char iv[8]; unused and wrong size */
  147. } PEM_USER;
  148. typedef struct pem_ctx_st
  149. {
  150. int type; /* what type of object */
  151. struct {
  152. int version;
  153. int mode;
  154. } proc_type;
  155. char *domain;
  156. struct {
  157. int cipher;
  158. /* unused, and wrong size
  159. unsigned char iv[8]; */
  160. } DEK_info;
  161. PEM_USER *originator;
  162. int num_recipient;
  163. PEM_USER **recipient;
  164. EVP_MD *md; /* signature type */
  165. int md_enc; /* is the md encrypted or not? */
  166. int md_len; /* length of md_data */
  167. char *md_data; /* message digest, could be pkey encrypted */
  168. EVP_CIPHER *dec; /* date encryption cipher */
  169. int key_len; /* key length */
  170. unsigned char *key; /* key */
  171. /* unused, and wrong size
  172. unsigned char iv[8]; */
  173. int data_enc; /* is the data encrypted */
  174. int data_len;
  175. unsigned char *data;
  176. } PEM_CTX;
  177. /* These macros make the PEM_read/PEM_write functions easier to maintain and
  178. * write. Now they are all implemented with either:
  179. * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...)
  180. */
  181. #ifdef OPENSSL_NO_FP_API
  182. #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/
  183. #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/
  184. #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/
  185. #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/
  186. #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/
  187. #else
  188. #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
  189. OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
  190. { \
  191. return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \
  192. }
  193. #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
  194. OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x) \
  195. { \
  196. return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \
  197. }
  198. #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
  199. OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x) \
  200. { \
  201. return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \
  202. }
  203. #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
  204. OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
  205. unsigned char *kstr, int klen, pem_password_cb *cb, \
  206. void *u) \
  207. { \
  208. return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
  209. }
  210. #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
  211. OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
  212. unsigned char *kstr, int klen, pem_password_cb *cb, \
  213. void *u) \
  214. { \
  215. return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
  216. }
  217. #endif
  218. #define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
  219. OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
  220. { \
  221. return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \
  222. }
  223. #define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
  224. OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x) \
  225. { \
  226. return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \
  227. }
  228. #define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
  229. OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x) \
  230. { \
  231. return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \
  232. }
  233. #define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
  234. OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
  235. unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
  236. { \
  237. return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \
  238. }
  239. #define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
  240. OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
  241. unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
  242. { \
  243. return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \
  244. }
  245. #define IMPLEMENT_PEM_write(name, type, str, asn1) \
  246. IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
  247. IMPLEMENT_PEM_write_fp(name, type, str, asn1)
  248. #define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
  249. IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
  250. IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
  251. #define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
  252. IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
  253. IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
  254. #define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
  255. IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
  256. IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
  257. #define IMPLEMENT_PEM_read(name, type, str, asn1) \
  258. IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
  259. IMPLEMENT_PEM_read_fp(name, type, str, asn1)
  260. #define IMPLEMENT_PEM_rw(name, type, str, asn1) \
  261. IMPLEMENT_PEM_read(name, type, str, asn1) \
  262. IMPLEMENT_PEM_write(name, type, str, asn1)
  263. #define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
  264. IMPLEMENT_PEM_read(name, type, str, asn1) \
  265. IMPLEMENT_PEM_write_const(name, type, str, asn1)
  266. #define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
  267. IMPLEMENT_PEM_read(name, type, str, asn1) \
  268. IMPLEMENT_PEM_write_cb(name, type, str, asn1)
  269. /* These are the same except they are for the declarations */
  270. #if defined(OPENSSL_NO_FP_API)
  271. #define DECLARE_PEM_read_fp(name, type) /**/
  272. #define DECLARE_PEM_write_fp(name, type) /**/
  273. #define DECLARE_PEM_write_cb_fp(name, type) /**/
  274. #else
  275. #define DECLARE_PEM_read_fp(name, type) \
  276. OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);
  277. #define DECLARE_PEM_write_fp(name, type) \
  278. OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x);
  279. #define DECLARE_PEM_write_fp_const(name, type) \
  280. OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x);
  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. #endif
  285. #define DECLARE_PEM_read_bio(name, type) \
  286. OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);
  287. #define DECLARE_PEM_write_bio(name, type) \
  288. OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x);
  289. #define DECLARE_PEM_write_bio_const(name, type) \
  290. OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x);
  291. #define DECLARE_PEM_write_cb_bio(name, type) \
  292. OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
  293. unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
  294. #define DECLARE_PEM_write(name, type) \
  295. DECLARE_PEM_write_bio(name, type) \
  296. DECLARE_PEM_write_fp(name, type)
  297. #define DECLARE_PEM_write_const(name, type) \
  298. DECLARE_PEM_write_bio_const(name, type) \
  299. DECLARE_PEM_write_fp_const(name, type)
  300. #define DECLARE_PEM_write_cb(name, type) \
  301. DECLARE_PEM_write_cb_bio(name, type) \
  302. DECLARE_PEM_write_cb_fp(name, type)
  303. #define DECLARE_PEM_read(name, type) \
  304. DECLARE_PEM_read_bio(name, type) \
  305. DECLARE_PEM_read_fp(name, type)
  306. #define DECLARE_PEM_rw(name, type) \
  307. DECLARE_PEM_read(name, type) \
  308. DECLARE_PEM_write(name, type)
  309. #define DECLARE_PEM_rw_const(name, type) \
  310. DECLARE_PEM_read(name, type) \
  311. DECLARE_PEM_write_const(name, type)
  312. #define DECLARE_PEM_rw_cb(name, type) \
  313. DECLARE_PEM_read(name, type) \
  314. DECLARE_PEM_write_cb(name, type)
  315. #if 1
  316. /* "userdata": new with OpenSSL 0.9.4 */
  317. typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);
  318. #else
  319. /* OpenSSL 0.9.3, 0.9.3a */
  320. typedef int pem_password_cb(char *buf, int size, int rwflag);
  321. #endif
  322. OPENSSL_EXPORT int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
  323. OPENSSL_EXPORT int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, pem_password_cb *callback,void *u);
  324. OPENSSL_EXPORT int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data,long *len);
  325. OPENSSL_EXPORT int PEM_write_bio(BIO *bp,const char *name, const char *hdr, const unsigned char *data, long len);
  326. 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);
  327. OPENSSL_EXPORT void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, pem_password_cb *cb, void *u);
  328. 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);
  329. OPENSSL_EXPORT STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
  330. 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);
  331. OPENSSL_EXPORT int PEM_read(FILE *fp, char **name, char **header, unsigned char **data,long *len);
  332. OPENSSL_EXPORT int PEM_write(FILE *fp, const char *name, const char *hdr, const unsigned char *data, long len);
  333. OPENSSL_EXPORT void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, pem_password_cb *cb, void *u);
  334. 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);
  335. OPENSSL_EXPORT STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
  336. OPENSSL_EXPORT int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type, unsigned char **ek, int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk);
  337. OPENSSL_EXPORT void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, unsigned char *in, int inl);
  338. OPENSSL_EXPORT int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl, unsigned char *out, int *outl, EVP_PKEY *priv);
  339. OPENSSL_EXPORT void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
  340. OPENSSL_EXPORT void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
  341. OPENSSL_EXPORT int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, EVP_PKEY *pkey);
  342. OPENSSL_EXPORT int PEM_def_callback(char *buf, int num, int w, void *key);
  343. OPENSSL_EXPORT void PEM_proc_type(char *buf, int type);
  344. OPENSSL_EXPORT void PEM_dek_info(char *buf, const char *type, int len, char *str);
  345. DECLARE_PEM_rw(X509, X509)
  346. DECLARE_PEM_rw(X509_AUX, X509)
  347. DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR)
  348. DECLARE_PEM_rw(X509_REQ, X509_REQ)
  349. DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
  350. DECLARE_PEM_rw(X509_CRL, X509_CRL)
  351. /* DECLARE_PEM_rw(PKCS7, PKCS7) */
  352. DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
  353. DECLARE_PEM_rw(PKCS8, X509_SIG)
  354. DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
  355. DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
  356. DECLARE_PEM_rw_const(RSAPublicKey, RSA)
  357. DECLARE_PEM_rw(RSA_PUBKEY, RSA)
  358. #ifndef OPENSSL_NO_DSA
  359. DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
  360. DECLARE_PEM_rw(DSA_PUBKEY, DSA)
  361. DECLARE_PEM_rw_const(DSAparams, DSA)
  362. #endif
  363. DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)
  364. DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
  365. DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
  366. DECLARE_PEM_rw_const(DHparams, DH)
  367. DECLARE_PEM_write_const(DHxparams, DH)
  368. DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
  369. DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
  370. 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);
  371. OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, char *, int, pem_password_cb *, void *);
  372. 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);
  373. OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u);
  374. OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
  375. 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);
  376. OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u);
  377. OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u);
  378. OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
  379. 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);
  380. OPENSSL_EXPORT EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
  381. OPENSSL_EXPORT int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
  382. OPENSSL_EXPORT EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
  383. OPENSSL_EXPORT EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
  384. OPENSSL_EXPORT EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
  385. OPENSSL_EXPORT EVP_PKEY *b2i_PublicKey_bio(BIO *in);
  386. OPENSSL_EXPORT int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);
  387. OPENSSL_EXPORT int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);
  388. OPENSSL_EXPORT EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
  389. OPENSSL_EXPORT int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel, pem_password_cb *cb, void *u);
  390. void ERR_load_PEM_strings(void);
  391. #ifdef __cplusplus
  392. }
  393. #endif
  394. #define PEM_F_PEM_ASN1_read 100
  395. #define PEM_F_PEM_ASN1_read_bio 101
  396. #define PEM_F_PEM_ASN1_write 102
  397. #define PEM_F_PEM_ASN1_write_bio 103
  398. #define PEM_F_PEM_X509_INFO_read 104
  399. #define PEM_F_PEM_X509_INFO_read_bio 105
  400. #define PEM_F_PEM_X509_INFO_write_bio 106
  401. #define PEM_F_PEM_do_header 107
  402. #define PEM_F_PEM_get_EVP_CIPHER_INFO 108
  403. #define PEM_F_PEM_read 109
  404. #define PEM_F_PEM_read_DHparams 110
  405. #define PEM_F_PEM_read_PrivateKey 111
  406. #define PEM_F_PEM_read_bio 112
  407. #define PEM_F_PEM_read_bio_DHparams 113
  408. #define PEM_F_PEM_read_bio_Parameters 114
  409. #define PEM_F_PEM_read_bio_PrivateKey 115
  410. #define PEM_F_PEM_write 116
  411. #define PEM_F_PEM_write_PrivateKey 117
  412. #define PEM_F_PEM_write_bio 118
  413. #define PEM_F_d2i_PKCS8PrivateKey_bio 119
  414. #define PEM_F_d2i_PKCS8PrivateKey_fp 120
  415. #define PEM_F_do_pk8pkey 121
  416. #define PEM_F_do_pk8pkey_fp 122
  417. #define PEM_F_load_iv 123
  418. #define PEM_R_BAD_BASE64_DECODE 100
  419. #define PEM_R_BAD_DECRYPT 101
  420. #define PEM_R_BAD_END_LINE 102
  421. #define PEM_R_BAD_IV_CHARS 103
  422. #define PEM_R_BAD_PASSWORD_READ 104
  423. #define PEM_R_CIPHER_IS_NULL 105
  424. #define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 106
  425. #define PEM_R_NOT_DEK_INFO 107
  426. #define PEM_R_NOT_ENCRYPTED 108
  427. #define PEM_R_NOT_PROC_TYPE 109
  428. #define PEM_R_NO_START_LINE 110
  429. #define PEM_R_READ_KEY 111
  430. #define PEM_R_SHORT_HEADER 112
  431. #define PEM_R_UNSUPPORTED_CIPHER 113
  432. #define PEM_R_UNSUPPORTED_ENCRYPTION 114
  433. #endif /* OPENSSL_HEADER_PEM_H */