summaryrefslogtreecommitdiffstats
path: root/ffi
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-12-20 17:42:00 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-01-15 14:09:15 +0100
commit5bef3bde45f71126cdca3e8ad30b1047287c843a (patch)
treee3b45081b6fc33115ce199716824d418d088f26c /ffi
parentf8a502c6b18e097bf1082877f3b6b2f5c99f3a41 (diff)
openpgp: Hand a Vec<crypto::Signer> to stream::Signer.
- Using `crypto::Signer`s has several benefits. First, it shifts the decision which key to use to the caller, moving policy out of the caller. Second, it forces the caller to deal with encrypted keys. Finally, it allows us to use remote keys like smart cards in the future. - Fixes #142.
Diffstat (limited to 'ffi')
-rw-r--r--ffi/src/openpgp/mod.rs24
1 files changed, 19 insertions, 5 deletions
diff --git a/ffi/src/openpgp/mod.rs b/ffi/src/openpgp/mod.rs
index 16321497..f3316944 100644
--- a/ffi/src/openpgp/mod.rs
+++ b/ffi/src/openpgp/mod.rs
@@ -1173,7 +1173,8 @@ pub extern "system" fn sq_arbitrary_writer_new
pub extern "system" fn sq_signer_new
(ctx: *mut Context,
inner: *mut writer::Stack<'static, Cookie>,
- signers: *const &'static TPK, signers_len: size_t)
+ signers: *const *mut Box<self::openpgp::crypto::Signer>,
+ signers_len: size_t)
-> *mut writer::Stack<'static, Cookie>
{
let ctx = ffi_param_ref_mut!(ctx);
@@ -1182,7 +1183,13 @@ pub extern "system" fn sq_signer_new
let signers = unsafe {
slice::from_raw_parts(signers, signers_len)
};
- fry_box!(ctx, Signer::new(*inner, &signers))
+ let signers = signers.into_iter().map(
+ |s| -> &mut dyn self::openpgp::crypto::Signer {
+ let signer = *s;
+ ffi_param_ref_mut!(signer).as_mut()
+ }
+ ).collect();
+ fry_box!(ctx, Signer::new(*inner, signers))
}
/// Creates a signer for a detached signature.
@@ -1190,16 +1197,23 @@ pub extern "system" fn sq_signer_new
pub extern "system" fn sq_signer_new_detached
(ctx: *mut Context,
inner: *mut writer::Stack<'static, Cookie>,
- signers: Option<&&'static TPK>, signers_len: size_t)
+ signers: *const *mut Box<self::openpgp::crypto::Signer>,
+ signers_len: size_t)
-> *mut writer::Stack<'static, Cookie>
{
let ctx = ffi_param_ref_mut!(ctx);
let inner = ffi_param_move!(inner);
- let signers = signers.expect("Signers is NULL");
+ let signers = ffi_param_ref!(signers);
let signers = unsafe {
slice::from_raw_parts(signers, signers_len)
};
- fry_box!(ctx, Signer::detached(*inner, &signers))
+ let signers = signers.into_iter().map(
+ |s| -> &mut dyn self::openpgp::crypto::Signer {
+ let signer = *s;
+ ffi_param_ref_mut!(signer).as_mut()
+ }
+ ).collect();
+ fry_box!(ctx, Signer::detached(*inner, signers))
}
/// Writes a literal data packet.