summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2024-03-24 14:14:28 +0100
committerJustus Winter <justus@sequoia-pgp.org>2024-03-24 14:14:28 +0100
commitfcea4415057618a65c506921e86ae5e4056c0ef9 (patch)
treed1bc64124fa964048bc9c17aadb0dea58c8a137b
parenta50b2e584190a39ac66ab4e79cb09c30abdb5812 (diff)
openpgp: Stash the digest on successful signature verifications.
-rw-r--r--openpgp/src/packet/signature.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/openpgp/src/packet/signature.rs b/openpgp/src/packet/signature.rs
index a99f4925..08e49009 100644
--- a/openpgp/src/packet/signature.rs
+++ b/openpgp/src/packet/signature.rs
@@ -1805,8 +1805,12 @@ pub struct Signature4 {
/// Signature MPIs.
mpis: mpi::Signature,
+ /// The computed digest.
+ ///
/// When used in conjunction with a one-pass signature, this is the
/// hash computed over the enclosed message.
+ ///
+ /// This is also set when a signature is successfully verified.
computed_digest: Option<Vec<u8>>,
/// Signature level.
@@ -1962,7 +1966,8 @@ impl Signature4 {
/// Gets the computed hash value.
///
- /// This is set by the [`PacketParser`] when parsing the message.
+ /// This is set by the [`PacketParser`] when parsing the message,
+ /// or during successful verification of signatures.
///
/// [`PacketParser`]: crate::parse::PacketParser
pub fn computed_digest(&self) -> Option<&[u8]> {
@@ -2767,6 +2772,11 @@ impl Signature {
self.additional_issuers.push(fp);
}
}
+
+ // Finally, remember the digest.
+ if let Some(digest) = computed_digest {
+ self.set_computed_digest(Some(digest.into_owned()));
+ }
}
result
}