summaryrefslogtreecommitdiffstats
path: root/ffi
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-01-10 11:14:02 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-01-10 14:41:51 +0100
commit6e53bb4f673786acee95a416fbf7859659d626b7 (patch)
treeac248ced95585636a9b5ad122df5ce6de54c4752 /ffi
parentb3a4ad197f84b22883c2c2f4114b0e3472af60ee (diff)
ffi: New function sq_p_key_into_key_pair.
Diffstat (limited to 'ffi')
-rw-r--r--ffi/include/sequoia/openpgp.h10
-rw-r--r--ffi/src/openpgp/mod.rs16
2 files changed, 26 insertions, 0 deletions
diff --git a/ffi/include/sequoia/openpgp.h b/ffi/include/sequoia/openpgp.h
index 40c45d55..7b1aa3b6 100644
--- a/ffi/include/sequoia/openpgp.h
+++ b/ffi/include/sequoia/openpgp.h
@@ -1178,6 +1178,16 @@ sq_public_key_algo_t sq_p_key_public_key_algo(sq_p_key_t key);
int sq_p_key_public_key_bits(sq_p_key_t key);
/*/
+/// Creates a new key pair from a Key packet with an unencrypted
+/// secret key.
+///
+/// # Errors
+///
+/// Fails if the secret key is missing, or encrypted.
+/*/
+sq_key_pair_t sq_p_key_into_key_pair (sq_context_t ctx, sq_p_key_t key);
+
+/*/
/// Returns the value of the User ID Packet.
///
/// The returned pointer is valid until `uid` is deallocated. If
diff --git a/ffi/src/openpgp/mod.rs b/ffi/src/openpgp/mod.rs
index 1f5081e6..16321497 100644
--- a/ffi/src/openpgp/mod.rs
+++ b/ffi/src/openpgp/mod.rs
@@ -511,6 +511,22 @@ pub extern "system" fn sq_p_key_public_key_bits(key: *const packet::Key)
}
}
+/// Creates a new key pair from a Key packet with an unencrypted
+/// secret key.
+///
+/// # Errors
+///
+/// Fails if the secret key is missing, or encrypted.
+#[no_mangle]
+pub extern "system" fn sq_p_key_into_key_pair(ctx: *mut Context,
+ key: *mut packet::Key)
+ -> *mut self::openpgp::crypto::KeyPair
+{
+ let ctx = ffi_param_ref_mut!(ctx);
+ let key = ffi_param_move!(key);
+ fry_box!(ctx, key.into_keypair())
+}
+
/// Returns the value of the User ID Packet.
///
/// The returned pointer is valid until `uid` is deallocated. If