summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/src/packet
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-18 14:44:53 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-18 16:21:46 +0100
commit7a6701001a9408a8eae6faedc91b5d2c42611c5c (patch)
tree21c0080676d791996043ddc133e0fa96879c144e /openpgp-ffi/src/packet
parent1e19e63f9a717df2c3dbb50b18665844e64cef9a (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/src/packet')
-rw-r--r--openpgp-ffi/src/packet/key.rs12
1 files changed, 7 insertions, 5 deletions
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())
}