From 41fd3f08adff856ec558f8b06214e0f392893a26 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 5 Dec 2019 16:13:54 +0100 Subject: 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. --- openpgp-ffi/src/cert.rs | 14 ++++++-------- openpgp-ffi/src/crypto.rs | 13 ++++++------- openpgp-ffi/src/packet/key.rs | 3 +-- openpgp-ffi/src/serialize.rs | 6 ++---- 4 files changed, 15 insertions(+), 21 deletions(-) (limited to 'openpgp-ffi/src') 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>, + primary_signer: *mut Box, code: c_int, reason: Option<&c_char>) -> Maybe @@ -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>, + primary_signer: *mut Box, code: c_int, reason: Option<&c_char>) -> Maybe @@ -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>, - expiry: u32) - -> Maybe { + cert: *mut Cert, + primary_signer: *mut Box, + expiry: u32) + -> Maybe { 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 + -> *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>) + (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) - -> *mut &'static mut dyn crypto::Signer + (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>, + signers: *const *mut Box, 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>, + signers: *const *mut Box, signers_len: size_t, hash_algo: u8) -> *mut writer::Stack<'static, Cookie> -- cgit v1.2.3