[][src]Enum sequoia_openpgp::packet::Key

pub enum Key<P: KeyParts, R: KeyRole> {
    V4(Key4<P, R>),
}

Holds a public key, public subkey, private key or private subkey packet.

See Section 5.5 of RFC 4880 for details.

Variants

V4(Key4<P, R>)

Key packet version 4.

Methods

impl<P, R> Key<P, R> where
    P: KeyParts,
    R: KeyRole
[src]

pub fn mark_parts_public(self) -> Key<PublicParts, R>[src]

Changes the key's parts tag to PublicParts.

pub fn mark_parts_public_ref(&self) -> &Key<PublicParts, R>[src]

Changes the key's parts tag to PublicParts.

pub fn mark_parts_secret(self) -> Result<Key<SecretParts, R>>[src]

Changes the key's parts tag to SecretParts.

pub fn mark_parts_secret_ref(&self) -> Result<&Key<SecretParts, R>>[src]

Changes the key's parts tag to SecretParts.

pub fn mark_parts_unspecified(self) -> Key<UnspecifiedParts, R>[src]

Changes the key's parts tag to UnspecifiedParts.

pub fn mark_parts_unspecified_ref(&self) -> &Key<UnspecifiedParts, R>[src]

Changes the key's parts tag to UnspecifiedParts.

impl<P, R> Key<P, R> where
    P: KeyParts,
    R: KeyRole
[src]

pub fn mark_role_primary(self) -> Key<P, PrimaryRole>[src]

Changes the key's role tag to PrimaryRole.

pub fn mark_role_primary_ref(&self) -> &Key<P, PrimaryRole>[src]

Changes the key's role tag to PrimaryRole.

pub fn mark_role_subordinate(self) -> Key<P, SubordinateRole>[src]

Changes the key's role tag to SubordinateRole.

pub fn mark_role_subordinate_ref(&self) -> &Key<P, SubordinateRole>[src]

Changes the key's role tag to SubordinateRole.

pub fn mark_role_unspecified(self) -> Key<P, UnspecifiedRole>[src]

Changes the key's role tag to UnspecifiedRole.

pub fn mark_role_unspecified_ref(&self) -> &Key<P, UnspecifiedRole>[src]

Changes the key's role tag to UnspecifiedRole.

impl<P: KeyParts, R: KeyRole> Key<P, R>[src]

pub fn version(&self) -> u8[src]

Gets the version.

pub fn public_cmp<PB, RB>(&self, b: &Key<PB, RB>) -> Ordering where
    PB: KeyParts,
    RB: KeyRole
[src]

Compares the public bits of two keys.

This returns Ordering::Equal if the public MPIs, version, creation time and algorithm of the two Keys match. This does not consider the packet's encoding, packet's tag or the secret key material.

impl<R: KeyRole> Key<SecretParts, R>[src]

pub fn into_keypair(self) -> Result<KeyPair>[src]

Creates a new key pair from a Key packet with an unencrypted secret key.

Errors

Fails if the secret key is missing, or encrypted.

impl<P: KeyParts> Key<P, SubordinateRole>[src]

pub fn bind<T>(
    &self,
    signer: &mut dyn Signer,
    cert: &Cert,
    signature: Builder,
    creation_time: T
) -> Result<Signature> where
    T: Into<Option<SystemTime>>, 
[src]

Creates a binding signature.

The signature binds this userid to cert. signer will be used to create a signature using signature as builder. Thehash_algo defaults to SHA512, creation_time to the current time.

This function adds a creation time subpacket, a issuer fingerprint subpacket, and a issuer subpacket to the signature.

Example

This example demonstrates how to bind this key to a Cert. Note that in general, the CertBuilder is a better way to add subkeys to a Cert.

// Generate a Cert, and create a keypair from the primary key.
let (cert, _) = CertBuilder::new().generate()?;
let mut keypair = cert.primary().clone()
    .mark_parts_secret()?.into_keypair()?;

// Let's add an encryption subkey.
let flags = KeyFlags::default().set_storage_encryption(true);
assert_eq!(cert.keys().alive().revoked(false)
               .key_flags(flags.clone()).count(),
           0);

// Generate a subkey and a binding signature.
let subkey: Key<_, key::SubordinateRole> =
    Key4::generate_ecc(false, Curve::Cv25519)?
    .into();
let builder = signature::Builder::new(SignatureType::SubkeyBinding)
    .set_key_flags(&flags)?;
let binding = subkey.bind(&mut keypair, &cert, builder, None)?;

// Now merge the key and binding signature into the Cert.
let cert = cert.merge_packets(vec![subkey.into(),
                                 binding.into()])?;

