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
sourceimpl 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
sourceimpl Clone for SecretKeyMaterial
impl Clone for SecretKeyMaterial
sourcefn clone(&self) -> SecretKeyMaterial
fn clone(&self) -> SecretKeyMaterial
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SecretKeyMaterial
impl Debug for SecretKeyMaterial
sourceimpl From<Encrypted> for SecretKeyMaterial
impl From<Encrypted> for SecretKeyMaterial
sourceimpl From<SecretKeyMaterial> for SecretKeyMaterial
impl From<SecretKeyMaterial> for SecretKeyMaterial
sourcefn from(mpis: SecretKeyMaterial) -> Self
fn from(mpis: SecretKeyMaterial) -> Self
Converts to this type from the input type.
sourceimpl From<Unencrypted> for SecretKeyMaterial
impl From<Unencrypted> for SecretKeyMaterial
sourcefn from(key: Unencrypted) -> Self
fn from(key: Unencrypted) -> Self
Converts to this type from the input type.
sourceimpl Hash for SecretKeyMaterial
impl Hash for SecretKeyMaterial
sourceimpl PartialEq<SecretKeyMaterial> for SecretKeyMaterial
impl PartialEq<SecretKeyMaterial> for SecretKeyMaterial
sourcefn eq(&self, other: &SecretKeyMaterial) -> bool
fn eq(&self, other: &SecretKeyMaterial) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SecretKeyMaterial) -> bool
fn ne(&self, other: &SecretKeyMaterial) -> bool
This method tests for !=
.
impl Eq for SecretKeyMaterial
impl StructuralEq for SecretKeyMaterial
impl StructuralPartialEq for SecretKeyMaterial
Auto Trait Implementations
impl RefUnwindSafe for SecretKeyMaterial
impl Send for SecretKeyMaterial
impl Sync for SecretKeyMaterial
impl Unpin for SecretKeyMaterial
impl UnwindSafe for SecretKeyMaterial
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more