diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-08-21 13:44:30 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-08-21 13:48:53 +0200 |
commit | c9aa8f586ee339adbe3baa3f8da63491e3b1bd13 (patch) | |
tree | 436f97f84bab7f24f0a0e722890f2aa596d53be8 | |
parent | c243834baa3115eda8445b111e3fe47e4bd7793e (diff) |
openpgp: Shortcut parse_finish for non-document signatures.
-rw-r--r-- | openpgp/src/parse.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs index c6fa646b..495f866e 100644 --- a/openpgp/src/parse.rs +++ b/openpgp/src/parse.rs @@ -1310,12 +1310,28 @@ impl Signature { Signature4::plausible(bio, header) } + /// When parsing an inline-signed message, attaches the digest to + /// the signature. fn parse_finish(indent: isize, mut pp: PacketParser, typ: SignatureType, hash_algo: HashAlgorithm) -> Result<PacketParser> { tracer!(TRACE, "Signature::parse_finish", indent); + let sig: &Signature = pp.packet.downcast_ref() + .ok_or_else( + || Error::InvalidOperation( + format!("Called Signature::parse_finish on a {:?}", + pp.packet)))?; + + // If we are not parsing an inline-signed message, we are + // done. + if sig.typ() != SignatureType::Binary + && sig.typ() != SignatureType::Text + { + return Ok(pp); + } + let need_hash = HashingMode::for_signature(hash_algo, typ); // Locate the corresponding HashedReader and extract the |