diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-01-03 13:41:56 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-01-03 13:41:56 +0100 |
commit | 7140cffef397007746ab3d93ef15b7f3c98576b5 (patch) | |
tree | 45dd9e99f00145920e41a0b0b9436c0580ff3fa5 /openpgp/src/crypto/mod.rs | |
parent | a608d9a1c57560a42cfc3b9642586166f8ab8e52 (diff) |
openpgp: Simplify crypto::hash_file.
- The context knows the algorithm now.
Diffstat (limited to 'openpgp/src/crypto/mod.rs')
-rw-r--r-- | openpgp/src/crypto/mod.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs index 51db3b18..7955d810 100644 --- a/openpgp/src/crypto/mod.rs +++ b/openpgp/src/crypto/mod.rs @@ -169,7 +169,7 @@ impl Password { /// /// This is useful when verifying detached signatures. pub fn hash_file<R: Read>(reader: R, algos: &[HashAlgorithm]) - -> Result<Vec<(HashAlgorithm, hash::Context)>> + -> Result<Vec<hash::Context>> { use std::mem; @@ -188,10 +188,10 @@ pub fn hash_file<R: Read>(reader: R, algos: &[HashAlgorithm]) // Hash all of the data. reader.drop_eof()?; - let mut hashes = + let hashes = mem::replace(&mut reader.cookie_mut().sig_group_mut().hashes, Default::default()); - let hashes = hashes.drain(..).collect(); + let hashes = hashes.into_iter().map(|(_, ctx)| ctx).collect(); Ok(hashes) } @@ -210,7 +210,8 @@ fn hash_file_test() { &expected.keys().cloned().collect::<Vec<HashAlgorithm>>()) .unwrap(); - for (algo, mut hash) in result.into_iter() { + for mut hash in result.into_iter() { + let algo = hash.algo(); let mut digest = vec![0u8; hash.digest_size()]; hash.digest(&mut digest); |