summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-02-11 17:40:39 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-02-11 17:40:39 +0100
commit30ac57a2a17b4595d9e5bccc6c0073810ffcc429 (patch)
tree209d3e98b78980b267ca7573cf614cb15954d963 /openpgp-ffi
parentd7b10e952b964d363527e94d49fa057902d21672 (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')
-rw-r--r--openpgp-ffi/include/sequoia/openpgp.h9
-rw-r--r--openpgp-ffi/src/cert.rs13
2 files changed, 8 insertions, 14 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h
index 08b035bf..14afd4bc 100644
--- a/openpgp-ffi/include/sequoia/openpgp.h
+++ b/openpgp-ffi/include/sequoia/openpgp.h
@@ -921,18 +921,15 @@ pgp_status_t pgp_cert_alive(pgp_error_t *errp, pgp_cert_t cert,
pgp_policy_t policy, time_t 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`.
/*/
-pgp_cert_t pgp_cert_set_validity_period(pgp_error_t *errp,
+pgp_cert_t pgp_cert_set_expiration_time(pgp_error_t *errp,
pgp_cert_t cert,
pgp_policy_t policy,
pgp_signer_t signer,
- uint32_t expiry);
+ time_t expiry);
/*/
/// Returns whether the Cert includes any secret key material.
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)
}