diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-01-10 11:14:02 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-01-10 14:41:51 +0100 |
commit | 6e53bb4f673786acee95a416fbf7859659d626b7 (patch) | |
tree | ac248ced95585636a9b5ad122df5ce6de54c4752 /ffi/src | |
parent | b3a4ad197f84b22883c2c2f4114b0e3472af60ee (diff) |
ffi: New function sq_p_key_into_key_pair.
Diffstat (limited to 'ffi/src')
-rw-r--r-- | ffi/src/openpgp/mod.rs | 16 |
1 files changed, 16 insertions, 0 deletions
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 |