diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-07-02 17:47:41 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-07-02 19:02:15 +0200 |
commit | 679b3631aa40663bd23778fc4776c3da8ba3cef0 (patch) | |
tree | 7fcf1bc3a3a34e33ac89fa4bb7ba2d45d1fb59a8 /openpgp/src/crypto | |
parent | 852890aac0c1db5e249e584666c056a2d9aa41ae (diff) |
openpgp: Use the hash abstraction for hashing.
Diffstat (limited to 'openpgp/src/crypto')
-rw-r--r-- | openpgp/src/crypto/keygrip.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/openpgp/src/crypto/keygrip.rs b/openpgp/src/crypto/keygrip.rs index a9f3cd0a..a1d457e2 100644 --- a/openpgp/src/crypto/keygrip.rs +++ b/openpgp/src/crypto/keygrip.rs @@ -1,11 +1,8 @@ use std::fmt; -use nettle; -use nettle::Hash; - use Error; use Result; -use constants::Curve; +use constants::{Curve, HashAlgorithm}; use crypto::mpis::{MPI, PublicKey}; /// A proprietary, protocol agnostic identifier for public keys. @@ -50,11 +47,13 @@ impl Keygrip { impl PublicKey { /// Computes the keygrip. pub fn keygrip(&self) -> Result<Keygrip> { + use crypto::hash; + use std::io::Write; use self::PublicKey::*; - let mut hash = nettle::hash::insecure_do_not_use::Sha1::default(); + let mut hash = HashAlgorithm::SHA1.context().unwrap(); - fn hash_sexp_mpi<H>(hash: &mut H, kind: char, prefix: &[u8], mpi: &MPI) - where H: Hash + ::std::io::Write + fn hash_sexp_mpi(hash: &mut hash::Context, kind: char, prefix: &[u8], + mpi: &MPI) { write!(hash, "(1:{}{}:", kind, mpi.value().len() + prefix.len()).unwrap(); @@ -63,8 +62,7 @@ impl PublicKey { write!(hash, ")").unwrap(); } - fn hash_ecc<H>(hash: &mut H, curve: &Curve, q: &MPI) - where H: Hash + ::std::io::Write + fn hash_ecc(hash: &mut hash::Context, curve: &Curve, q: &MPI) { for (i, name) in "pabgnhq".chars().enumerate() { if i == 5 { |