[][src]Struct sequoia_openpgp::packet::key::Key4

pub struct Key4<P, R> where
    P: KeyParts,
    R: KeyRole
{ /* fields omitted */ }

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

See Section 5.5 of RFC 4880 for details.

Methods

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

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

Changes the key's parts tag to PublicParts.

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

Changes the key's parts tag to PublicParts.

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

Changes the key's parts tag to SecretParts.

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

Changes the key's parts tag to SecretParts.

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

Changes the key's parts tag to UnspecifiedParts.

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

Changes the key's parts tag to UnspecifiedParts.

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

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

Changes the key's role tag to PrimaryRole.

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

Changes the key's role tag to PrimaryRole.

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

Changes the key's role tag to SubordinateRole.

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

Changes the key's role tag to SubordinateRole.

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

Changes the key's role tag to UnspecifiedRole.

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

Changes the key's role tag to UnspecifiedRole.

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

pub fn public_cmp(a: &Self, b: &Self) -> Ordering[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.

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

pub fn new(
    creation_time: Tm,
    pk_algo: PublicKeyAlgorithm,
    mpis: PublicKey,
    secret: Option<SecretKeyMaterial>
) -> Result<Self>
[src]

Creates a new OpenPGP key packet.

pub fn import_public_cv25519<H, S, T>(
    public_key: &[u8],
    hash: H,
    sym: S,
    ctime: T
) -> Result<Self> where
    H: Into<Option<HashAlgorithm>>,
    S: Into<Option<SymmetricAlgorithm>>,
    T: Into<Option<Tm>>, 
[src]

Creates a new OpenPGP public key packet for an existing X25519 key.

The ECDH key will use hash algorithm hash and symmetric algorithm sym. If one or both are None secure defaults will be used. The key will have it's creation date set to ctime or the current time if None is given.

pub fn import_secret_cv25519<H, S, T>(
    private_key: &[u8],
    hash: H,
    sym: S,
    ctime: T
) -> Result<Self> where
    H: Into<Option<HashAlgorithm>>,
    S: Into<Option<SymmetricAlgorithm>>,
    T: Into<Option<Tm>>, 
[src]

Creates a new OpenPGP secret key packet for an existing X25519 key.

The ECDH key will use hash algorithm hash and symmetric algorithm sym. If one or both are None secure defaults will be used. The key will have it's creation date set to ctime or the current time if None is given.

pub fn import_public_ed25519<T>(public_key: &[u8], ctime: T) -> Result<Self> where
    T: Into<Option<Tm>>, 
[src]

Creates a new OpenPGP public key packet for an existing Ed25519 key.

The ECDH key will use hash algorithm hash and symmetric algorithm sym. If one or both are None secure defaults will be used. The key will have it's creation date set to ctime or the current time if None is given.

pub fn import_secret_ed25519<T>(private_key: &[u8], ctime: T) -> Result<Self> where
    T: Into<Option<Tm>>, 
[src]

Creates a new OpenPGP secret key packet for an existing Ed25519 key.

The ECDH key will use hash algorithm hash and symmetric algorithm sym. If one or both are None secure defaults will be used. The key will have it's creation date set to ctime or the current time if None is given.

pub fn import_public_rsa<T>(e: &[u8], n: &[u8], ctime: T) -> Result<Self> where
    T: Into<Option<Tm>>, 
[src]

Creates a new OpenPGP public key packet for an existing RSA key.

The RSA key will use public exponent e and modulo n. The key will have it's creation date set to ctime or the current time if None is given.

pub fn import_secret_rsa<T>(
    d: &[u8],
    p: &[u8],
    q: &[u8],
    ctime: T
) -> Result<Self> where
    T: Into<Option<Tm>>, 
[src]

Creates a new OpenPGP public key packet for an existing RSA key.

The RSA key will use public exponent e and modulo n. The key will have it's creation date set to ctime or the current time if None is given.

pub fn generate_rsa(bits: usize) -> Result<Self>[src]

Generates a new RSA key with a public modulos of size bits.

pub fn generate_ecc(for_signing: bool, curve: Curve) -> Result<Self>[src]

Generates a new ECC key over curve.

If for_signing is false a ECDH key, if it's true either a EdDSA or ECDSA key is generated. Giving for_signing == true and curve == Cv25519 will produce an error. Similar for for_signing == false and curve == Ed25519. signing/encryption

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

Gets the key packet's creation time field.

pub fn set_creation_time(&mut self, timestamp: Tm) -> Tm[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, R> Hash for Key4<P, R> where
    P: KeyParts,
    R: KeyRole
[src]

fn hash(&self, hash: &mut Context)[src]

Update the Hash with a hash of the key.

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

fn export(&self, o: &mut dyn Write) -> Result<()>[src]

Exports a serialized version of the object to o. Read more

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

fn to_vec(&self) -> Result<Vec<u8>>[src]

Serializes the packet to a vector.

fn export_into(&self, buf: &mut [u8]) -> Result<usize>[src]

Exports into the given buffer. Read more

fn export_to_vec(&self) -> Result<Vec<u8>>[src]

Exports to a vector. Read more

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

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

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

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

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

Auto Trait Implementations

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

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

Blanket Implementations

impl<T> From for T[src]

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

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

type Owned = T

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

impl<T, U> TryInto 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 for T where
    V: MultiLane<T>,