summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/src
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-05 16:13:54 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-05 16:21:52 +0100
commit41fd3f08adff856ec558f8b06214e0f392893a26 (patch)
treee7894d4e77074109692503fab3b3b46d343f70b6 /openpgp-ffi/src
parent71a3a540bda400f52a841c04b8d33a51959fa8f0 (diff)
openpgp: Make crypto::{Signer,Decryptor} non-polymorphic.
- These are low-level cryptographic traits that are not concerned with the role of a key. - Fixes #382.
Diffstat (limited to 'openpgp-ffi/src')
-rw-r--r--openpgp-ffi/src/cert.rs14
-rw-r--r--openpgp-ffi/src/crypto.rs13
-rw-r--r--openpgp-ffi/src/packet/key.rs3
-rw-r--r--openpgp-ffi/src/serialize.rs6
4 files changed, 15 insertions, 21 deletions
diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs
index 561d0c2c..00e7b3b4 100644
--- a/openpgp-ffi/src/cert.rs
+++ b/openpgp-ffi/src/cert.rs
@@ -232,8 +232,7 @@ fn int_to_reason_for_revocation(code: c_int) -> ReasonForRevocation {
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_cert_revoke(errp: Option<&mut *mut crate::error::Error>,
cert: *const Cert,
- primary_signer: *mut Box<dyn crypto::Signer<
- openpgp::packet::key::UnspecifiedRole>>,
+ primary_signer: *mut Box<dyn crypto::Signer>,
code: c_int,
reason: Option<&c_char>)
-> Maybe<Signature>
@@ -299,8 +298,7 @@ fn pgp_cert_revoke(errp: Option<&mut *mut crate::error::Error>,
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_cert_revoke_in_place(errp: Option<&mut *mut crate::error::Error>,
cert: *mut Cert,
- primary_signer: *mut Box<dyn crypto::Signer<
- openpgp::packet::key::UnspecifiedRole>>,
+ primary_signer: *mut Box<dyn crypto::Signer>,
code: c_int,
reason: Option<&c_char>)
-> Maybe<Cert>
@@ -342,10 +340,10 @@ fn pgp_cert_alive(cert: *const Cert, when: time_t)
/// This function consumes `cert` and returns a new `Cert`.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_cert_set_expiry(errp: Option<&mut *mut crate::error::Error>,
- cert: *mut Cert, primary_signer: *mut Box<dyn crypto::Signer<
- openpgp::packet::key::UnspecifiedRole>>,
- expiry: u32)
- -> Maybe<Cert> {
+ cert: *mut Cert,
+ primary_signer: *mut Box<dyn crypto::Signer>,
+ expiry: u32)
+ -> Maybe<Cert> {
let cert = cert.move_from_raw();
let signer = ffi_param_ref_mut!(primary_signer);
diff --git a/openpgp-ffi/src/crypto.rs b/openpgp-ffi/src/crypto.rs
index 41c58504..d4e7ace9 100644
--- a/openpgp-ffi/src/crypto.rs
+++ b/openpgp-ffi/src/crypto.rs
@@ -58,8 +58,7 @@ fn pgp_password_from_bytes(buf: *const u8, size: size_t) -> *mut Password {
/// Frees a signer.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "C" fn pgp_signer_free
- (s: Option<&mut &'static mut dyn crypto::Signer<
- openpgp::packet::key::UnspecifiedRole>>)
+ (s: Option<&mut &'static mut dyn crypto::Signer>)
{
ffi_free!(s)
}
@@ -69,7 +68,7 @@ pub extern "C" fn pgp_signer_free
pub extern "C" fn pgp_key_pair_new
(errp: Option<&mut *mut crate::error::Error>, public: *mut Key,
secret: *mut openpgp::packet::key::Unencrypted)
- -> *mut crypto::KeyPair<openpgp::packet::key::UnspecifiedRole>
+ -> *mut crypto::KeyPair
{
ffi_make_fry_from_errp!(errp);
let public = public.move_from_raw();
@@ -80,7 +79,7 @@ pub extern "C" fn pgp_key_pair_new
/// Frees a key pair.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "C" fn pgp_key_pair_free
- (kp: Option<&mut crypto::KeyPair<openpgp::packet::key::UnspecifiedRole>>)
+ (kp: Option<&mut crypto::KeyPair>)
{
ffi_free!(kp)
}
@@ -91,11 +90,11 @@ pub extern "C" fn pgp_key_pair_free
/// must not outlive the key pair.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "C" fn pgp_key_pair_as_signer
- (kp: *mut crypto::KeyPair<openpgp::packet::key::UnspecifiedRole>)
- -> *mut &'static mut dyn crypto::Signer<openpgp::packet::key::UnspecifiedRole>
+ (kp: *mut crypto::KeyPair)
+ -> *mut &'static mut dyn crypto::Signer
{
let kp = ffi_param_ref_mut!(kp);
- let signer: &mut dyn crypto::Signer<_> = kp;
+ let signer: &mut dyn crypto::Signer = kp;
box_raw!(signer)
//box_raw!(kp)
}
diff --git a/openpgp-ffi/src/packet/key.rs b/openpgp-ffi/src/packet/key.rs
index 7f08d040..e612e4ae 100644
--- a/openpgp-ffi/src/packet/key.rs
+++ b/openpgp-ffi/src/packet/key.rs
@@ -76,8 +76,7 @@ fn pgp_key_public_key_bits(key: *const Key) -> c_int {
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_key_into_key_pair(errp: Option<&mut *mut crate::error::Error>,
key: *mut Key)
- -> *mut self::openpgp::crypto::KeyPair<
- self::openpgp::packet::key::UnspecifiedRole>
+ -> *mut self::openpgp::crypto::KeyPair
{
ffi_make_fry_from_errp!(errp);
let key : self::openpgp::packet::key::UnspecifiedSecret
diff --git a/openpgp-ffi/src/serialize.rs b/openpgp-ffi/src/serialize.rs
index 5c74b413..6f24a5aa 100644
--- a/openpgp-ffi/src/serialize.rs
+++ b/openpgp-ffi/src/serialize.rs
@@ -150,8 +150,7 @@ pub extern "C" fn pgp_arbitrary_writer_new
pub extern "C" fn pgp_signer_new
(errp: Option<&mut *mut crate::error::Error>,
inner: *mut writer::Stack<'static, Cookie>,
- signers: *const *mut Box<dyn self::openpgp::crypto::Signer<
- self::openpgp::packet::key::UnspecifiedRole>>,
+ signers: *const *mut Box<dyn self::openpgp::crypto::Signer>,
signers_len: size_t,
hash_algo: u8)
-> *mut writer::Stack<'static, Cookie>
@@ -188,8 +187,7 @@ pub extern "C" fn pgp_signer_new
pub extern "C" fn pgp_signer_new_detached
(errp: Option<&mut *mut crate::error::Error>,
inner: *mut writer::Stack<'static, Cookie>,
- signers: *const *mut Box<dyn self::openpgp::crypto::Signer<
- self::openpgp::packet::key::UnspecifiedRole>>,
+ signers: *const *mut Box<dyn self::openpgp::crypto::Signer>,
signers_len: size_t,
hash_algo: u8)
-> *mut writer::Stack<'static, Cookie>