Struct SecretSubkey

Source
pub struct SecretSubkey(/* private fields */);

Implementations§

Source§

impl SecretSubkey

Source

pub fn new(details: PublicSubkey, secret_params: SecretParams) -> Self

Source

pub fn from_slice(packet_version: Version, input: &[u8]) -> Result<Self>

Parses a SecretSubkey packet from the given slice.

Source

pub fn secret_params(&self) -> &SecretParams

Source

pub fn has_sha1_checksum(&self) -> bool

Checks if we should expect a SHA1 checksum in the encrypted part.

Source

pub fn sign<R: CryptoRng + Rng, F>( &self, rng: R, key: &impl SecretKeyTrait, key_pw: F, ) -> Result<Signature>
where F: FnOnce() -> String,

Source§

impl SecretSubkey

Source

pub fn remove_password<P>(&mut self, password: P) -> Result<()>
where P: FnOnce() -> String,

Remove the password protection of the private key material in this secret key packet. This permanently “unlocks” the secret key material.

If the Secret Key material in the packet is not locked, it is left unchanged.

The current locking password for this key must be provided in password.

Source

pub fn set_password<R, P>(&mut self, rng: R, password: P) -> Result<()>
where R: Rng + CryptoRng, P: FnOnce() -> String,

Set a password that “locks” the private key material in this Secret Key packet.

This function uses the default S2K locking mechanism (Cfb with iterated and salted derivation of the password).

To change the password on a locked Secret Key packet, it needs to be unlocked using Self::remove_password before calling this function.

Source

pub fn set_password_with_s2k<P>( &mut self, password: P, s2k_params: S2kParams, ) -> Result<()>
where P: FnOnce() -> String,

Set a password that “locks” the private key material in this Secret Key packet using the mechanisms specified in s2k_params.

To change the password on a locked Secret Key packet, it needs to be unlocked using Self::remove_password before calling this function.

Trait Implementations§

Source§

impl Clone for SecretSubkey

Source§

fn clone(&self) -> SecretSubkey

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SecretSubkey

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for SecretSubkey

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<SecretSubkey> for Packet

Source§

fn from(other: SecretSubkey) -> Packet

Converts to this type from the input type.
Source§

impl PacketTrait for SecretSubkey

Source§

impl PartialEq for SecretSubkey

Source§

fn eq(&self, other: &SecretSubkey) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PublicKeyTrait for SecretSubkey

Source§

fn verify_signature( &self, hash: HashAlgorithm, hashed: &[u8], sig: &SignatureBytes, ) -> Result<()>

Verify a signed message. Data will be hashed using hash, before verifying.
Source§

fn encrypt<R: Rng + CryptoRng>( &self, rng: R, plain: &[u8], typ: EskType, ) -> Result<PkeskBytes>

Encrypt the given plain for this key.
Source§

fn serialize_for_hashing(&self, writer: &mut impl Write) -> Result<()>

This is the data used for hashing in a signature. Only uses the public portion of the key.
Source§

fn public_params(&self) -> &PublicParams

Source§

fn version(&self) -> KeyVersion

Source§

fn fingerprint(&self) -> Fingerprint

Source§

fn key_id(&self) -> KeyId

Returns the Key ID of the associated primary key.
Source§

fn algorithm(&self) -> PublicKeyAlgorithm

Source§

fn created_at(&self) -> &DateTime<Utc>

Source§

fn expiration(&self) -> Option<u16>

Source§

fn is_signing_key(&self) -> bool

Source§

fn is_encryption_key(&self) -> bool

Source§

impl SecretKeyTrait for SecretSubkey

Source§

type PublicKey = PublicSubkey

Source§

type Unlocked = SecretKeyRepr

The type representing the unlocked version of this.
Source§

fn unlock<F, G, T>(&self, pw: F, work: G) -> Result<T>
where F: FnOnce() -> String, G: FnOnce(&Self::Unlocked) -> Result<T>,

Unlock the raw data in the secret parameters.
Source§

fn create_signature<F>( &self, key_pw: F, hash: HashAlgorithm, data: &[u8], ) -> Result<SignatureBytes>
where F: FnOnce() -> String,

Source§

fn public_key(&self) -> PublicSubkey

Source§

fn hash_alg(&self) -> HashAlgorithm

The suggested hash algorithm to calculate the signature hash digest with, when using this key as a signer
Source§

impl Serialize for SecretSubkey

Source§

fn to_writer<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

fn to_bytes(&self) -> Result<Vec<u8>>

Source§

impl TryFrom<Packet> for SecretSubkey

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(other: Packet) -> Result<SecretSubkey, Self::Error>

Performs the conversion.
Source§

impl Zeroize for SecretSubkey

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl Eq for SecretSubkey

Source§

impl StructuralPartialEq for SecretSubkey

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V