// Check that we have an encryption subkey.
assert_eq!(cert.keys().alive().revoked(false)
               .key_flags(flags).count(),
           1);

Methods from Deref<Target = Key4<P, R>>

pub fn mark_parts_public_ref(&self) -> &Key4<PublicParts, R>[src]

Changes the key's parts tag to PublicParts.

pub fn mark_parts_secret_ref(&self) -> Result<&Key4<SecretParts, R>>[src]

Changes the key's parts tag to SecretParts.

pub fn mark_parts_unspecified_ref(&self) -> &Key4<UnspecifiedParts, R>[src]

Changes the key's parts tag to UnspecifiedParts.

pub fn mark_role_primary_ref(&self) -> &Key4<P, PrimaryRole>[src]

Changes the key's role tag to PrimaryRole.

pub fn mark_role_subordinate_ref(&self) -> &Key4<P, SubordinateRole>[src]

Changes the key's role tag to SubordinateRole.

pub fn mark_role_unspecified_ref(&self) -> &Key4<P, UnspecifiedRole>[src]

Changes the key's role tag to UnspecifiedRole.

pub fn public_cmp<PB, RB>(&self, b: &Key4<PB, RB>) -> Ordering where
    PB: KeyParts,
    RB: KeyRole
[src]

Compares the public bits of two keys.

This returns Ordering::Equal if the public MPIs, creation time and algorithm of the two Key4s match. This does not consider the packet's encoding, packet's tag or the secret key material.

pub fn creation_time(&self) -> SystemTime[src]

Gets the key packet's creation time field.

pub fn set_creation_time<T>(&mut self, timestamp: T) -> Result<SystemTime> where
    T: Into<SystemTime>, 
[src]

Sets the key packet's creation time field.

pub fn pk_algo(&self) -> PublicKeyAlgorithm[src]

Gets the public key algorithm.

pub fn set_pk_algo(&mut self, pk_algo: PublicKeyAlgorithm) -> PublicKeyAlgorithm[src]

Sets the public key algorithm.

pub fn mpis(&self) -> &PublicKey[src]

Gets the key packet's MPIs.

pub fn mpis_mut(&mut self) -> &mut PublicKey[src]

Gets a mutable reference to the key packet's MPIs.

pub fn set_mpis(&mut self, mpis: PublicKey) -> PublicKey[src]

Sets the key packet's MPIs.

pub fn secret(&self) -> Option<&SecretKeyMaterial>[src]

Gets the key packet's SecretKeyMaterial.

pub fn secret_mut(&mut self) -> Option<&mut SecretKeyMaterial>[src]

Gets a mutable reference to the key packet's SecretKeyMaterial.

pub fn set_secret(
    &mut self,
    secret: Option<SecretKeyMaterial>
) -> Option<SecretKeyMaterial>
[src]

Sets the key packet's SecretKeyMaterial.

Returns the old value.

pub fn fingerprint(&self) -> Fingerprint[src]

Computes and returns the key's fingerprint as per Section 12.2 of RFC 4880.

pub fn keyid(&self) -> KeyID[src]

Computes and returns the key's key ID as per Section 12.2 of RFC 4880.

Trait Implementations

impl<P: Clone + KeyParts, R: Clone + KeyRole> Clone for Key<P, R>[src]

impl<P: Debug + KeyParts, R: Debug + KeyRole> Debug for Key<P, R>[src]

impl<P: KeyParts, R: KeyRole> Deref for Key<P, R>[src]

type Target = Key4<P, R>

The resulting type after dereferencing.

impl<P: KeyParts, R: KeyRole> DerefMut for Key<P, R>[src]

impl<P: KeyParts, R: KeyRole> Display for Key<P, R>[src]

impl<P: Eq + KeyParts, R: Eq + KeyRole> Eq for Key<P, R>[src]

impl<'_, '_, P> From<&'_ Key<P, PrimaryRole>> for &'_ Key<P, SubordinateRole> where
    P: KeyParts
[src]

impl<'_, '_, P> From<&'_ Key<P, PrimaryRole>> for &'_ Key<P, UnspecifiedRole> where
    P: KeyParts
[src]

impl<'_, '_, P> From<&'_ Key<P, SubordinateRole>> for &'_ Key<P, PrimaryRole> where
    P: KeyParts
[src]

impl<'_, '_, P> From<&'_ Key<P, SubordinateRole>> for &'_ Key<P, UnspecifiedRole> where
    P: KeyParts
[src]

impl<'_, '_, P> From<&'_ Key<P, UnspecifiedRole>> for &'_ Key<P, PrimaryRole> where
    P: KeyParts
