pub struct PasswordProtectedKeyEnvelope { /* private fields */ }Expand description
A password-protected key envelope can seal a symmetric key, and protect it with a password. It does so by using a Key Derivation Function (KDF), to increase the difficulty of brute-forcing the password.
The KDF parameters such as iterations and salt are stored in the envelope and do not have to be provided.
Internally, Argon2 is used as the KDF and XChaCha20-Poly1305 is used to encrypt the key.
Implementations§
Source§impl PasswordProtectedKeyEnvelope
impl PasswordProtectedKeyEnvelope
Sourcepub fn seal<Ids: KeySlotIds>(
key_to_seal: Ids::Symmetric,
password: &str,
namespace: PasswordProtectedKeyEnvelopeNamespace,
ctx: &KeyStoreContext<'_, Ids>,
) -> Result<Self, PasswordProtectedKeyEnvelopeError>
pub fn seal<Ids: KeySlotIds>( key_to_seal: Ids::Symmetric, password: &str, namespace: PasswordProtectedKeyEnvelopeNamespace, ctx: &KeyStoreContext<'_, Ids>, ) -> Result<Self, PasswordProtectedKeyEnvelopeError>
Seals a symmetric key with a password, using the current default KDF parameters and a random salt.
This should never fail, except for memory allocation error, when running the KDF.
Sourcepub fn unseal<Ids: KeySlotIds>(
&self,
password: &str,
namespace: PasswordProtectedKeyEnvelopeNamespace,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<Ids::Symmetric, PasswordProtectedKeyEnvelopeError>
pub fn unseal<Ids: KeySlotIds>( &self, password: &str, namespace: PasswordProtectedKeyEnvelopeNamespace, ctx: &mut KeyStoreContext<'_, Ids>, ) -> Result<Ids::Symmetric, PasswordProtectedKeyEnvelopeError>
Unseals a symmetric key from the password-protected envelope, and stores it in the key store context.
Sourcepub fn reseal(
&self,
password: &str,
new_password: &str,
namespace: PasswordProtectedKeyEnvelopeNamespace,
) -> Result<Self, PasswordProtectedKeyEnvelopeError>
pub fn reseal( &self, password: &str, new_password: &str, namespace: PasswordProtectedKeyEnvelopeNamespace, ) -> Result<Self, PasswordProtectedKeyEnvelopeError>
Re-seals the key with new KDF parameters (updated settings, salt), and a new password
Sourcepub fn contained_key_id(
&self,
) -> Result<Option<KeyId>, PasswordProtectedKeyEnvelopeError>
pub fn contained_key_id( &self, ) -> Result<Option<KeyId>, PasswordProtectedKeyEnvelopeError>
Get the key ID of the contained key, if the key ID is stored on the envelope headers. Only COSE keys have a key ID, legacy keys do not.
Trait Implementations§
Source§impl Clone for PasswordProtectedKeyEnvelope
impl Clone for PasswordProtectedKeyEnvelope
Source§fn clone(&self) -> PasswordProtectedKeyEnvelope
fn clone(&self) -> PasswordProtectedKeyEnvelope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PasswordProtectedKeyEnvelope
impl Debug for PasswordProtectedKeyEnvelope
Source§impl<'de> Deserialize<'de> for PasswordProtectedKeyEnvelope
impl<'de> Deserialize<'de> for PasswordProtectedKeyEnvelope
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl From<&PasswordProtectedKeyEnvelope> for Vec<u8>
impl From<&PasswordProtectedKeyEnvelope> for Vec<u8>
Source§fn from(val: &PasswordProtectedKeyEnvelope) -> Self
fn from(val: &PasswordProtectedKeyEnvelope) -> Self
Source§impl From<PasswordProtectedKeyEnvelope> for String
impl From<PasswordProtectedKeyEnvelope> for String
Source§fn from(val: PasswordProtectedKeyEnvelope) -> Self
fn from(val: PasswordProtectedKeyEnvelope) -> Self
Auto Trait Implementations§
impl Freeze for PasswordProtectedKeyEnvelope
impl RefUnwindSafe for PasswordProtectedKeyEnvelope
impl Send for PasswordProtectedKeyEnvelope
impl Sync for PasswordProtectedKeyEnvelope
impl Unpin for PasswordProtectedKeyEnvelope
impl UnsafeUnpin for PasswordProtectedKeyEnvelope
impl UnwindSafe for PasswordProtectedKeyEnvelope
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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more