summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ffi/src/error.rs2
-rw-r--r--openpgp-ffi/src/error.rs6
-rw-r--r--openpgp/src/lib.rs7
3 files changed, 15 insertions, 0 deletions
diff --git a/ffi/src/error.rs b/ffi/src/error.rs
index 5c58f0b0..331bad04 100644
--- a/ffi/src/error.rs
+++ b/ffi/src/error.rs
@@ -78,6 +78,8 @@ impl<'a> FromSequoiaError<'a> for Status {
Status::NoBindingSignature,
&openpgp::Error::InvalidKey(_) =>
Status::InvalidKey,
+ &openpgp::Error::PolicyViolation(_, _) =>
+ Status::PolicyViolation,
openpgp::Error::__Nonexhaustive => unreachable!(),
}
}
diff --git a/openpgp-ffi/src/error.rs b/openpgp-ffi/src/error.rs
index b26610a5..01e4ed44 100644
--- a/openpgp-ffi/src/error.rs
+++ b/openpgp-ffi/src/error.rs
@@ -159,6 +159,9 @@ pub enum Status {
/// Invalid key.
InvalidKey = -33,
+
+ /// Policy violation.
+ PolicyViolation = -34,
}
/// Returns the error message.
@@ -203,6 +206,7 @@ pub extern "C" fn pgp_status_to_string(status: Status) -> *const c_char {
NotYetLive => "Not yet live\x00",
NoBindingSignature => "No binding signature\x00",
InvalidKey => "Invalid key\x00",
+ PolicyViolation => "Policy violation\x00",
}.as_bytes().as_ptr() as *const c_char
}
@@ -262,6 +266,8 @@ impl<'a> From<&'a failure::Error> for Status {
Status::NoBindingSignature,
&openpgp::Error::InvalidKey(_) =>
Status::InvalidKey,
+ &openpgp::Error::PolicyViolation(_, _) =>
+ Status::PolicyViolation,
openpgp::Error::__Nonexhaustive => unreachable!(),
}
}
diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs
index 6802861b..b2cf4e48 100644
--- a/openpgp/src/lib.rs
+++ b/openpgp/src/lib.rs
@@ -299,6 +299,13 @@ pub enum Error {
#[fail(display = "Invalid key: {:?}", _0)]
InvalidKey(String),
+ /// The operation is not allowed, because it violates the policy.
+ ///
+ /// The optional time is the time at which the operation was
+ /// determined to no longer be secure.
+ #[fail(display = "Not secure as of: {:?}: {}", _1, _0)]
+ PolicyViolation(String, Option<std::time::SystemTime>),
+
/// This marks this enum as non-exhaustive. Do not use this
/// variant.
#[doc(hidden)] #[fail(display = "__Nonexhaustive")] __Nonexhaustive,