diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-02-11 17:40:39 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-02-11 17:40:39 +0100 |
commit | 30ac57a2a17b4595d9e5bccc6c0073810ffcc429 (patch) | |
tree | 209d3e98b78980b267ca7573cf614cb15954d963 /openpgp-ffi/src/cert.rs | |
parent | d7b10e952b964d363527e94d49fa057902d21672 (diff) |
openpgp: Use absolute expiration time in cert.
- The certificate is a mid-level interface, and should therefore use
the more user-friendly way of specifying expiration.
- Fixes #429.
Diffstat (limited to 'openpgp-ffi/src/cert.rs')
-rw-r--r-- | openpgp-ffi/src/cert.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs index f98478fa..0c4b2e83 100644 --- a/openpgp-ffi/src/cert.rs +++ b/openpgp-ffi/src/cert.rs @@ -339,26 +339,23 @@ fn pgp_cert_alive(errp: Option<&mut *mut crate::error::Error>, ffi_try_status!(cert.ref_raw().alive(policy, maybe_time(when))) } -/// Changes the Cert's expiration. -/// -/// Expiry is when the key should expire in seconds relative to the -/// key's creation (not the current time). +/// Sets the key to expire at the given time. /// /// This function consumes `cert` and returns a new `Cert`. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn pgp_cert_set_validity_period(errp: Option<&mut *mut crate::error::Error>, +fn pgp_cert_set_expiration_time(errp: Option<&mut *mut crate::error::Error>, cert: *mut Cert, policy: *const Policy, primary_signer: *mut Box<dyn crypto::Signer>, - expiry: u32) + expiry: time_t) -> Maybe<Cert> { let policy = &**policy.ref_raw(); let cert = cert.move_from_raw(); let signer = ffi_param_ref_mut!(primary_signer); - cert.set_validity_period(policy, signer.as_mut(), - Some(std::time::Duration::new(expiry as u64, 0))) + cert.set_expiration_time(policy, signer.as_mut(), + maybe_time(expiry)) .move_into_raw(errp) } |