summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/examples/decrypt-with.rs3
-rw-r--r--openpgp/examples/generate-sign-verify.rs2
-rw-r--r--openpgp/src/parse/stream.rs16
3 files changed, 21 insertions, 0 deletions
diff --git a/openpgp/examples/decrypt-with.rs b/openpgp/examples/decrypt-with.rs
index 35393924..2892761e 100644
--- a/openpgp/examples/decrypt-with.rs
+++ b/openpgp/examples/decrypt-with.rs
@@ -135,6 +135,9 @@ impl VerificationHelper for Helper {
BadChecksum { cert, .. } => {
eprintln!("Bad signature from {}", cert);
},
+ Error { error, .. } => {
+ eprintln!("Error: {}", error);
+ },
}
}
}
diff --git a/openpgp/examples/generate-sign-verify.rs b/openpgp/examples/generate-sign-verify.rs
index 65202609..fefc8a20 100644
--- a/openpgp/examples/generate-sign-verify.rs
+++ b/openpgp/examples/generate-sign-verify.rs
@@ -118,6 +118,8 @@ impl<'a> VerificationHelper for Helper<'a> {
"Missing key to verify signature")),
Some(VerificationResult::BadChecksum { .. }) =>
return Err(failure::err_msg("Bad signature")),
+ Some(VerificationResult::Error { error, .. }) =>
+ return Err(error),
None =>
return Err(failure::err_msg("No signature")),
}
diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs
index fd278e16..336f64e0 100644
--- a/openpgp/src/parse/stream.rs
+++ b/openpgp/src/parse/stream.rs
@@ -212,6 +212,20 @@ pub enum VerificationResult<'a> {
/// The signing key that made the signature.
ka: KeyAmalgamation<'a, key::PublicParts>,
},
+
+ /// An error occured while verifying the signature.
+ ///
+ /// This could occur if the signature is invalid (e.g., no
+ /// Signature Creation Time packet), the key is invalid (e.g., the
+ /// key is not alive, the key is revoked, the key is not signing
+ /// capable), etc.
+ Error {
+ /// The signature.
+ sig: Signature,
+
+ /// The reason.
+ error: failure::Error,
+ },
}
impl<'a> VerificationResult<'a> {
@@ -223,6 +237,7 @@ impl<'a> VerificationResult<'a> {
NotAlive { sig, .. } => sig.level(),
MissingKey { sig, .. } => sig.level(),
BadChecksum { sig, .. } => sig.level(),
+ Error { sig, .. } => sig.level(),
}
}
}
@@ -1772,6 +1787,7 @@ mod test {
MissingKey { .. } => self.unknown += 1,
NotAlive { .. } => self.bad += 1,
BadChecksum { .. } => self.bad += 1,
+ Error { .. } => self.bad += 1,
}
}
MessageLayer::Compression { .. } => (),