summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/src/policy.rs
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-01-31 14:20:53 +0100
committerNeal H. Walfield <neal@pep.foundation>2020-01-31 15:59:16 +0100
commita464ce819ccd1fa07ff8c6d0be74cff5eec5cf34 (patch)
tree31ed9d18b9c7802a93b4e4c8e6e85d1121b201d8 /openpgp-ffi/src/policy.rs
parentb9b6533bd5394cd5cdb6b91b5c5ca7a02e3ea199 (diff)
openpgp: Add a policy object.
- Change all functions that need to evaluate the validity of a signature (either directly or indirectly to take a policy object. - Use the policy object to allow the user to place additional constraints on a signature's validity. - This addresses the first half of #274 (it introduces the policy object, but does not yet implement any policy).
Diffstat (limited to 'openpgp-ffi/src/policy.rs')
-rw-r--r--openpgp-ffi/src/policy.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/openpgp-ffi/src/policy.rs b/openpgp-ffi/src/policy.rs
new file mode 100644
index 00000000..2c00ae52
--- /dev/null
+++ b/openpgp-ffi/src/policy.rs
@@ -0,0 +1,36 @@
+//! Policy objects.
+//!
+//! This module allows the caller to specify low-level policy like
+//! what algorithms are allowed.
+//!
+//! Wraps the policy object functions, see
+//! [`sequoia-openpgp::policy`].
+//!
+//! [`sequoia-openpgp::policy`]: ../../sequoia_openpgp/policy/index.html
+
+extern crate sequoia_openpgp as openpgp;
+
+use crate::MoveIntoRaw;
+
+use self::openpgp::policy;
+
+/// A policy object.
+#[crate::ffi_wrapper_type(
+ prefix = "pgp_",
+ derive = "Clone, Debug")]
+pub struct Policy(Box<policy::Policy>);
+
+/// A StandardPolicy object.
+#[crate::ffi_wrapper_type(
+ prefix = "pgp_",
+ derive = "Clone, Debug")]
+pub struct StandardPolicy(policy::StandardPolicy);
+
+/// Returns a new standard policy.
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
+pub extern "C" fn pgp_standard_policy()
+ -> *mut Policy
+{
+ let p : Box<policy::Policy> = Box::new(policy::StandardPolicy::new());
+ p.move_into_raw()
+}