pub struct PasswordProtectedKeyEnvelope {
cose_encrypt: CoseEncrypt,
}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.
Fields§
§cose_encrypt: CoseEncryptImplementations§
Source§impl PasswordProtectedKeyEnvelope
impl PasswordProtectedKeyEnvelope
Sourcepub fn seal<Ids: KeyIds>(
key_to_seal: Ids::Symmetric,
password: &str,
ctx: &KeyStoreContext<'_, Ids>,
) -> Result<Self, PasswordProtectedKeyEnvelopeError>
pub fn seal<Ids: KeyIds>( key_to_seal: Ids::Symmetric, password: &str, 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.
Sourcefn seal_ref(
key_to_seal: &SymmetricCryptoKey,
password: &str,
) -> Result<Self, PasswordProtectedKeyEnvelopeError>
fn seal_ref( key_to_seal: &SymmetricCryptoKey, password: &str, ) -> Result<Self, PasswordProtectedKeyEnvelopeError>
Seals a key reference with a password. This function is not public since callers are expected to only work with key store references.
Sourcefn seal_ref_with_settings(
key_to_seal: &SymmetricCryptoKey,
password: &str,
kdf_settings: &Argon2RawSettings,
) -> Result<Self, PasswordProtectedKeyEnvelopeError>
fn seal_ref_with_settings( key_to_seal: &SymmetricCryptoKey, password: &str, kdf_settings: &Argon2RawSettings, ) -> Result<Self, PasswordProtectedKeyEnvelopeError>
Seals a key reference with a password and custom provided settings. This function is not public since callers are expected to only work with key store references, and to not control the KDF difficulty where possible.
Sourcepub fn unseal<Ids: KeyIds>(
&self,
password: &str,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<Ids::Symmetric, PasswordProtectedKeyEnvelopeError>
pub fn unseal<Ids: KeyIds>( &self, password: &str, 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.
fn unseal_ref( &self, password: &str, ) -> Result<SymmetricCryptoKey, PasswordProtectedKeyEnvelopeError>
Trait Implementations§
Source§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 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
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<> Read moreSource§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