summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/src/key_amalgamation.rs
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-03-20 22:57:10 +0100
committerNeal H. Walfield <neal@pep.foundation>2020-03-23 20:57:07 +0100
commit10b5ed603a298c43c80423d70bb6f61d2f3d3b68 (patch)
tree013fdf121e72217e60ee36470a68b22273cde840 /openpgp-ffi/src/key_amalgamation.rs
parentf37e461474581a8f9aefb3765fc1c90b8f547e8d (diff)
openpgp-ffi: Add pgp_valid_key_amalgamation_with_policy.
- Expose ValidKeyAmalgamation::with_policy in the C FFI.
Diffstat (limited to 'openpgp-ffi/src/key_amalgamation.rs')
-rw-r--r--openpgp-ffi/src/key_amalgamation.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/openpgp-ffi/src/key_amalgamation.rs b/openpgp-ffi/src/key_amalgamation.rs
index a7bbeeec..c7a8870d 100644
--- a/openpgp-ffi/src/key_amalgamation.rs
+++ b/openpgp-ffi/src/key_amalgamation.rs
@@ -11,17 +11,21 @@ use libc::{size_t, time_t};
extern crate sequoia_openpgp as openpgp;
use self::openpgp::packet::key;
use self::openpgp::cert::amalgamation::ValidAmalgamation;
+use self::openpgp::cert::amalgamation::ValidateAmalgamation;
use self::openpgp::crypto;
use super::packet::key::Key;
use super::packet::signature::Signature;
use super::packet::Packet;
+use super::policy::Policy;
use super::revocation_status::RevocationStatus;
use crate::error::Status;
+use crate::Maybe;
use crate::MoveIntoRaw;
use crate::MoveResultIntoRaw;
use crate::RefRaw;
+use crate::MoveFromRaw;
use crate::maybe_time;
/// A local alias to appease the proc macro transformation.
@@ -134,3 +138,22 @@ fn pgp_valid_key_amalgamation_set_expiration_time(
}
}
}
+
+/// Changes the policy applied to the `ValidKeyAmalgamation`.
+///
+/// This consumes the key amalgamation.
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
+fn pgp_valid_key_amalgamation_with_policy<'a>(errp: Option<&mut *mut crate::error::Error>,
+ ka: *mut ValidKeyAmalgamation<'a>,
+ policy: *const Policy,
+ time: time_t)
+ -> Maybe<ValidKeyAmalgamation<'a>>
+{
+ ffi_make_fry_from_errp!(errp);
+
+ let ka = ka.move_from_raw();
+ let policy = policy.ref_raw();
+ let time = maybe_time(time);
+
+ ka.with_policy(&**policy, time).move_into_raw(errp)
+}