summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/src/packet/key.rs
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2019-08-12 13:39:14 +0200
committerNeal H. Walfield <neal@pep.foundation>2019-08-23 19:15:13 +0200
commit05cf492f3417fd61f6b1e7dc4913a16fd5f201ea (patch)
treeeca0c2e0481e10b54884a766e7e864020089fe84 /openpgp-ffi/src/packet/key.rs
parent102dea398e920e91b34e5602033c2e7e53c50bb1 (diff)
openpgp: Use marker types to denote a Key's type.
- In addition to providing some added protection, this allows us to implement 'From<Key<_, _>> for Packet'.
Diffstat (limited to 'openpgp-ffi/src/packet/key.rs')
-rw-r--r--openpgp-ffi/src/packet/key.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/openpgp-ffi/src/packet/key.rs b/openpgp-ffi/src/packet/key.rs
index c824363d..0229a301 100644
--- a/openpgp-ffi/src/packet/key.rs
+++ b/openpgp-ffi/src/packet/key.rs
@@ -25,7 +25,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);
+pub struct Key(openpgp::packet::key::UnspecifiedKey);
/// Computes and returns the key's fingerprint as per Section 12.2
/// of RFC 4880.
@@ -73,7 +73,11 @@ 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 {
+ -> *mut self::openpgp::crypto::KeyPair<
+ self::openpgp::packet::key::UnspecifiedRole>
+{
ffi_make_fry_from_errp!(errp);
- ffi_try_box!(key.move_from_raw().into_keypair())
+ let key : self::openpgp::packet::key::UnspecifiedSecret
+ = key.move_from_raw().into();
+ ffi_try_box!(key.into_keypair())
}