From 7d4090c4c862e6f38f5a17a9ad77484bf219909d Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 5 Aug 2020 11:53:22 +0200 Subject: openpgp: Don't implement Default for the Bitflags types. - See #525. --- openpgp-ffi/src/packet/signature.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'openpgp-ffi') diff --git a/openpgp-ffi/src/packet/signature.rs b/openpgp-ffi/src/packet/signature.rs index fdab2d4f..b6ee4061 100644 --- a/openpgp-ffi/src/packet/signature.rs +++ b/openpgp-ffi/src/packet/signature.rs @@ -11,6 +11,7 @@ use libc::time_t; use libc::c_uint; extern crate sequoia_openpgp as openpgp; +use openpgp::types::KeyFlags; use super::Packet; use super::super::fingerprint::Fingerprint; use super::super::keyid::KeyID; @@ -71,14 +72,14 @@ fn pgp_signature_issuer_fingerprint(sig: *const Signature) /// make certifications. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_signature_for_certification(sig: *const Signature) -> bool { - sig.ref_raw().key_flags().unwrap_or_default().for_certification() + sig.ref_raw().key_flags().unwrap_or_else(KeyFlags::empty).for_certification() } /// Returns whether the KeyFlags indicates that the key can be used to /// make signatures. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_signature_for_signing(sig: *const Signature) -> bool { - sig.ref_raw().key_flags().unwrap_or_default().for_signing() + sig.ref_raw().key_flags().unwrap_or_else(KeyFlags::empty).for_signing() } /// Returns whether the KeyFlags indicates that the key can be used to @@ -86,35 +87,35 @@ fn pgp_signature_for_signing(sig: *const Signature) -> bool { #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_signature_for_transport_encryption(sig: *const Signature) -> bool { - sig.ref_raw().key_flags().unwrap_or_default().for_transport_encryption() + sig.ref_raw().key_flags().unwrap_or_else(KeyFlags::empty).for_transport_encryption() } /// Returns whether the KeyFlags indicates that the key can be used to /// encrypt data at rest. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_signature_for_storage_encryption(sig: *const Signature) -> bool { - sig.ref_raw().key_flags().unwrap_or_default().for_storage_encryption() + sig.ref_raw().key_flags().unwrap_or_else(KeyFlags::empty).for_storage_encryption() } /// Returns whether the KeyFlags indicates that the key can be used /// for authentication. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_signature_for_authentication(sig: *const Signature) -> bool { - sig.ref_raw().key_flags().unwrap_or_default().for_authentication() + sig.ref_raw().key_flags().unwrap_or_else(KeyFlags::empty).for_authentication() } /// Returns whether the KeyFlags indicates that the key is a split /// key. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_signature_is_split_key(sig: *const Signature) -> bool { - sig.ref_raw().key_flags().unwrap_or_default().is_split_key() + sig.ref_raw().key_flags().unwrap_or_else(KeyFlags::empty).is_split_key() } /// Returns whether the KeyFlags indicates that the key is a group /// key. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_signature_is_group_key(sig: *const Signature) -> bool { - sig.ref_raw().key_flags().unwrap_or_default().is_group_key() + sig.ref_raw().key_flags().unwrap_or_else(KeyFlags::empty).is_group_key() } -- cgit v1.2.3