diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-12-18 14:44:53 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-12-18 16:21:46 +0100 |
commit | 7a6701001a9408a8eae6faedc91b5d2c42611c5c (patch) | |
tree | 21c0080676d791996043ddc133e0fa96879c144e /openpgp-ffi | |
parent | 1e19e63f9a717df2c3dbb50b18665844e64cef9a (diff) |
openpgp: Make type aliases for keys pub(crate).
- They can still be used as a convenience, but the documentation
will refer to them as their expanded counterparts.
- This makes the structure of they Key<_, _> type more visible.
Diffstat (limited to 'openpgp-ffi')
-rw-r--r-- | openpgp-ffi/src/cert.rs | 9 | ||||
-rw-r--r-- | openpgp-ffi/src/packet/key.rs | 12 | ||||
-rw-r--r-- | openpgp-ffi/src/parse/stream.rs | 5 |
3 files changed, 15 insertions, 11 deletions
diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs index 94dbb2c8..b81150fa 100644 --- a/openpgp-ffi/src/cert.rs +++ b/openpgp-ffi/src/cert.rs @@ -150,8 +150,8 @@ fn pgp_cert_as_tsk(cert: *const Cert) -> *mut TSK<'static> { /// The cert still owns the key. The caller must not modify the key. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_primary_key(cert: *const Cert) -> *const Key { - let key : &self::openpgp::packet::key::UnspecifiedKey - = cert.ref_raw().primary().into(); + let key = cert.ref_raw().primary() + .mark_parts_unspecified_ref().mark_role_unspecified_ref(); key.move_into_raw() } @@ -704,8 +704,9 @@ pub extern "C" fn pgp_cert_key_iter_next<'a>( *ptr = rs.move_into_raw(); } - let key : &self::openpgp::packet::key::UnspecifiedKey - = key.into(); + let key + = key.mark_parts_unspecified_ref().mark_role_unspecified_ref(); + Some(key).move_into_raw() } else { None diff --git a/openpgp-ffi/src/packet/key.rs b/openpgp-ffi/src/packet/key.rs index e612e4ae..73d8350d 100644 --- a/openpgp-ffi/src/packet/key.rs +++ b/openpgp-ffi/src/packet/key.rs @@ -4,11 +4,10 @@ //! //! [Section 5.5 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.5 -use std::convert::TryInto; - use libc::{c_int, time_t}; extern crate sequoia_openpgp as openpgp; +use self::openpgp::packet::key; use super::super::fingerprint::Fingerprint; use super::super::keyid::KeyID; @@ -16,6 +15,10 @@ use crate::MoveFromRaw; use crate::MoveIntoRaw; use crate::RefRaw; +/// A local alias to appease the proc macro transformation. +type UnspecifiedKey = + openpgp::packet::Key<key::UnspecifiedParts, key::UnspecifiedRole>; + /// Holds a public key, public subkey, private key or private subkey packet. /// /// See [Section 5.5 of RFC 4880] for details. @@ -27,7 +30,7 @@ use crate::RefRaw; /// [`sequoia-openpgp::packet::key::Key`]: ../../sequoia_openpgp/packet/key/struct.Key.html #[crate::ffi_wrapper_type(prefix = "pgp_", derive = "Clone, Debug, PartialEq, Parse")] -pub struct Key(openpgp::packet::key::UnspecifiedKey); +pub struct Key(UnspecifiedKey); /// Computes and returns the key's fingerprint as per Section 12.2 /// of RFC 4880. @@ -79,7 +82,6 @@ fn pgp_key_into_key_pair(errp: Option<&mut *mut crate::error::Error>, -> *mut self::openpgp::crypto::KeyPair { ffi_make_fry_from_errp!(errp); - let key : self::openpgp::packet::key::UnspecifiedSecret - = ffi_try!(key.move_from_raw().try_into()); + let key = ffi_try!(key.move_from_raw().mark_parts_secret()); ffi_try_box!(key.into_keypair()) } diff --git a/openpgp-ffi/src/parse/stream.rs b/openpgp-ffi/src/parse/stream.rs index 70319a40..f3b5b32f 100644 --- a/openpgp-ffi/src/parse/stream.rs +++ b/openpgp-ffi/src/parse/stream.rs @@ -199,8 +199,9 @@ fn $fn_name<'a>( } if let Some(mut p) = key_r { *unsafe { p.as_mut() } = { - let key : &self::openpgp::packet::key::UnspecifiedKey - = (*key).into(); + let key = key + .mark_parts_unspecified_ref() + .mark_role_unspecified_ref(); key.move_into_raw() }; } |