diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-05-15 15:43:36 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-05-15 15:45:30 +0200 |
commit | 0e655002843c2754f2e24773d8117499a8b30a54 (patch) | |
tree | af68b488de46650f292f3a32cceaa0d66458209a | |
parent | 9853283156cdfaa3bb6556d36a3a0c98a6bca244 (diff) |
openpgp: Support generating 2k RSA keys
-rw-r--r-- | openpgp-ffi/include/sequoia/openpgp/types.h | 5 | ||||
-rw-r--r-- | openpgp-ffi/src/tpk.rs | 1 | ||||
-rw-r--r-- | openpgp/src/tpk/builder.rs | 6 |
3 files changed, 11 insertions, 1 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp/types.h b/openpgp-ffi/include/sequoia/openpgp/types.h index 40c926d0..42dfb727 100644 --- a/openpgp-ffi/include/sequoia/openpgp/types.h +++ b/openpgp-ffi/include/sequoia/openpgp/types.h @@ -430,6 +430,11 @@ typedef enum pgp_tpk_cipher_suite { /*/ PGP_TPK_CIPHER_SUITE_P521, + /*/ + /// 2048 bit RSA with SHA512 and AES256. + /*/ + PGP_TPK_CIPHER_SUITE_RSA2K, + /* Dummy value to make sure the enumeration has a defined size. Do not use this value. */ PGP_TPK_CIPHER_SUITE_FORCE_WIDTH = INT_MAX, diff --git a/openpgp-ffi/src/tpk.rs b/openpgp-ffi/src/tpk.rs index c8b70618..259b3a1c 100644 --- a/openpgp-ffi/src/tpk.rs +++ b/openpgp-ffi/src/tpk.rs @@ -845,6 +845,7 @@ fn int_to_cipher_suite(cs: c_int) -> CipherSuite { 2 => P256, 3 => P384, 4 => P521, + 5 => RSA2k, n => panic!("Bad ciphersuite: {}", n), } } diff --git a/openpgp/src/tpk/builder.rs b/openpgp/src/tpk/builder.rs index 912ca97d..f824309c 100644 --- a/openpgp/src/tpk/builder.rs +++ b/openpgp/src/tpk/builder.rs @@ -31,6 +31,8 @@ pub enum CipherSuite { P384, /// EdDSA and ECDH over NIST P-521 with SHA512 and AES256 P521, + /// 2048 bit RSA with SHA512 and AES256 + RSA2k, } impl Default for CipherSuite { @@ -44,6 +46,8 @@ impl CipherSuite { use constants::Curve; match self { + CipherSuite::RSA2k => + Key4::generate_rsa(2048), CipherSuite::RSA3k => Key4::generate_rsa(3072), CipherSuite::Cv25519 | CipherSuite::P256 | @@ -572,7 +576,7 @@ mod tests { fn all_ciphersuites() { use self::CipherSuite::*; - for cs in vec![Cv25519, RSA3k, P256, P384, P521] { + for cs in vec![Cv25519, RSA3k, P256, P384, P521, RSA2k] { assert!(TPKBuilder::new() .set_cipher_suite(cs) .generate().is_ok()); |