Enum sequoia_openpgp::packet::key::SecretKeyMaterial
source · pub enum SecretKeyMaterial {
Unencrypted(Unencrypted),
Encrypted(Encrypted),
}
Expand description
Holds secret key material.
This type allows postponing the decryption of the secret key material until it is actually needed.
If the secret key material is not encrypted with a password, then we encrypt it in memory. This helps protect against heartbleed-style attacks where a buffer over-read allows an attacker to read from the process’s address space. This protection is less important for Rust programs, which are memory safe. However, it is essential when Sequoia is used via its FFI.
See crypto::mem::Encrypted
for details.
Variants§
Unencrypted(Unencrypted)
Unencrypted secret key. Can be used as-is.
Encrypted(Encrypted)
The secret key is encrypted with a password.
Implementations§
source§impl SecretKeyMaterial
impl SecretKeyMaterial
sourcepub fn decrypt(
self,
pk_algo: PublicKeyAlgorithm,
password: &Password,
) -> Result<Self>
pub fn decrypt( self, pk_algo: PublicKeyAlgorithm, password: &Password, ) -> Result<Self>
Decrypts the secret key material using password
.
The SecretKeyMaterial
type does not know what kind of key it
contains. So, in order to know how many MPIs to parse, the
public key algorithm needs to be provided explicitly.
This returns an error if the secret key material is not encrypted or the password is incorrect.
sourcepub fn decrypt_in_place(
&mut self,
pk_algo: PublicKeyAlgorithm,
password: &Password,
) -> Result<()>
pub fn decrypt_in_place( &mut self, pk_algo: PublicKeyAlgorithm, password: &Password, ) -> Result<()>
Decrypts the secret key material using password
.
The SecretKeyMaterial
type does not know what kind of key it
contains. So, in order to know how many MPIs to parse, the
public key algorithm needs to be provided explicitly.
This returns an error if the secret key material is not encrypted or the password is incorrect.
sourcepub fn encrypt(self, password: &Password) -> Result<Self>
pub fn encrypt(self, password: &Password) -> Result<Self>
Encrypts the secret key material using password
.
This returns an error if the secret key material is encrypted.
See Unencrypted::encrypt
for details.
sourcepub fn encrypt_in_place(&mut self, password: &Password) -> Result<()>
pub fn encrypt_in_place(&mut self, password: &Password) -> Result<()>
Encrypts the secret key material using password
.
This returns an error if the secret key material is encrypted.
See Unencrypted::encrypt
for details.
sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Returns whether the secret key material is encrypted.
Trait Implementations§
source§impl Clone for SecretKeyMaterial
impl Clone for SecretKeyMaterial
source§fn clone(&self) -> SecretKeyMaterial
fn clone(&self) -> SecretKeyMaterial
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SecretKeyMaterial
impl Debug for SecretKeyMaterial
source§impl From<Encrypted> for SecretKeyMaterial
impl From<Encrypted> for SecretKeyMaterial
source§impl From<SecretKeyMaterial> for SecretKeyMaterial
impl From<SecretKeyMaterial> for SecretKeyMaterial
source§fn from(mpis: SecretKeyMaterial) -> Self
fn from(mpis: SecretKeyMaterial) -> Self
source§impl From<Unencrypted> for SecretKeyMaterial
impl From<Unencrypted> for SecretKeyMaterial
source§fn from(key: Unencrypted) -> Self
fn from(key: Unencrypted) -> Self
source§impl Hash for SecretKeyMaterial
impl Hash for SecretKeyMaterial
source§impl PartialEq for SecretKeyMaterial
impl PartialEq for SecretKeyMaterial
source§fn eq(&self, other: &SecretKeyMaterial) -> bool
fn eq(&self, other: &SecretKeyMaterial) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for SecretKeyMaterial
impl StructuralPartialEq for SecretKeyMaterial
Auto Trait Implementations§
impl Freeze for SecretKeyMaterial
impl RefUnwindSafe for SecretKeyMaterial
impl Send for SecretKeyMaterial
impl Sync for SecretKeyMaterial
impl Unpin for SecretKeyMaterial
impl UnwindSafe for SecretKeyMaterial
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)