diff options
author | Kai Michaelis <kai@sequoia-pgp.org> | 2019-02-13 14:26:12 +0100 |
---|---|---|
committer | Kai Michaelis <kai@sequoia-pgp.org> | 2019-02-13 19:23:42 +0100 |
commit | 91bda43cc807917a585d7cf33e708e37a726433c (patch) | |
tree | 67d8fc3077aa605ac53917ad292d1d4bb6bbdf0c /openpgp/src/crypto | |
parent | ca912da838bca40a2e008264a2c8c339a62df483 (diff) |
openpgp: use nettle 4.0
Diffstat (limited to 'openpgp/src/crypto')
-rw-r--r-- | openpgp/src/crypto/aead.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/asymmetric.rs | 8 | ||||
-rw-r--r-- | openpgp/src/crypto/ecdh.rs | 6 | ||||
-rw-r--r-- | openpgp/src/crypto/mod.rs | 3 | ||||
-rw-r--r-- | openpgp/src/crypto/s2k.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/symmetric.rs | 2 |
6 files changed, 12 insertions, 11 deletions
diff --git a/openpgp/src/crypto/aead.rs b/openpgp/src/crypto/aead.rs index 33227997..b791e2b4 100644 --- a/openpgp/src/crypto/aead.rs +++ b/openpgp/src/crypto/aead.rs @@ -758,7 +758,7 @@ mod tests { #[test] fn roundtrip() { use std::io::Cursor; - use nettle::Yarrow; + use nettle::{Random, Yarrow}; let mut rng = Yarrow::default(); for cipher in [SymmetricAlgorithm::AES128, diff --git a/openpgp/src/crypto/asymmetric.rs b/openpgp/src/crypto/asymmetric.rs index b779176a..06eaf0ba 100644 --- a/openpgp/src/crypto/asymmetric.rs +++ b/openpgp/src/crypto/asymmetric.rs @@ -1,6 +1,6 @@ //! Asymmetric crypt operations. -use nettle::{dsa, ecdsa, ed25519, rsa, Yarrow}; +use nettle::{dsa, ecc, ecdsa, ed25519, rsa, Yarrow}; use packet::Key; use crypto::mpis::{self, MPI}; @@ -144,13 +144,13 @@ impl Signer for KeyPair { &mpis::SecretKey::ECDSA { ref scalar }) => { let secret = match curve { Curve::NistP256 => - ecdsa::PrivateKey::new::<ecdsa::Secp256r1>( + ecc::Scalar::new::<ecc::Secp256r1>( &scalar.value)?, Curve::NistP384 => - ecdsa::PrivateKey::new::<ecdsa::Secp384r1>( + ecc::Scalar::new::<ecc::Secp384r1>( &scalar.value)?, Curve::NistP521 => - ecdsa::PrivateKey::new::<ecdsa::Secp521r1>( + ecc::Scalar::new::<ecc::Secp521r1>( &scalar.value)?, _ => return Err( diff --git a/openpgp/src/crypto/ecdh.rs b/openpgp/src/crypto/ecdh.rs index 3329bbb4..b3116485 100644 --- a/openpgp/src/crypto/ecdh.rs +++ b/openpgp/src/crypto/ecdh.rs @@ -14,12 +14,14 @@ use conversions::{ read_be_u64, }; use crypto::mpis::{MPI, PublicKey, SecretKey, Ciphertext}; -use nettle::{cipher, curve25519, mode, Mode}; +use nettle::{cipher, curve25519, mode, Mode, ecc, ecdh, Yarrow}; /// Wraps a session key using Elliptic Curve Diffie-Hellman. pub fn wrap_session_key(recipient: &Key, session_key: &[u8]) -> Result<Ciphertext> { + let mut rng = Yarrow::default(); + if let &PublicKey::ECDH { ref curve, ref q,.. } = recipient.mpis() { @@ -31,7 +33,7 @@ pub fn wrap_session_key(recipient: &Key, session_key: &[u8]) // Generate an ephemeral key pair {v, V=vG} let mut v = - ::crypto::SessionKey::from(curve25519::secret_key()); + ::crypto::SessionKey::from(curve25519::private_key(&mut rng)); // Compute the public key. We need to add an encoding // octet in front of the key. diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs index 052be2d4..c0f514dd 100644 --- a/openpgp/src/crypto/mod.rs +++ b/openpgp/src/crypto/mod.rs @@ -6,8 +6,7 @@ use std::fmt; use std::cmp::Ordering; use memsec; -use nettle; -use nettle::random::Yarrow; +use nettle::{self, Random, Yarrow}; use constants::HashAlgorithm; use Result; diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs index 98aacf69..193eafcb 100644 --- a/openpgp/src/crypto/s2k.rs +++ b/openpgp/src/crypto/s2k.rs @@ -14,7 +14,7 @@ use crypto::SessionKey; use std::fmt; -use nettle::{Hash, Yarrow}; +use nettle::{Hash, Yarrow, Random}; use quickcheck::{Arbitrary, Gen}; use rand::Rng; diff --git a/openpgp/src/crypto/symmetric.rs b/openpgp/src/crypto/symmetric.rs index 2caaa5a7..0d24b0c3 100644 --- a/openpgp/src/crypto/symmetric.rs +++ b/openpgp/src/crypto/symmetric.rs @@ -588,7 +588,7 @@ mod tests { #[test] fn roundtrip() { use std::io::Cursor; - use nettle::Yarrow; + use nettle::{Random, Yarrow}; let mut rng = Yarrow::default(); for algo in [SymmetricAlgorithm::TripleDES, |