pem.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. // pem.h - PEM read and write routines.
  2. // Written and placed in the public domain by Jeffrey Walton
  3. /// \file pem.h
  4. /// \brief Functions to read and write PEM encoded objects
  5. /// \details This is a library add-on. You must download and compile it
  6. /// yourself. Also see <A HREF="http://www.cryptopp.com/wiki/PEM_Pack">PEM
  7. /// Pack</A> on the Crypto++ wiki.
  8. // Why Not Specialize Function Templates?
  9. // http://www.gotw.ca/publications/mill17.htm
  10. /////////////////////////////////////////////////////////////////////////////
  11. #ifndef CRYPTOPP_PEM_H
  12. #define CRYPTOPP_PEM_H
  13. #include "pubkey.h"
  14. #include "eccrypto.h"
  15. #include "gfpcrypt.h"
  16. #include "x509cert.h"
  17. #include "elgamal.h"
  18. #include "rsa.h"
  19. #include "dsa.h"
  20. #include "asn.h"
  21. NAMESPACE_BEGIN(CryptoPP)
  22. /// \brief Get the next PEM object
  23. /// \param src the source BufferedTransformation
  24. /// \param dest the destination BufferedTransformation
  25. /// \returns true if an object was parsed, false otherwise
  26. /// \details PEM_NextObject attempts to retrieve the next PEM encoded key or
  27. /// parameter from <tt>src</tt> and transfers it to <tt>dest</tt>. If there
  28. /// are multiple keys or parameters, then only the first is transferred.
  29. /// \details If <tt>src</tt> is empty then PEM_NextObject() returns false.
  30. /// If <tt>src</tt> holds a partial or malformed object is present then
  31. /// InvalidDataFormat is thrown. The exception is used to distinguish
  32. /// from an empty <tt>src</tt>, and the exception signals the caller to fix
  33. /// <tt>src</tt>.
  34. /// \details PEM_NextObject will parse an invalid object. For example, it
  35. /// will parse a key or parameter with <tt>-----BEGIN FOO-----</tt> and
  36. /// <tt>-----END BAR-----</tt>. The parser only looks for BEGIN and END
  37. /// (and the dashes). The malformed input will be caught later when a
  38. /// particular key or parameter is parsed.
  39. /// \throws InvalidDataFormat
  40. bool PEM_NextObject(BufferedTransformation& src, BufferedTransformation& dest);
  41. /// \brief Recognized PEM types.
  42. /// \details Many PEM types can be read and write, but not all of them.
  43. /// \sa <A HREF="https://stackoverflow.com/questions/5355046">Where is the
  44. /// PEM file format specified?</A>
  45. enum PEM_Type {
  46. /// \brief Public key
  47. /// \details non-specific public key
  48. PEM_PUBLIC_KEY = 1,
  49. /// \brief Private key
  50. /// \details non-specific private key
  51. PEM_PRIVATE_KEY,
  52. /// \brief RSA public key
  53. PEM_RSA_PUBLIC_KEY,
  54. /// \brief RSA private key
  55. PEM_RSA_PRIVATE_KEY,
  56. /// \brief Encrypted RSA private key
  57. PEM_RSA_ENC_PRIVATE_KEY,
  58. /// \brief DSA public key
  59. PEM_DSA_PUBLIC_KEY,
  60. /// \brief DSA private key
  61. PEM_DSA_PRIVATE_KEY,
  62. /// \brief Encrypted DSA private key
  63. PEM_DSA_ENC_PRIVATE_KEY,
  64. /// \brief ElGamal public key
  65. PEM_ELGAMAL_PUBLIC_KEY,
  66. /// \brief ElGamal private key
  67. PEM_ELGAMAL_PRIVATE_KEY,
  68. /// \brief Encrypted ElGamal private key
  69. PEM_ELGAMAL_ENC_PRIVATE_KEY,
  70. /// \brief Elliptic curve public key
  71. /// \details non-specific elliptic curve public key
  72. PEM_EC_PUBLIC_KEY,
  73. /// \brief Elliptic curve private key
  74. /// \details non-specific elliptic curve private key
  75. PEM_EC_PRIVATE_KEY,
  76. /// \brief Encrypted elliptic curve private key
  77. /// \details non-specific encrypted elliptic curve private key
  78. PEM_EC_ENC_PRIVATE_KEY,
  79. /// \brief ECDSA public key
  80. PEM_ECDSA_PUBLIC_KEY,
  81. /// \brief ECDSA private key
  82. PEM_ECDSA_PRIVATE_KEY,
  83. /// \brief Encrypted ECDSA private key
  84. PEM_ENC_ECDSA_PRIVATE_KEY,
  85. /// \brief X25519 public key
  86. PEM_X25519_PUBLIC_KEY,
  87. /// \brief X25519 private key
  88. PEM_X25519_PRIVATE_KEY,
  89. /// \brief Encrypted X25519 private key
  90. PEM_X25519_ENC_PRIVATE_KEY,
  91. /// \brief Elliptic curve parameters
  92. PEM_EC_PARAMETERS,
  93. /// \brief Diffie-Hellman curve parameters
  94. PEM_DH_PARAMETERS,
  95. /// \brief DSA parameters
  96. PEM_DSA_PARAMETERS,
  97. /// \brief X.509 certificate
  98. PEM_X509_CERTIFICATE,
  99. /// \brief Certificate request
  100. PEM_REQ_CERTIFICATE,
  101. /// \brief Certificate
  102. PEM_CERTIFICATE,
  103. /// \brief Unsupported type
  104. PEM_UNSUPPORTED = 0xFFFFFFFF
  105. };
  106. /// \brief Determine the type of key or parameter
  107. /// \param bt the source BufferedTransformation
  108. /// \returns PEM_Type or PEM_UNSUPPORTED
  109. PEM_Type PEM_GetType(const BufferedTransformation& bt);
  110. /////////////////////////////////////////////////////////////////////////////
  111. /// \brief Load a PEM encoded RSA public key
  112. /// \param bt the source BufferedTransformation
  113. /// \param key the RSA public key
  114. /// \throws Exception on failure
  115. void PEM_Load(BufferedTransformation& bt, RSA::PublicKey& key);
  116. /// \brief Load a PEM encoded RSA private key
  117. /// \param bt the source BufferedTransformation
  118. /// \param key the RSA private key
  119. /// \throws Exception on failure
  120. void PEM_Load(BufferedTransformation& bt, RSA::PrivateKey& key);
  121. /// \brief Load a PEM encoded RSA private key
  122. /// \param bt the source BufferedTransformation
  123. /// \param key the RSA private key
  124. /// \param password pointer to the password buffer
  125. /// \param length the size of the password buffer
  126. /// \throws Exception on failure
  127. void PEM_Load(BufferedTransformation& bt, RSA::PrivateKey& key,
  128. const char* password, size_t length);
  129. /// \brief Load a PEM encoded DSA public key
  130. /// \param bt the source BufferedTransformation
  131. /// \param key the DSA public key
  132. /// \throws Exception on failure
  133. void PEM_Load(BufferedTransformation& bt, DSA::PublicKey& key);
  134. /// \brief Load a PEM encoded DSA private key
  135. /// \param bt the source BufferedTransformation
  136. /// \param key the DSA private key
  137. /// \throws Exception on failure
  138. void PEM_Load(BufferedTransformation& bt, DSA::PrivateKey& key);
  139. /// \brief Load a PEM encoded DSA private key
  140. /// \param bt the source BufferedTransformation
  141. /// \param key the DSA private key
  142. /// \param password pointer to the password buffer
  143. /// \param length the size of the password buffer
  144. /// \throws Exception on failure
  145. void PEM_Load(BufferedTransformation& bt, DSA::PrivateKey& key,
  146. const char* password, size_t length);
  147. /// \brief Load a PEM encoded ElGamal public key
  148. /// \param bt the source BufferedTransformation
  149. /// \param key the ElGamal public key
  150. /// \throws Exception on failure
  151. void PEM_Load(BufferedTransformation& bt, ElGamalKeys::PublicKey& key);
  152. /// \brief Load a PEM encoded ElGamal private key
  153. /// \param bt the source BufferedTransformation
  154. /// \param key the ElGamal private key
  155. /// \throws Exception on failure
  156. void PEM_Load(BufferedTransformation& bt, ElGamalKeys::PrivateKey& key);
  157. /// \brief Load a PEM encoded ElGamal private key
  158. /// \param bt the source BufferedTransformation
  159. /// \param key the ElGamal private key
  160. /// \param password pointer to the password buffer
  161. /// \param length the size of the password buffer
  162. /// \throws Exception on failure
  163. void PEM_Load(BufferedTransformation& bt, ElGamalKeys::PrivateKey& key,
  164. const char* password, size_t length);
  165. /// \brief Load a PEM encoded ECP public key
  166. /// \param bt the source BufferedTransformation
  167. /// \param key the ECP public key
  168. /// \throws Exception on failure
  169. void PEM_Load(BufferedTransformation& bt, DL_PublicKey_EC<ECP>& key);
  170. /// \brief Load a PEM encoded ECP private key
  171. /// \param bt the source BufferedTransformation
  172. /// \param key the ECP private key
  173. /// \throws Exception on failure
  174. void PEM_Load(BufferedTransformation& bt, DL_PrivateKey_EC<ECP>& key);
  175. /// \brief Load a PEM encoded ECP private key
  176. /// \param bt the source BufferedTransformation
  177. /// \param key the ECP private key
  178. /// \param password pointer to the password buffer
  179. /// \param length the size of the password buffer
  180. /// \throws Exception on failure
  181. void PEM_Load(BufferedTransformation& bt, DL_PrivateKey_EC<ECP>& key,
  182. const char* password, size_t length);
  183. /// \brief Load a PEM encoded EC2N public key
  184. /// \param bt the source BufferedTransformation
  185. /// \param key the EC2N public key
  186. /// \throws Exception on failure
  187. void PEM_Load(BufferedTransformation& bt, DL_PublicKey_EC<EC2N>& key);
  188. /// \brief Load a PEM encoded EC2N private key
  189. /// \param bt the source BufferedTransformation
  190. /// \param key the EC2N private key
  191. /// \throws Exception on failure
  192. void PEM_Load(BufferedTransformation& bt, DL_PrivateKey_EC<EC2N>& key);
  193. /// \brief Load a PEM encoded EC2N private key
  194. /// \param bt the source BufferedTransformation
  195. /// \param key the EC2N private key
  196. /// \param password pointer to the password buffer
  197. /// \param length the size of the password buffer
  198. /// \throws Exception on failure
  199. void PEM_Load(BufferedTransformation& bt, DL_PrivateKey_EC<EC2N>& key,
  200. const char* password, size_t length);
  201. /// \brief Load a PEM encoded ECDSA private key
  202. /// \param bt the source BufferedTransformation
  203. /// \param key the ECDSA private key
  204. /// \throws Exception on failure
  205. void PEM_Load(BufferedTransformation& bt, DL_Keys_ECDSA<ECP>::PrivateKey& key);
  206. /// \brief Load a PEM encoded ECDSA private key
  207. /// \param bt the source BufferedTransformation
  208. /// \param key the ECDSA private key
  209. /// \param password pointer to the password buffer
  210. /// \param length the size of the password buffer
  211. /// \throws Exception on failure
  212. void PEM_Load(BufferedTransformation& bt, DL_Keys_ECDSA<ECP>::PrivateKey& key,
  213. const char* password, size_t length);
  214. /// \brief Load a PEM encoded ECDSA public key
  215. /// \param bt the source BufferedTransformation
  216. /// \param key the ECDSA public key
  217. /// \throws Exception on failure
  218. void PEM_Load(BufferedTransformation& bt, DL_Keys_ECDSA<EC2N>::PrivateKey& key);
  219. /// \brief Load a PEM encoded ECDSA private key
  220. /// \param bt the source BufferedTransformation
  221. /// \param key the ECDSA private key
  222. /// \param password pointer to the password buffer
  223. /// \param length the size of the password buffer
  224. /// \throws Exception on failure
  225. void PEM_Load(BufferedTransformation& bt, DL_Keys_ECDSA<EC2N>::PrivateKey& key,
  226. const char* password, size_t length);
  227. /// \brief Load a PEM encoded DSA group parameters
  228. /// \param bt the source BufferedTransformation
  229. /// \param params the DSA group parameters
  230. /// \throws Exception on failure
  231. void PEM_Load(BufferedTransformation& bt, DL_GroupParameters_DSA& params);
  232. /// \brief Load a PEM encoded ECP group parameters
  233. /// \param bt the source BufferedTransformation
  234. /// \param params the ECP group parameters
  235. /// \throws Exception on failure
  236. void PEM_Load(BufferedTransformation& bt, DL_GroupParameters_EC<ECP>& params);
  237. /// \brief Load a PEM encoded EC2N group parameters
  238. /// \param bt the source BufferedTransformation
  239. /// \param params the EC2N group parameters
  240. /// \throws Exception on failure
  241. void PEM_Load(BufferedTransformation& bt, DL_GroupParameters_EC<EC2N>& params);
  242. /// \brief Load a PEM encoded X.509 certificate
  243. /// \param bt the source BufferedTransformation
  244. /// \param cert the X.509 certificate
  245. /// \throws Exception on failure
  246. void PEM_Load(BufferedTransformation& bt, X509Certificate& cert);
  247. /// \brief Load a PEM encoded Diffie-Hellman parameters
  248. /// \param bt the source BufferedTransformation
  249. /// \param p the prime modulus
  250. /// \param g the group generator
  251. /// \throws Exception on failure
  252. void PEM_DH_Load(BufferedTransformation& bt, Integer& p, Integer& g);
  253. /// \brief Load a PEM encoded Diffie-Hellman parameters
  254. /// \param bt the source BufferedTransformation
  255. /// \param p the prime modulus
  256. /// \param q the subgroup order
  257. /// \param g the group generator
  258. /// \throws Exception on failure
  259. void PEM_DH_Load(BufferedTransformation& bt, Integer& p, Integer& q, Integer& g);
  260. /////////////////////////////////////////////////////////////////////////////
  261. // Begin the Write routines. The write routines always write the "named curve"
  262. // (i.e., the OID of secp256k1) rather than the domain parameters. This is
  263. // because RFC 5915 specifies the format. In addition, OpenSSL cannot load and
  264. // utilize an EC key with a non-named curve into a server. For encrpted private
  265. // keys, the algorithm should be a value like `AES-128-CBC`. See pem_read.cpp
  266. // and pem_write.cpp for the values that are recognized. On failure, any number
  267. // of Crypto++ exceptions are thrown. No custom exceptions are thrown.
  268. /// \brief Save a PEM encoded RSA public key
  269. /// \param bt the destination BufferedTransformation
  270. /// \param key the RSA public key
  271. /// \throws Exception on failure
  272. void PEM_Save(BufferedTransformation& bt, const RSA::PublicKey& key);
  273. /// \brief Save a PEM encoded RSA private key
  274. /// \param bt the destination BufferedTransformation
  275. /// \param key the RSA private key
  276. /// \throws Exception on failure
  277. void PEM_Save(BufferedTransformation& bt, const RSA::PrivateKey& key);
  278. /// \brief Save a PEM encoded RSA private key
  279. /// \param bt the destination BufferedTransformation
  280. /// \param rng a RandomNumberGenerator to produce an initialization vector
  281. /// \param key the RSA private key
  282. /// \param algorithm the encryption algorithm
  283. /// \param password pointer to the password buffer
  284. /// \param length the size of the password buffer
  285. /// \details The algorithm should be a value like <tt>AES-128-CBC</tt>. See
  286. /// <tt>pem_read.cpp</tt> and <tt>pem_write.cpp</tt> for the values that are
  287. /// recognized.
  288. /// \throws Exception on failure
  289. void PEM_Save(BufferedTransformation& bt, const RSA::PrivateKey& key,
  290. RandomNumberGenerator& rng, const std::string& algorithm,
  291. const char* password, size_t length);
  292. /// \brief Save a PEM encoded DSA public key
  293. /// \param bt the destination BufferedTransformation
  294. /// \param key the DSA public key
  295. /// \throws Exception on failure
  296. void PEM_Save(BufferedTransformation& bt, const DSA::PublicKey& key);
  297. /// \brief Save a PEM encoded DSA private key
  298. /// \param bt the destination BufferedTransformation
  299. /// \param key the DSA private key
  300. /// \throws Exception on failure
  301. void PEM_Save(BufferedTransformation& bt, const DSA::PrivateKey& key);
  302. /// \brief Save a PEM encoded DSA private key
  303. /// \param bt the destination BufferedTransformation
  304. /// \param rng a RandomNumberGenerator to produce an initialization vector
  305. /// \param key the DSA private key
  306. /// \param algorithm the encryption algorithm
  307. /// \param password pointer to the password buffer
  308. /// \param length the size of the password buffer
  309. /// \details The algorithm should be a value like <tt>AES-128-CBC</tt>. See
  310. /// <tt>pem_read.cpp</tt> and <tt>pem_write.cpp</tt> for the values that are
  311. /// recognized.
  312. /// \throws Exception on failure
  313. void PEM_Save(BufferedTransformation& bt, const DSA::PrivateKey& key,
  314. RandomNumberGenerator& rng, const std::string& algorithm,
  315. const char* password, size_t length);
  316. /// \brief Save a PEM encoded ElGamal public key
  317. /// \param bt the destination BufferedTransformation
  318. /// \param key the ElGamal public key
  319. /// \throws Exception on failure
  320. void PEM_Save(BufferedTransformation& bt, const ElGamalKeys::PublicKey& key);
  321. /// \brief Save a PEM encoded ElGamal private key
  322. /// \param bt the destination BufferedTransformation
  323. /// \param key the ElGamal private key
  324. /// \throws Exception on failure
  325. void PEM_Save(BufferedTransformation& bt, const ElGamalKeys::PrivateKey& key);
  326. /// \brief Save a PEM encoded ElGamal private key
  327. /// \param bt the destination BufferedTransformation
  328. /// \param rng a RandomNumberGenerator to produce an initialization vector
  329. /// \param key the ElGamal private key
  330. /// \param algorithm the encryption algorithm
  331. /// \param password pointer to the password buffer
  332. /// \param length the size of the password buffer
  333. /// \details The algorithm should be a value like <tt>AES-128-CBC</tt>. See
  334. /// <tt>pem_read.cpp</tt> and <tt>pem_write.cpp</tt> for the values that are
  335. /// recognized.
  336. /// \throws Exception on failure
  337. void PEM_Save(BufferedTransformation& bt, const ElGamalKeys::PrivateKey& key,
  338. RandomNumberGenerator& rng, const std::string& algorithm,
  339. const char* password, size_t length);
  340. /// \brief Save a PEM encoded ECP public key
  341. /// \param bt the destination BufferedTransformation
  342. /// \param key the ECP public key
  343. /// \throws Exception on failure
  344. void PEM_Save(BufferedTransformation& bt, const DL_PublicKey_EC<ECP>& key);
  345. /// \brief Save a PEM encoded ECP private key
  346. /// \param bt the destination BufferedTransformation
  347. /// \param key the ECP private key
  348. /// \throws Exception on failure
  349. void PEM_Save(BufferedTransformation& bt, const DL_PrivateKey_EC<ECP>& key);
  350. /// \brief Save a PEM encoded ECP private key
  351. /// \param bt the destination BufferedTransformation
  352. /// \param rng a RandomNumberGenerator to produce an initialization vector
  353. /// \param key the ECP private key
  354. /// \param algorithm the encryption algorithm
  355. /// \param password pointer to the password buffer
  356. /// \param length the size of the password buffer
  357. /// \details The algorithm should be a value like <tt>AES-128-CBC</tt>. See
  358. /// <tt>pem_read.cpp</tt> and <tt>pem_write.cpp</tt> for the values that are
  359. /// recognized.
  360. /// \details The "named curve" (i.e., the OID of secp256k1) is used rather
  361. /// than the domain parameters. This is because RFC 5915 specifies the format.
  362. /// In addition, OpenSSL cannot load and utilize an EC key with a non-named
  363. /// curve into a server.
  364. /// \throws Exception on failure
  365. void PEM_Save(BufferedTransformation& bt, const DL_PrivateKey_EC<ECP>& key,
  366. RandomNumberGenerator& rng, const std::string& algorithm,
  367. const char* password, size_t length);
  368. /// \brief Save a PEM encoded EC2N public key
  369. /// \param bt the destination BufferedTransformation
  370. /// \param key the EC2N public key
  371. /// \throws Exception on failure
  372. void PEM_Save(BufferedTransformation& bt, const DL_PublicKey_EC<EC2N>& key);
  373. /// \brief Save a PEM encoded EC2N private key
  374. /// \param bt the destination BufferedTransformation
  375. /// \param key the EC2N private key
  376. /// \throws Exception on failure
  377. void PEM_Save(BufferedTransformation& bt, const DL_PrivateKey_EC<EC2N>& key);
  378. /// \brief Save a PEM encoded EC2N private key
  379. /// \param bt the destination BufferedTransformation
  380. /// \param rng a RandomNumberGenerator to produce an initialization vector
  381. /// \param key the EC2N private key
  382. /// \param algorithm the encryption algorithm
  383. /// \param password pointer to the password buffer
  384. /// \param length the size of the password buffer
  385. /// \details The algorithm should be a value like <tt>AES-128-CBC</tt>. See
  386. /// <tt>pem_read.cpp</tt> and <tt>pem_write.cpp</tt> for the values that are
  387. /// recognized.
  388. /// \details The "named curve" (i.e., the OID of secp256k1) is used rather than
  389. /// the domain parameters. This is because RFC 5915 specifies the format. In
  390. /// addition, OpenSSL cannot load and utilize an EC key with a non-named curve
  391. /// into a server.
  392. /// \throws Exception on failure
  393. void PEM_Save(BufferedTransformation& bt, const DL_PrivateKey_EC<EC2N>& key,
  394. RandomNumberGenerator& rng, const std::string& algorithm,
  395. const char* password, size_t length);
  396. /// \brief Save a PEM encoded ECDSA private key
  397. /// \param bt the destination BufferedTransformation
  398. /// \param key the ECDSA private key
  399. /// \throws Exception on failure
  400. void PEM_Save(BufferedTransformation& bt, const DL_Keys_ECDSA<ECP>::PrivateKey& key);
  401. /// \brief Save a PEM encoded ECDSA private key
  402. /// \param bt the destination BufferedTransformation
  403. /// \param rng a RandomNumberGenerator to produce an initialization vector
  404. /// \param key the ECDSA private key
  405. /// \param algorithm the encryption algorithm
  406. /// \param password pointer to the password buffer
  407. /// \param length the size of the password buffer
  408. /// \details The algorithm should be a value like <tt>AES-128-CBC</tt>. See
  409. /// <tt>pem_read.cpp</tt> and <tt>pem_write.cpp</tt> for the values that
  410. /// are recognized.
  411. /// \details The "named curve" (i.e., the OID of secp256k1) is used rather
  412. /// than the domain parameters. This is because RFC 5915 specifies the format.
  413. /// In addition, OpenSSL cannot load and utilize an EC key with a non-named
  414. /// curve into a server.
  415. /// \throws Exception on failure
  416. void PEM_Save(BufferedTransformation& bt, const DL_Keys_ECDSA<ECP>::PrivateKey& key,
  417. RandomNumberGenerator& rng, const std::string& algorithm,
  418. const char* password, size_t length);
  419. /// \brief Save a PEM encoded DSA group parameters
  420. /// \param bt the destination BufferedTransformation
  421. /// \param params the DSA group parameters
  422. /// \throws Exception on failure
  423. void PEM_Save(BufferedTransformation& bt, const DL_GroupParameters_DSA& params);
  424. /// \brief Save a PEM encoded ECP group parameters
  425. /// \param bt the destination BufferedTransformation
  426. /// \param params the ECP group parameters
  427. /// \throws Exception on failure
  428. void PEM_Save(BufferedTransformation& bt, const DL_GroupParameters_EC<ECP>& params);
  429. /// \brief Save a PEM encoded EC2N group parameters
  430. /// \param bt the destination BufferedTransformation
  431. /// \param params the EC2N group parameters
  432. /// \throws Exception on failure
  433. void PEM_Save(BufferedTransformation& bt, const DL_GroupParameters_EC<EC2N>& params);
  434. /// \brief Save a PEM encoded X.509 certificate
  435. /// \param bt the destination BufferedTransformation
  436. /// \param cert the X.509 certificate
  437. /// \throws Exception on failure
  438. void PEM_Save(BufferedTransformation& bt, const X509Certificate& cert);
  439. /// \brief Save a PEM encoded Diffie-Hellman parameters
  440. /// \param bt the destination BufferedTransformation
  441. /// \param p the prime modulus
  442. /// \param g the group generator
  443. /// \throws Exception on failure
  444. void PEM_DH_Save(BufferedTransformation& bt, const Integer& p, const Integer& g);
  445. /// \brief Save a PEM encoded Diffie-Hellman parameters
  446. /// \param bt the destination BufferedTransformation
  447. /// \param p the prime modulus
  448. /// \param q the subgroup order
  449. /// \param g the group generator
  450. /// \throws Exception on failure
  451. void PEM_DH_Save(BufferedTransformation& bt, const Integer& p, const Integer& q, const Integer& g);
  452. NAMESPACE_END
  453. #endif