diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-11-16 13:54:56 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-11-24 13:27:51 +0100 |
commit | fbbe3cf4ca6b6b1881160925f869065e8f3df58e (patch) | |
tree | 0a5313dac497810f9b7a06b6562ab89de2fd35e0 /openpgp/src/cert.rs | |
parent | 03598e4da99dbaf4c9f978e8f6f57ce3f6720b48 (diff) |
openpgp: Align hashing of compound objects with primitive objects.
Diffstat (limited to 'openpgp/src/cert.rs')
-rw-r--r-- | openpgp/src/cert.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs index f6232bc6..65a47486 100644 --- a/openpgp/src/cert.rs +++ b/openpgp/src/cert.rs @@ -1482,9 +1482,12 @@ impl Cert { .into_iter() { // Use hash prefix as heuristic. - match Signature::$hash_method(&sig, - self.primary.key(), - $($verify_args),*) { + let key = self.primary.key(); + match sig.hash_algo().context().and_then(|mut ctx| { + Signature::$hash_method(&mut ctx, &sig, key, + $($verify_args),*); + ctx.into_digest() + }) { Ok(hash) => { if &sig.digest_prefix()[..] == &hash[..2] { // See if we can get the key for a @@ -1706,8 +1709,14 @@ impl Cert { } } else { // Use hash prefix as heuristic. - if let Ok(hash) = Signature::$hash_method( - &sig, self.primary.key(), $($verify_args),*) { + let key = self.primary.key(); + if let Ok(hash) = sig.hash_algo().context() + .and_then(|mut ctx| { + Signature::$hash_method(&mut ctx, &sig, key, + $($verify_args),*); + ctx.into_digest() + }) + { if &sig.digest_prefix()[..] == &hash[..2] { t!("Sig {:02X}{:02X}, {:?} \ was out of place. Likely belongs to {}.", |