[−][src]Enum sequoia_openpgp::KeyHandle
Enum representing an identifier for certificates and keys.
A KeyHandle contains either a Fingerprint or a KeyID.
This is needed because signatures can reference their issuer
either by Fingerprint or by KeyID.
Currently, sequoia supports version 4 fingerprints and Key ID only. Version 3 fingerprints and Key ID were deprecated by RFC 4880 in 2007.
A v4 fingerprint is, essentially, a 20-byte SHA-1 hash over the key's public key packet. A v4 Key ID is defined as the fingerprint's lower 8 bytes.
For the exact definition, see Section 12.2 of RFC 4880.
Both fingerprint and Key ID are used to identify a key, e.g., the issuer of a signature.
Examples
use openpgp::KeyHandle; use openpgp::Packet; use openpgp::parse::Parse; let p = Packet::from_bytes( "-----BEGIN PGP SIGNATURE----- // ... -----END PGP SIGNATURE-----")?; if let Packet::Signature(sig) = p { let issuers = sig.get_issuers(); assert_eq!(issuers.len(), 2); assert_eq!(&issuers[0], &KeyHandle::Fingerprint( "C03F A641 1B03 AE12 5764 6118 7223 B566 78E0 2528" .parse()?)); assert_eq!(&issuers[1], &KeyHandle::KeyID("7223 B566 78E0 2528".parse()?)); } else { unreachable!("It's a signature!"); }
Variants
Fingerprint(Fingerprint)A Fingerprint.
KeyID(KeyID)A KeyID.
Implementations
impl KeyHandle[src]
pub fn as_bytes(&self) -> &[u8][src]
Returns the raw identifier as a byte slice.
pub fn aliases<H>(&self, other: H) -> bool where
H: Borrow<KeyHandle>, [src]
H: Borrow<KeyHandle>,
Returns whether self and other could be aliases of each
other.
KeyHandle's PartialEq implementation cannot assert that a
Fingerprint and a KeyID are equal, because distinct
fingerprints may have the same KeyID, and PartialEq must
be transitive, i.e.,
a == b and b == c implies a == c.
That is, if fpr1 and fpr2 are distinct fingerprints with the
same key ID then:
fpr1 == keyid and fpr2 == keyid, but fpr1 != fpr2.
In these cases (and only these cases) KeyHandle's
PartialOrd implementation returns None to correctly
indicate that a comparison is not possible.
This definition of equality makes searching for a given
KeyHandle using PartialEq awkward. This function fills
that gap. It answers the question: given two KeyHandles,
could they be aliases? That is, it implements the desired,
non-transitive equality relation:
// fpr1 and fpr2 are different fingerprints with the same KeyID. assert!(! fpr1.eq(&fpr2)); assert!(fpr1.aliases(&keyid)); assert!(fpr2.aliases(&keyid)); assert!(! fpr1.aliases(&fpr2));
Trait Implementations
impl Clone for KeyHandle[src]
impl Debug for KeyHandle[src]
impl Display for KeyHandle[src]
impl<'_> From<&'_ Fingerprint> for KeyHandle[src]
pub fn from(i: &Fingerprint) -> Self[src]
impl<'_> From<&'_ KeyHandle> for KeyID[src]
impl<'_> From<&'_ KeyID> for KeyHandle[src]
impl From<Fingerprint> for KeyHandle[src]
pub fn from(i: Fingerprint) -> Self[src]
impl From<KeyHandle> for KeyID[src]
impl From<KeyID> for KeyHandle[src]
impl LowerHex for KeyHandle[src]
impl PartialEq<KeyHandle> for KeyHandle[src]
pub fn eq(&self, other: &Self) -> bool[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialOrd<KeyHandle> for KeyHandle[src]
pub fn partial_cmp(&self, other: &KeyHandle) -> Option<Ordering>[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> TryFrom<&'_ KeyHandle> for Fingerprint[src]
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(i: &KeyHandle) -> Result<Self>[src]
impl TryFrom<KeyHandle> for Fingerprint[src]
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(i: KeyHandle) -> Result<Self>[src]
impl UpperHex for KeyHandle[src]
Auto Trait Implementations
impl RefUnwindSafe for KeyHandle[src]
impl Send for KeyHandle[src]
impl Sync for KeyHandle[src]
impl Unpin for KeyHandle[src]
impl UnwindSafe for KeyHandle[src]
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,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DynClone for T where
T: Clone, [src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
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.
pub 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>,