pub struct SecretKey(/* private fields */);
Implementations§
Source§impl SecretKey
impl SecretKey
pub fn new(details: PublicKey, secret_params: SecretParams) -> Self
Sourcepub fn from_slice(packet_version: Version, input: &[u8]) -> Result<Self>
pub fn from_slice(packet_version: Version, input: &[u8]) -> Result<Self>
Parses a SecretKey
packet from the given slice.
pub fn secret_params(&self) -> &SecretParams
Sourcepub fn has_sha1_checksum(&self) -> bool
pub fn has_sha1_checksum(&self) -> bool
Checks if we should expect a SHA1 checksum in the encrypted part.
pub fn sign<R: CryptoRng + Rng, F>( &self, rng: R, key: &impl SecretKeyTrait, key_pw: F, ) -> Result<Signature>
Source§impl SecretKey
impl SecretKey
Sourcepub fn remove_password<P>(&mut self, password: P) -> Result<()>
pub fn remove_password<P>(&mut self, password: P) -> Result<()>
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
.
Sourcepub fn set_password<R, P>(&mut self, rng: R, password: P) -> Result<()>
pub fn set_password<R, P>(&mut self, rng: R, password: P) -> Result<()>
Set a password
that “locks” the private key material in this Secret Key packet.
This function uses the default S2K locking mechanism for the key version:
- for V6 keys:
Aead
withArgon2
derivation, - for V4 keys:
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.
Sourcepub fn set_password_with_s2k<P>(
&mut self,
password: P,
s2k_params: S2kParams,
) -> Result<()>
pub fn set_password_with_s2k<P>( &mut self, password: P, s2k_params: S2kParams, ) -> Result<()>
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 PacketTrait for SecretKey
impl PacketTrait for SecretKey
Source§impl PublicKeyTrait for SecretKey
impl PublicKeyTrait for SecretKey
Source§fn verify_signature(
&self,
hash: HashAlgorithm,
hashed: &[u8],
sig: &SignatureBytes,
) -> Result<()>
fn verify_signature( &self, hash: HashAlgorithm, hashed: &[u8], sig: &SignatureBytes, ) -> Result<()>
hash
, before verifying.Source§fn encrypt<R: Rng + CryptoRng>(
&self,
rng: R,
plain: &[u8],
typ: EskType,
) -> Result<PkeskBytes>
fn encrypt<R: Rng + CryptoRng>( &self, rng: R, plain: &[u8], typ: EskType, ) -> Result<PkeskBytes>
plain
for this key.