From 214e6a2cac09e29bcbae61cbccdeb58afa38611a Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Tue, 7 May 2019 12:13:20 +0200 Subject: openpgp-ffi: Wrap TPKBuilder::general_purpose --- openpgp-ffi/include/sequoia/openpgp.h | 9 +++++++++ openpgp-ffi/src/tpk.rs | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'openpgp-ffi') 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 @@ -810,6 +810,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]. /// 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 -- cgit v1.2.3