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

pub struct Key { /* 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 Key[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, 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 Key[src]

pub fn new(
    creation_time: Tm,
    pk_algo: PublicKeyAlgorithm,
    mpis: PublicKey,
    secret: Option<SecretKey>
) -> Result<Key>
[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 version(&self) -> u8[src]

Gets the key packet's version field.

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<&SecretKey>[src]

Gets the key packet's SecretKey.

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

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

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

Sets the key packet's SecretKey.

Returns the old value.

pub fn into_packet(self, tag: Tag) -> Result<Packet>[src]

Convert the Key struct to a Packet.

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 Key[src]

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 Hash for Key[src]

fn hash<H: Hash + Write>(&self, hash: &mut H)[src]

Update the Hash with a hash of the key.

impl SerializeKey for Key[src]

impl SerializeKeyInto for Key[src]

fn to_vec(&self, tag: Tag) -> Result<Vec<u8>>[src]

Serializes the packet to a vector.

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

fn from_file<P: AsRef<Path>>(path: P) -> Result<T>[src]

Reads from the given file. Read more

fn from_bytes(data: &'a [u8]) -> Result<T>[src]

Reads from the given slice. Read more

impl Eq for Key[src]

impl PartialEq<Key> for Key[src]

impl Clone for Key[src]

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

Performs copy-assignment from source. Read more

impl Display for Key[src]

impl Hash for Key[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 Debug for Key[src]

Auto Trait Implementations

impl Send for Key

impl !Sync for Key

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.