summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2022-11-18 09:21:18 +0100
committerNeal H. Walfield <neal@pep.foundation>2022-11-18 09:21:18 +0100
commitba35204e4848b49fd100c5cc5f8e0b1cf109b69d (patch)
tree57b2c71919f5418b7d03c37900af7e5562567eb6
parentd638a95af5e3505436c262f6ca09ebfa11bfe77d (diff)
openpgp: Improve error message when rejecting a packet.
- When we reject a particular version of a packet, indicate what version of the packet we rejected.
-rw-r--r--openpgp/src/policy/cutofflist.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/openpgp/src/policy/cutofflist.rs b/openpgp/src/policy/cutofflist.rs
index 6bbc8eb7..78abe7c8 100644
--- a/openpgp/src/policy/cutofflist.rs
+++ b/openpgp/src/policy/cutofflist.rs
@@ -406,17 +406,18 @@ impl<A> VersionedCutoffList<A>
//
// `tolerance` is added to the cutoff time.
#[inline]
- pub(super) fn check(&self, a: A, version: u8, time: Timestamp,
+ pub(super) fn check(&self, algo: A, version: u8, time: Timestamp,
tolerance: Option<Duration>)
-> Result<()>
{
- if let Some(cutoff) = self.cutoff(a.clone(), version) {
+ if let Some(cutoff) = self.cutoff(algo.clone(), version) {
let cutoff = cutoff
.checked_add(tolerance.unwrap_or_else(|| Duration::seconds(0)))
.unwrap_or(Timestamp::MAX);
if time >= cutoff {
Err(Error::PolicyViolation(
- a.to_string(), Some(cutoff.into())).into())
+ format!("{} v{}", algo, version),
+ Some(cutoff.into())).into())
} else {
Ok(())
}