pub struct PasswordProtectedKeyEnvelope<Ids: KeyIds> {
_phantom: PhantomData<Ids>,
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§
§_phantom: PhantomData<Ids>
§cose_encrypt: CoseEncrypt
Implementations§
Source§impl<Ids: KeyIds> PasswordProtectedKeyEnvelope<Ids>
impl<Ids: KeyIds> PasswordProtectedKeyEnvelope<Ids>
Sourcepub fn seal(
key_to_seal: Ids::Symmetric,
password: &str,
ctx: &KeyStoreContext<'_, Ids>,
) -> Result<Self, PasswordProtectedKeyEnvelopeError>
pub fn seal( 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(
&self,
target_keyslot: Ids::Symmetric,
password: &str,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<Ids::Symmetric, PasswordProtectedKeyEnvelopeError>
pub fn unseal( &self, target_keyslot: Ids::Symmetric, 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<Ids: KeyIds> Debug for PasswordProtectedKeyEnvelope<Ids>
impl<Ids: KeyIds> Debug for PasswordProtectedKeyEnvelope<Ids>
Source§impl<'de, Ids: KeyIds> Deserialize<'de> for PasswordProtectedKeyEnvelope<Ids>
impl<'de, Ids: KeyIds> Deserialize<'de> for PasswordProtectedKeyEnvelope<Ids>
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<Ids: KeyIds> From<&PasswordProtectedKeyEnvelope<Ids>> for Vec<u8>
impl<Ids: KeyIds> From<&PasswordProtectedKeyEnvelope<Ids>> for Vec<u8>
Source§fn from(val: &PasswordProtectedKeyEnvelope<Ids>) -> Self
fn from(val: &PasswordProtectedKeyEnvelope<Ids>) -> Self
Source§impl<Ids: KeyIds> From<PasswordProtectedKeyEnvelope<Ids>> for String
impl<Ids: KeyIds> From<PasswordProtectedKeyEnvelope<Ids>> for String
Source§fn from(val: PasswordProtectedKeyEnvelope<Ids>) -> Self
fn from(val: PasswordProtectedKeyEnvelope<Ids>) -> Self
Source§impl<Ids: KeyIds> FromStr for PasswordProtectedKeyEnvelope<Ids>
impl<Ids: KeyIds> FromStr for PasswordProtectedKeyEnvelope<Ids>
Source§impl<Ids: KeyIds> Serialize for PasswordProtectedKeyEnvelope<Ids>
impl<Ids: KeyIds> Serialize for PasswordProtectedKeyEnvelope<Ids>
Auto Trait Implementations§
impl<Ids> Freeze for PasswordProtectedKeyEnvelope<Ids>
impl<Ids> RefUnwindSafe for PasswordProtectedKeyEnvelope<Ids>where
Ids: RefUnwindSafe,
impl<Ids> Send for PasswordProtectedKeyEnvelope<Ids>where
Ids: Send,
impl<Ids> Sync for PasswordProtectedKeyEnvelope<Ids>where
Ids: Sync,
impl<Ids> Unpin for PasswordProtectedKeyEnvelope<Ids>where
Ids: Unpin,
impl<Ids> UnwindSafe for PasswordProtectedKeyEnvelope<Ids>where
Ids: UnwindSafe,
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