summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-02-17 15:11:56 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-02-17 15:12:36 +0100
commit18109f3a0fe949e4547cce2060ba33d7444b6520 (patch)
tree236db187468be213d04d1ed564c547a77f2d9a1e
parentadd0403a5af97ca7b54437ee745a3ba7f52cf847 (diff)
openpgp: Support CAST5.
- Fixes #193.
-rw-r--r--openpgp/src/crypto/symmetric.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/openpgp/src/crypto/symmetric.rs b/openpgp/src/crypto/symmetric.rs
index 0d24b0c3..1d18efc9 100644
--- a/openpgp/src/crypto/symmetric.rs
+++ b/openpgp/src/crypto/symmetric.rs
@@ -21,6 +21,7 @@ impl SymmetricAlgorithm {
use nettle::cipher;
match self {
SymmetricAlgorithm::TripleDES => Ok(cipher::Des3::KEY_SIZE),
+ SymmetricAlgorithm::CAST5 => Ok(cipher::Cast128::KEY_SIZE),
SymmetricAlgorithm::Blowfish => Ok(cipher::Blowfish::KEY_SIZE),
SymmetricAlgorithm::AES128 => Ok(cipher::Aes128::KEY_SIZE),
SymmetricAlgorithm::AES192 => Ok(cipher::Aes192::KEY_SIZE),
@@ -39,6 +40,7 @@ impl SymmetricAlgorithm {
use nettle::cipher;
match self {
SymmetricAlgorithm::TripleDES => Ok(cipher::Des3::BLOCK_SIZE),
+ SymmetricAlgorithm::CAST5 => Ok(cipher::Cast128::BLOCK_SIZE),
SymmetricAlgorithm::Blowfish => Ok(cipher::Blowfish::BLOCK_SIZE),
SymmetricAlgorithm::AES128 => Ok(cipher::Aes128::BLOCK_SIZE),
SymmetricAlgorithm::AES192 => Ok(cipher::Aes192::BLOCK_SIZE),
@@ -58,6 +60,9 @@ impl SymmetricAlgorithm {
SymmetricAlgorithm::TripleDES =>
Ok(Box::new(
mode::Cfb::<cipher::Des3>::with_encrypt_key(&key[..])?)),
+ SymmetricAlgorithm::CAST5 =>
+ Ok(Box::new(
+ mode::Cfb::<cipher::Cast128>::with_encrypt_key(&key[..])?)),
SymmetricAlgorithm::Blowfish =>
Ok(Box::new(
mode::Cfb::<cipher::Blowfish>::with_encrypt_key(&key[..])?)),
@@ -93,6 +98,9 @@ impl SymmetricAlgorithm {
SymmetricAlgorithm::TripleDES =>
Ok(Box::new(
mode::Cfb::<cipher::Des3>::with_decrypt_key(&key[..])?)),
+ SymmetricAlgorithm::CAST5 =>
+ Ok(Box::new(
+ mode::Cfb::<cipher::Cast128>::with_decrypt_key(&key[..])?)),
SymmetricAlgorithm::Blowfish =>
Ok(Box::new(
mode::Cfb::<cipher::Blowfish>::with_decrypt_key(&key[..])?)),
@@ -592,6 +600,7 @@ mod tests {
let mut rng = Yarrow::default();
for algo in [SymmetricAlgorithm::TripleDES,
+ SymmetricAlgorithm::CAST5,
SymmetricAlgorithm::Blowfish,
SymmetricAlgorithm::AES128,
SymmetricAlgorithm::AES192,