diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-11-22 14:26:14 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-11-22 14:26:14 +0100 |
commit | ced195eb1a7d9151640f1ffacd890839a55b8680 (patch) | |
tree | 53001af1ba91361bfa2ed4b585686781983c6603 /openpgp-ffi/src/packet | |
parent | 28be944bd9f6548b2eee5fc222ffeb52c9d2f8aa (diff) |
openpgp: Make conversions into Key<SecretParts, _> fallible.
- Fixes #380.
Diffstat (limited to 'openpgp-ffi/src/packet')
-rw-r--r-- | openpgp-ffi/src/packet/key.rs | 4 | ||||
-rw-r--r-- | openpgp-ffi/src/packet/pkesk.rs | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/openpgp-ffi/src/packet/key.rs b/openpgp-ffi/src/packet/key.rs index e0eead22..7f08d040 100644 --- a/openpgp-ffi/src/packet/key.rs +++ b/openpgp-ffi/src/packet/key.rs @@ -4,6 +4,8 @@ //! //! [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; @@ -79,6 +81,6 @@ fn pgp_key_into_key_pair(errp: Option<&mut *mut crate::error::Error>, { ffi_make_fry_from_errp!(errp); let key : self::openpgp::packet::key::UnspecifiedSecret - = key.move_from_raw().into(); + = ffi_try!(key.move_from_raw().try_into()); ffi_try_box!(key.into_keypair()) } diff --git a/openpgp-ffi/src/packet/pkesk.rs b/openpgp-ffi/src/packet/pkesk.rs index 8f844d6c..82227065 100644 --- a/openpgp-ffi/src/packet/pkesk.rs +++ b/openpgp-ffi/src/packet/pkesk.rs @@ -44,7 +44,9 @@ pub extern "C" fn pgp_pkesk_decrypt(errp: Option<&mut *mut crate::error::Error>, let algo = ffi_param_ref_mut!(algo); let key_len = ffi_param_ref_mut!(key_len); - match secret_key.clone().mark_parts_secret().into_keypair() { + match ffi_try_or_status!(secret_key.clone().mark_parts_secret()) + .into_keypair() + { Ok(mut keypair) => { match pkesk.decrypt(&mut keypair) { Ok((a, k)) => { |