summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-09 11:57:22 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-09 12:10:40 +0100
commit7f3d55f777f44f9046ac91afe8e398984f1e4ba1 (patch)
tree4c3edeae026a56d8fadeb5c6ea327a2d13185c74
parentd4e3162c0c56a874f29a58d7fe84a8723b9516aa (diff)
openpgp: New errors Expired and NotYetLive.
-rw-r--r--ffi/src/error.rs4
-rw-r--r--openpgp-ffi/include/sequoia/openpgp/error.h10
-rw-r--r--openpgp-ffi/src/error.rs12
-rw-r--r--openpgp/src/lib.rs8
4 files changed, 34 insertions, 0 deletions
diff --git a/ffi/src/error.rs b/ffi/src/error.rs
index 884e28d1..0e867cb3 100644
--- a/ffi/src/error.rs
+++ b/ffi/src/error.rs
@@ -70,6 +70,10 @@ impl<'a> FromSequoiaError<'a> for Status {
Status::IndexOutOfRange,
&openpgp::Error::UnsupportedCert(_) =>
Status::UnsupportedCert,
+ &openpgp::Error::Expired(_) =>
+ Status::Expired,
+ &openpgp::Error::NotYetLive(_) =>
+ Status::NotYetLive,
}
}
diff --git a/openpgp-ffi/include/sequoia/openpgp/error.h b/openpgp-ffi/include/sequoia/openpgp/error.h
index 67a42ab6..00542290 100644
--- a/openpgp-ffi/include/sequoia/openpgp/error.h
+++ b/openpgp-ffi/include/sequoia/openpgp/error.h
@@ -132,6 +132,16 @@ typedef enum pgp_status {
/*/
PGP_STATUS_UNSUPPORTED_CERT = -24,
+ /*/
+ /// Expired.
+ /*/
+ PGP_STATUS_EXPIRED = -30,
+
+ /*/
+ /// Not yet live.
+ /*/
+ PGP_STATUS_NOT_YET_LIVE = -31,
+
/* Dummy value to make sure the enumeration has a defined size. Do
not use this value. */
PGP_STATUS_FORCE_WIDTH = INT_MAX,
diff --git a/openpgp-ffi/src/error.rs b/openpgp-ffi/src/error.rs
index 4c2924c3..14c79187 100644
--- a/openpgp-ffi/src/error.rs
+++ b/openpgp-ffi/src/error.rs
@@ -147,6 +147,12 @@ pub enum Status {
// XXX: Skipping MissingSessionKey = -27
// XXX: Skipping UnsupportedCompressionAlgorithm = -28
// XXX: Skipping PacketTooLarge = -29
+
+ /// Expired.
+ Expired = -30,
+
+ /// Not yet live.
+ NotYetLive = -31,
}
/// Returns the error message.
@@ -187,6 +193,8 @@ pub extern "C" fn pgp_status_to_string(status: Status) -> *const c_char {
MalformedMessage => "Malformed message\x00",
IndexOutOfRange => "Index out of range\x00",
UnsupportedCert => "Cert not supported\x00",
+ Expired => "Expired\x00",
+ NotYetLive => "Not yet live\x00",
}.as_bytes().as_ptr() as *const c_char
}
@@ -238,6 +246,10 @@ impl<'a> From<&'a failure::Error> for Status {
Status::IndexOutOfRange,
&openpgp::Error::UnsupportedCert(_) =>
Status::UnsupportedCert,
+ &openpgp::Error::Expired(_) =>
+ Status::Expired,
+ &openpgp::Error::NotYetLive(_) =>
+ Status::NotYetLive,
}
}
diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs
index d533ec13..f503f77f 100644
--- a/openpgp/src/lib.rs
+++ b/openpgp/src/lib.rs
@@ -260,6 +260,14 @@ pub enum Error {
/// Index out of range.
#[fail(display = "Index out of range")]
IndexOutOfRange,
+
+ /// Expired.
+ #[fail(display = "Expired on {:?}", _0)]
+ Expired(std::time::SystemTime),
+
+ /// Not yet live.
+ #[fail(display = "Not live until {:?}", _0)]
+ NotYetLive(std::time::SystemTime),
}
/// The OpenPGP packets that Sequoia understands.