[−][src]Struct sequoia_openpgp::types::KeyFlags
Describes how a key may be used, and stores additional information.
Key flags are described in Section 5.2.3.21 of RFC 4880 and Section 5.2.3.22 of RFC 4880bis.
A note on equality
PartialEq
compares the serialized form of the key flag sets. If
you prefer to compare two key flag sets for semantic equality, you
should use KeyFlags::normalized_eq
. The difference between
semantic equality and serialized equality is that semantic
equality ignores differences in the amount of padding.
Examples
use sequoia_openpgp as openpgp; use openpgp::cert::prelude::*; use openpgp::policy::StandardPolicy; let p = &StandardPolicy::new(); let (cert, _) = CertBuilder::new() .add_userid("Alice <alice@example.com>") .add_transport_encryption_subkey() .generate()?; for subkey in cert.with_policy(p, None)?.keys().subkeys() { // Key contains one Encryption subkey: assert!(subkey.key_flags().unwrap().for_transport_encryption()); }
Implementations
impl KeyFlags
[src]
pub fn new<B: AsRef<[u8]>>(bits: B) -> Self
[src]
Creates a new instance from bits
.
pub fn empty() -> Self
[src]
Returns a new KeyFlags
with all capabilities disabled.
pub fn normalized_eq(&self, other: &Self) -> bool
[src]
Compares two key flag sets for semantic equality.
KeyFlags
' implementation of PartialEq
compares two key
flag sets for serialized equality. That is, the PartialEq
implementation considers two key flag sets to not be equal
if they have different amounts of padding. This comparison
function ignores padding.
Examples
use sequoia_openpgp as openpgp; use openpgp::types::KeyFlags; let a = KeyFlags::new(&[0x1]); let b = KeyFlags::new(&[0x1, 0x0]); assert!(a != b); assert!(a.normalized_eq(&b));
pub fn get(&self, bit: usize) -> bool
[src]
Returns whether the specified key flag is set.
Examples
use sequoia_openpgp as openpgp; use openpgp::types::KeyFlags; // Key flags 0 and 2. let kf = KeyFlags::new(&[0x5]); assert!(kf.get(0)); assert!(! kf.get(1)); assert!(kf.get(2)); assert!(! kf.get(3)); assert!(! kf.get(8)); assert!(! kf.get(80));
pub fn set(self, bit: usize) -> Self
[src]
Sets the specified key flag.
This also clears any padding (trailing NUL bytes).
Examples
use sequoia_openpgp as openpgp; use openpgp::types::KeyFlags; let kf = KeyFlags::empty().set(0).set(2); assert!(kf.get(0)); assert!(! kf.get(1)); assert!(kf.get(2)); assert!(! kf.get(3));
pub fn clear(self, bit: usize) -> Self
[src]
Clears the specified key flag.
This also clears any padding (trailing NUL bytes).
Examples
use sequoia_openpgp as openpgp; use openpgp::types::KeyFlags; let kf = KeyFlags::empty().set(0).set(2).clear(2); assert!(kf.get(0)); assert!(! kf.get(1)); assert!(! kf.get(2)); assert!(! kf.get(3));
pub fn for_certification(&self) -> bool
[src]
This key may be used to certify other keys.
pub fn set_certification(self) -> Self
[src]
Declares that this key may be used to certify other keys.
pub fn clear_certification(self) -> Self
[src]
Declares that this key may not be used to certify other keys.
pub fn for_signing(&self) -> bool
[src]
This key may be used to sign data.
pub fn set_signing(self) -> Self
[src]
Declares that this key may be used to sign data.
pub fn clear_signing(self) -> Self
[src]
Declares that this key may not be used to sign data.
pub fn for_transport_encryption(&self) -> bool
[src]
This key may be used to encrypt communications.
pub fn set_transport_encryption(self) -> Self
[src]
Declares that this key may be used to encrypt communications.
pub fn clear_transport_encryption(self) -> Self
[src]
Declares that this key may not be used to encrypt communications.
pub fn for_storage_encryption(&self) -> bool
[src]
This key may be used to encrypt storage.
pub fn set_storage_encryption(self) -> Self
[src]
Declares that this key may be used to encrypt storage.
pub fn clear_storage_encryption(self) -> Self
[src]
Declares that this key may not be used to encrypt storage.
pub fn for_authentication(&self) -> bool
[src]
This key may be used for authentication.
pub fn set_authentication(self) -> Self
[src]
Declares that this key may be used for authentication.
pub fn clear_authentication(self) -> Self
[src]
Declares that this key may not be used for authentication.
pub fn is_split_key(&self) -> bool
[src]
The private component of this key may have been split using a secret-sharing mechanism.
pub fn set_split_key(self) -> Self
[src]
Declares that the private component of this key may have been split using a secret-sharing mechanism.
pub fn clear_split_key(self) -> Self
[src]
Declares that the private component of this key has not been split using a secret-sharing mechanism.
pub fn is_group_key(&self) -> bool
[src]
The private component of this key may be in possession of more than one person.
pub fn set_group_key(self) -> Self
[src]
Declares that the private component of this key should not be in possession of more than one person.
pub fn is_empty(&self) -> bool
[src]
Returns whether no flags are set.
Trait Implementations
impl<'_> BitAnd<&'_ KeyFlags> for &'_ KeyFlags
[src]
type Output = KeyFlags
The resulting type after applying the &
operator.
fn bitand(self, rhs: Self) -> KeyFlags
[src]
impl<'_> BitOr<&'_ KeyFlags> for &'_ KeyFlags
[src]
type Output = KeyFlags
The resulting type after applying the |
operator.
fn bitor(self, rhs: Self) -> KeyFlags
[src]
impl Clone for KeyFlags
[src]
impl Debug for KeyFlags
[src]
impl Eq for KeyFlags
[src]
impl Hash for KeyFlags
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<KeyFlags> for KeyFlags
[src]
impl StructuralEq for KeyFlags
[src]
impl StructuralPartialEq for KeyFlags
[src]
Auto Trait Implementations
impl RefUnwindSafe for KeyFlags
impl Send for KeyFlags
impl Sync for KeyFlags
impl Unpin for KeyFlags
impl UnwindSafe for KeyFlags
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,