[src]

impl<'_, '_, P> From<&'_ Key<P, UnspecifiedRole>> for &'_ Key<P, SubordinateRole> where
    P: KeyParts
[src]

impl<'_, '_> From<&'_ Key<PublicParts, PrimaryRole>> for &'_ Key<SecretParts, SubordinateRole>[src]

impl<'_, '_> From<&'_ Key<PublicParts, PrimaryRole>> for &'_ Key<SecretParts, UnspecifiedRole>[src]

impl<'_, '_> From<&'_ Key<PublicParts, PrimaryRole>> for &'_ Key<UnspecifiedParts, SubordinateRole>[src]

impl<'_, '_> From<&'_ Key<PublicParts, PrimaryRole>> for &'_ Key<UnspecifiedParts, UnspecifiedRole>[src]

impl<'_, '_, R> From<&'_ Key<PublicParts, R>> for &'_ Key<UnspecifiedParts, R> where
    R: KeyRole
[src]

impl<'_, '_> From<&'_ Key<PublicParts, SubordinateRole>> for &'_ Key<SecretParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<PublicParts, SubordinateRole>> for &'_ Key<SecretParts, UnspecifiedRole>[src]

impl<'_, '_> From<&'_ Key<PublicParts, SubordinateRole>> for &'_ Key<UnspecifiedParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<PublicParts, SubordinateRole>> for &'_ Key<UnspecifiedParts, UnspecifiedRole>[src]

impl<'_, '_> From<&'_ Key<PublicParts, UnspecifiedRole>> for &'_ Key<SecretParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<PublicParts, UnspecifiedRole>> for &'_ Key<SecretParts, SubordinateRole>[src]

impl<'_, '_> From<&'_ Key<PublicParts, UnspecifiedRole>> for &'_ Key<UnspecifiedParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<PublicParts, UnspecifiedRole>> for &'_ Key<UnspecifiedParts, SubordinateRole>[src]

impl<'_, '_> From<&'_ Key<SecretParts, PrimaryRole>> for &'_ Key<PublicParts, SubordinateRole>[src]

impl<'_, '_> From<&'_ Key<SecretParts, PrimaryRole>> for &'_ Key<PublicParts, UnspecifiedRole>[src]

impl<'_, '_> From<&'_ Key<SecretParts, PrimaryRole>> for &'_ Key<UnspecifiedParts, SubordinateRole>[src]

impl<'_, '_> From<&'_ Key<SecretParts, PrimaryRole>> for &'_ Key<UnspecifiedParts, UnspecifiedRole>[src]

impl<'_, '_, R> From<&'_ Key<SecretParts, R>> for &'_ Key<PublicParts, R> where
    R: KeyRole
[src]

impl<'_, '_, R> From<&'_ Key<SecretParts, R>> for &'_ Key<UnspecifiedParts, R> where
    R: KeyRole
[src]

impl<'_, '_> From<&'_ Key<SecretParts, SubordinateRole>> for &'_ Key<PublicParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<SecretParts, SubordinateRole>> for &'_ Key<PublicParts, UnspecifiedRole>[src]

impl<'_, '_> From<&'_ Key<SecretParts, SubordinateRole>> for &'_ Key<UnspecifiedParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<SecretParts, SubordinateRole>> for &'_ Key<UnspecifiedParts, UnspecifiedRole>[src]

impl<'_, '_> From<&'_ Key<SecretParts, UnspecifiedRole>> for &'_ Key<PublicParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<SecretParts, UnspecifiedRole>> for &'_ Key<PublicParts, SubordinateRole>[src]

