diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-05-14 10:43:43 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-05-14 11:05:49 +0200 |
commit | 0e74cf1b42b239e26d21b531e6ba3694e6f9361c (patch) | |
tree | 9af9f135bf1682286e97ec074d52f659910ef056 /openpgp-ffi | |
parent | ec19b193720cca4529dc0bb109e615dff7a5959f (diff) |
openpgp, openpgp-ffi: Normalize TPK::revoked()
- `TPK::revoked` returns a revocation status, not a boolean. Rename
it to `TPK::revocation_status()`, like it is called in the FFI.
- Like other methods, provide a `foo_at()` method and a `foo()`
method.
Diffstat (limited to 'openpgp-ffi')
-rw-r--r-- | openpgp-ffi/include/sequoia/openpgp.h | 12 | ||||
-rw-r--r-- | openpgp-ffi/src/tpk.rs | 26 |
2 files changed, 34 insertions, 4 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h index 141b5b7f..554a8306 100644 --- a/openpgp-ffi/include/sequoia/openpgp.h +++ b/openpgp-ffi/include/sequoia/openpgp.h @@ -698,7 +698,7 @@ pgp_tsk_t pgp_tpk_as_tsk (pgp_tpk_t tpk); pgp_key_t pgp_tpk_primary (pgp_tpk_t tpk); /*/ -/// Returns the TPK's revocation status. +/// Returns the TPK's current revocation status. /// /// Note: this only returns whether the TPK has been revoked, and does /// not reflect whether an individual user id, user attribute or @@ -707,6 +707,16 @@ pgp_key_t pgp_tpk_primary (pgp_tpk_t tpk); pgp_revocation_status_t pgp_tpk_revocation_status (pgp_tpk_t tpk); /*/ +/// Returns the TPK's revocation status at the specified time. +/// +/// Note: this only returns whether the TPK has been revoked, and does +/// not reflect whether an individual user id, user attribute or +/// subkey has been revoked. +/*/ +pgp_revocation_status_t pgp_tpk_revocation_status_at (pgp_tpk_t tpk, + time_t when); + +/*/ /// Writes a revocation certificate to the writer. /// /// This function consumes the writer. It does *not* consume tpk. diff --git a/openpgp-ffi/src/tpk.rs b/openpgp-ffi/src/tpk.rs index 2080e494..c8b70618 100644 --- a/openpgp-ffi/src/tpk.rs +++ b/openpgp-ffi/src/tpk.rs @@ -151,15 +151,35 @@ fn pgp_tpk_primary(tpk: *const TPK) -> *const Key { tpk.ref_raw().primary().move_into_raw() } -/// Returns the TPK's revocation status. +/// Returns the TPK's revocation status as of a given time. +/// +/// Note: this only returns whether the TPK has been revoked, and does +/// not reflect whether an individual user id, user attribute or +/// subkey has been revoked. +#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" +fn pgp_tpk_revocation_status_at(tpk: *const TPK, when: time_t) + -> *mut RevocationStatus<'static> +{ + let when = when as i64; + let when = if when == 0 { + None + } else { + Some(time::at(time::Timespec::new(when, 0))) + }; + + tpk.ref_raw().revocation_status_at(when).move_into_raw() +} + +/// Returns the TPK's current revocation status. /// /// Note: this only returns whether the TPK has been revoked, and does /// not reflect whether an individual user id, user attribute or /// subkey has been revoked. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_tpk_revocation_status(tpk: *const TPK) - -> *mut RevocationStatus<'static> { - tpk.ref_raw().revoked(None).move_into_raw() + -> *mut RevocationStatus<'static> +{ + tpk.ref_raw().revocation_status().move_into_raw() } fn int_to_reason_for_revocation(code: c_int) -> ReasonForRevocation { |