diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-01-03 15:03:45 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-01-03 15:03:45 +0100 |
commit | b298e538d1bec7db5b2fad5d020df8dcf4c2067b (patch) | |
tree | 111004ba8aa9ea8ad0e1d369e5c408d9f89853b5 | |
parent | 271802a7f1daf3802ecf5e496e1ede48da874031 (diff) |
openpgp: Rename hash_file to hash_reader, improve documentation.
-rw-r--r-- | openpgp/src/crypto/mod.rs | 15 | ||||
-rw-r--r-- | sqv/src/sqv.rs | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs index e72ae672..9b338f13 100644 --- a/openpgp/src/crypto/mod.rs +++ b/openpgp/src/crypto/mod.rs @@ -165,10 +165,13 @@ impl Password { } -/// Hash the specified file. +/// Hashes the given reader. /// -/// This is useful when verifying detached signatures. -pub fn hash_file<R: Read>(reader: R, algos: &[HashAlgorithm]) +/// This can be used to verify detached signatures. For a more +/// convenient method, see [`DetachedVerifier`]. +/// +/// [`DetachedVerifier`]: ../parse/stream/struct.DetachedVerifier.html +pub fn hash_reader<R: Read>(reader: R, algos: &[HashAlgorithm]) -> Result<Vec<hash::Context>> { use std::mem; @@ -196,7 +199,7 @@ pub fn hash_file<R: Read>(reader: R, algos: &[HashAlgorithm]) #[test] -fn hash_file_test() { +fn hash_reader_test() { use std::collections::HashMap; let expected: HashMap<HashAlgorithm, &str> = [ @@ -205,8 +208,8 @@ fn hash_file_test() { ].iter().cloned().collect(); let result = - hash_file(::std::io::Cursor::new(crate::tests::manifesto()), - &expected.keys().cloned().collect::<Vec<HashAlgorithm>>()) + hash_reader(std::io::Cursor::new(crate::tests::manifesto()), + &expected.keys().cloned().collect::<Vec<HashAlgorithm>>()) .unwrap(); for mut hash in result.into_iter() { diff --git a/sqv/src/sqv.rs b/sqv/src/sqv.rs index a7ddf0e7..59ea23d2 100644 --- a/sqv/src/sqv.rs +++ b/sqv/src/sqv.rs @@ -149,7 +149,7 @@ fn real_main() -> Result<(), failure::Error> { let hash_algos : Vec<HashAlgorithm> = sigs.iter().map(|&(ref sig, _)| sig.hash_algo()).collect(); let hashes: HashMap<_, _> = - openpgp::crypto::hash_file(File::open(file)?, &hash_algos[..])? + openpgp::crypto::hash_reader(File::open(file)?, &hash_algos[..])? .into_iter().map(|ctx| (ctx.algo(), ctx)).collect(); fn cert_has_key(cert: &Cert, keyid: &KeyID) -> bool { |