impl<'_, '_> From<&'_ Key<SecretParts, UnspecifiedRole>> for &'_ Key<UnspecifiedParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<SecretParts, UnspecifiedRole>> for &'_ Key<UnspecifiedParts, SubordinateRole>[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, PrimaryRole>> for &'_ Key<PublicParts, SubordinateRole>[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, PrimaryRole>> for &'_ Key<PublicParts, UnspecifiedRole>[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, PrimaryRole>> for &'_ Key<SecretParts, SubordinateRole>[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, PrimaryRole>> for &'_ Key<SecretParts, UnspecifiedRole>[src]

impl<'_, '_, R> From<&'_ Key<UnspecifiedParts, R>> for &'_ Key<PublicParts, R> where
    R: KeyRole
[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, SubordinateRole>> for &'_ Key<PublicParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, SubordinateRole>> for &'_ Key<PublicParts, UnspecifiedRole>[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, SubordinateRole>> for &'_ Key<SecretParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, SubordinateRole>> for &'_ Key<SecretParts, UnspecifiedRole>[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, UnspecifiedRole>> for &'_ Key<PublicParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, UnspecifiedRole>> for &'_ Key<PublicParts, SubordinateRole>[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, UnspecifiedRole>> for &'_ Key<SecretParts, PrimaryRole>[src]

impl<'_, '_> From<&'_ Key<UnspecifiedParts, UnspecifiedRole>> for &'_ Key<SecretParts, SubordinateRole>[src]

impl<'a> From<&'a Key<PublicParts, UnspecifiedRole>> for Recipient<'a>[src]

impl<P> From<Key<P, PrimaryRole>> for Key<P, SubordinateRole> where
    P: KeyParts
[src]

impl<P> From<Key<P, PrimaryRole>> for Key<P, UnspecifiedRole> where
    P: KeyParts
[src]

impl<P> From<Key<P, SubordinateRole>> for Key<P, PrimaryRole> where
    P: KeyParts
[src]

impl<P> From<Key<P, SubordinateRole>> for Key<P, UnspecifiedRole> where
    P: KeyParts
[src]

impl<P> From<Key<P, UnspecifiedRole>> for Key<P, PrimaryRole> where
    P: KeyParts
[src]

impl<P> From<Key<P, UnspecifiedRole>> for Key<P, SubordinateRole> where
    P: KeyParts
[src]

impl From<Key<PublicParts, PrimaryRole>> for Key<SecretParts, SubordinateRole>[src]

impl From<Key<PublicParts, PrimaryRole>> for Key<SecretParts, UnspecifiedRole>[src]

impl From<Key<PublicParts, PrimaryRole>> for Key<UnspecifiedParts, SubordinateRole>[src]

impl From<Key<PublicParts, PrimaryRole>> for Key<UnspecifiedParts, UnspecifiedRole>[src]

impl From<Key<PublicParts, PrimaryRole>> for Packet[src]

fn from(k: Key<PublicParts, PrimaryRole>) -> Self[src]

Convert the Key struct to a Packet.

impl<R> From<Key<PublicParts, R>> for Key<UnspecifiedParts, R> where
    R: KeyRole
[src]

impl From<Key<PublicParts, SubordinateRole>> for Key<SecretParts, PrimaryRole>[src]

impl From<Key<PublicParts, SubordinateRole>> for Key<SecretParts, UnspecifiedRole>[src]

impl From<Key<PublicParts, SubordinateRole>> for Key<UnspecifiedParts, PrimaryRole>[src]

impl From<Key<PublicParts, SubordinateRole>> for Key<UnspecifiedParts, UnspecifiedRole>[src]

impl From<Key<PublicParts, SubordinateRole>> for Packet[src]

fn from(k: Key<PublicParts, SubordinateRole>) -> Self[src]

Convert the Key struct to a Packet.

impl From<Key<PublicParts, UnspecifiedRole>> for Key<SecretParts, PrimaryRole>[src]

impl From<Key<PublicParts, UnspecifiedRole>> for Key<SecretParts, SubordinateRole>[src]

impl From<Key<PublicParts, UnspecifiedRole>> for Key<UnspecifiedParts, PrimaryRole>[src]

impl From<Key<PublicParts, UnspecifiedRole>> for Key<UnspecifiedParts, SubordinateRole>[src]

impl From<Key<SecretParts, PrimaryRole>> for Key<PublicParts, SubordinateRole>[src]

impl From<Key<SecretParts, PrimaryRole>> for Key<PublicParts, UnspecifiedRole>[src]

impl From<Key<SecretParts, PrimaryRole>> for Key<UnspecifiedParts, SubordinateRole>[src]

impl From<Key<SecretParts, PrimaryRole>> for Key<UnspecifiedParts, UnspecifiedRole>[src]

impl From<Key<SecretParts, PrimaryRole>> for Packet[src]

fn from(k: Key<SecretParts, PrimaryRole>) -> Self[src]

Convert the Key struct to a Packet.

impl<R> From<Key<SecretParts, R>> for Key<PublicParts, R> where
    R: KeyRole
[src]

impl<R> From<Key<SecretParts, R>> for Key<UnspecifiedParts, R> where
    R: KeyRole
[src]

impl From<Key<SecretParts, SubordinateRole>> for Key<PublicParts, PrimaryRole>[src]

impl From<Key<SecretParts, SubordinateRole>> for Key<PublicParts, UnspecifiedRole>[src]

impl From<Key<SecretParts, SubordinateRole>> for Key<UnspecifiedParts, PrimaryRole>[src]

impl From<Key<SecretParts, SubordinateRole>> for Key<UnspecifiedParts, UnspecifiedRole>[src]

impl From<Key<SecretParts, SubordinateRole>> for Packet[src]

fn from(k: Key<SecretParts, SubordinateRole>) -> Self[src]

Convert the Key struct to a Packet.

impl From<Key<SecretParts, UnspecifiedRole>> for Key<PublicParts, PrimaryRole>[src]

impl From<Key<SecretParts, UnspecifiedRole>> for Key<PublicParts, SubordinateRole>[src]

impl From<Key<SecretParts, UnspecifiedRole>> for Key<UnspecifiedParts, PrimaryRole>[src]

impl From<Key<SecretParts, UnspecifiedRole>> for Key<UnspecifiedParts, SubordinateRole>[src]

impl From<Key<UnspecifiedParts, PrimaryRole>> for Key<PublicParts, SubordinateRole>[src]

impl From<Key<UnspecifiedParts, PrimaryRole>> for Key<PublicParts, UnspecifiedRole>[src]

impl From<Key<UnspecifiedParts, PrimaryRole>> for Key<SecretParts, SubordinateRole>[src]

impl From<Key<UnspecifiedParts, PrimaryRole>> for Key<SecretParts, UnspecifiedRole>[src]

impl<R> From<Key<UnspecifiedParts, R>> for Key<PublicParts, R> where
    R: KeyRole
[src]

impl From<Key<UnspecifiedParts, SubordinateRole>> for Key<PublicParts, PrimaryRole>[src]

impl From<Key<UnspecifiedParts, SubordinateRole>> for Key<PublicParts, UnspecifiedRole>[src]

impl From<Key<UnspecifiedParts, SubordinateRole>> for Key<SecretParts, PrimaryRole>[src]

impl From<Key<UnspecifiedParts, SubordinateRole>> for Key<SecretParts, UnspecifiedRole>[src]

impl From<Key<UnspecifiedParts, UnspecifiedRole>> for Key<PublicParts, PrimaryRole>[src]

impl From<Key<UnspecifiedParts, UnspecifiedRole>> for Key<PublicParts, SubordinateRole>[src]

impl From<Key<UnspecifiedParts, UnspecifiedRole>> for Key<SecretParts, PrimaryRole>[src]

impl From<Key<UnspecifiedParts, UnspecifiedRole>> for Key<SecretParts, SubordinateRole>[src]

impl<P, R> From<Key4<P, R>> for Key<P, R> where
    P: KeyParts,
    R: KeyRole
[src]

impl From<KeyPair> for Key<SecretParts, UnspecifiedRole>[src]

impl<P: Hash + KeyParts, R: Hash + KeyRole> Hash for Key<P, R>[src]

impl<'a> Parse<'a, Key<UnspecifiedParts, UnspecifiedRole>> for Key<UnspecifiedParts, UnspecifiedRole>[src]

impl<P: PartialEq + KeyParts, R: PartialEq + KeyRole> PartialEq<Key<P, R>> for Key<P, R>[src]

impl<P: KeyParts, R: KeyRole> Serialize for Key<P, R>[src]

impl<P: KeyParts, R: KeyRole> SerializeInto for Key<P, R>[src]

impl<P: KeyParts, R: KeyRole> StructuralEq for Key<P, R>[src]

impl<P: KeyParts, R: KeyRole> StructuralPartialEq for Key<P, R>[src]

impl<'_, '_, R> TryFrom<&'_ Key<PublicParts, R>> for &'_ Key<SecretParts, R> where
    R: KeyRole
[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'_, '_, R> TryFrom<&'_ Key<UnspecifiedParts, R>> for &'_ Key<SecretParts, R> where
    R: KeyRole
[src]

type Error = Error

The type returned in the event of a conversion error.

impl<R> TryFrom<Key<PublicParts, R>> for Key<SecretParts, R> where
    R: KeyRole
[src]

type Error = Error

The type returned in the event of a conversion error.

impl<R> TryFrom<Key<UnspecifiedParts, R>> for Key<SecretParts, R> where
    R: KeyRole
[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<P, R> RefUnwindSafe for Key<P, R> where
    P: RefUnwindSafe,
    R: RefUnwindSafe

impl<P, R> Send for Key<P, R> where
    P: Send,
    R: Send

impl<P, R> Sync for Key<P, R> where
    P: Sync,
    R: Sync

impl<P, R> Unpin for Key<P, R> where
    P: Unpin,
    R: Unpin

impl<P, R> UnwindSafe for Key<P, R> where
    P: UnwindSafe,
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,