summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2019-05-07 12:13:20 +0200
committerNeal H. Walfield <neal@pep.foundation>2019-05-07 12:18:47 +0200
commit214e6a2cac09e29bcbae61cbccdeb58afa38611a (patch)
tree9f7556ecaef5ccaec17a9caf692b9d071e7a47a1 /openpgp-ffi
parenta23be8beccfb4bec44ea99ce6943b50800998b01 (diff)
openpgp-ffi: Wrap TPKBuilder::general_purpose
Diffstat (limited to 'openpgp-ffi')
-rw-r--r--openpgp-ffi/include/sequoia/openpgp.h9
-rw-r--r--openpgp-ffi/src/tpk.rs18
2 files changed, 27 insertions, 0 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h
index c0ac87d6..1e70a1bc 100644
--- a/openpgp-ffi/include/sequoia/openpgp.h
+++ b/openpgp-ffi/include/sequoia/openpgp.h
@@ -811,6 +811,15 @@ char *pgp_tpk_primary_user_id(pgp_tpk_t tpk);
pgp_tpk_builder_t pgp_tpk_builder_new(void);
/*/
+/// Generates a general-purpose key.
+///
+/// The key's primary key is certification- and signature-capable.
+/// The key has one subkey, an encryption-capable subkey.
+/*/
+pgp_tpk_builder_t pgp_tpk_builder_general_purpose(pgp_tpk_cipher_suite_t cs,
+ const char *uid);
+
+/*/
/// Generates a key compliant to [Autocrypt Level 1].
///
/// [Autocrypt Level 1]: https://autocrypt.org/level1.html
diff --git a/openpgp-ffi/src/tpk.rs b/openpgp-ffi/src/tpk.rs
index 2083add9..eeb115e0 100644
--- a/openpgp-ffi/src/tpk.rs
+++ b/openpgp-ffi/src/tpk.rs
@@ -709,6 +709,24 @@ pub extern "system" fn pgp_tpk_builder_new() -> *mut TPKBuilder {
box_raw!(TPKBuilder::new())
}
+/// Generates a general-purpose key.
+///
+/// The key's primary key is certification- and signature-capable.
+/// The key has one subkey, an encryption-capable subkey.
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
+pub extern "system" fn pgp_tpk_builder_general_purpose(cs: c_int,
+ uid: *const c_char)
+ -> *mut TPKBuilder
+{
+ let uid = if uid.is_null() {
+ None
+ } else {
+ Some(ffi_param_cstr!(uid).to_string_lossy())
+ };
+ box_raw!(TPKBuilder::general_purpose(
+ Some(int_to_cipher_suite(cs)), uid))
+}
+
/// Generates a key compliant to [Autocrypt Level 1].
///
/// Autocrypt requires a user id, however, if `uid` is NULL, a TPK is