summaryrefslogtreecommitdiffstats
path: root/openpgp/src/parse.rs
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/src/parse.rs')
-rw-r--r--openpgp/src/parse.rs16
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