pub struct DataKey { /* private fields */ }Expand description
The key that seals stored secrets. Keep it apart from every other key, outside the database and its backups. Zeroed on drop.
Implementations§
Source§impl DataKey
impl DataKey
Sourcepub fn seal_bytes<R: CryptoRng + ?Sized>(
&self,
rng: &mut R,
aad: &Aad,
plaintext: &[u8],
) -> Result<Vec<u8>, Error>
pub fn seal_bytes<R: CryptoRng + ?Sized>( &self, rng: &mut R, aad: &Aad, plaintext: &[u8], ) -> Result<Vec<u8>, Error>
Sourcepub fn open_bytes(&self, aad: &Aad, stored: &[u8]) -> Option<Vec<u8>>
pub fn open_bytes(&self, aad: &Aad, stored: &[u8]) -> Option<Vec<u8>>
Opens sealed bytes; None when they are plaintext, sealed under another key, bound
to another Aad or tampered with.
Sourcepub fn seal_text<R: CryptoRng + ?Sized>(
&self,
rng: &mut R,
aad: &Aad,
plaintext: &str,
) -> Result<String, Error>
pub fn seal_text<R: CryptoRng + ?Sized>( &self, rng: &mut R, aad: &Aad, plaintext: &str, ) -> Result<String, Error>
Sourcepub fn open_text(&self, aad: &Aad, stored: &str) -> Option<String>
pub fn open_text(&self, aad: &Aad, stored: &str) -> Option<String>
Opens sealed text; None as for open_bytes.
Sourcepub fn seal_totp<R: CryptoRng + ?Sized>(
&self,
rng: &mut R,
user: UserId,
secret: &TotpSecret,
) -> Result<Vec<u8>, Error>
pub fn seal_totp<R: CryptoRng + ?Sized>( &self, rng: &mut R, user: UserId, secret: &TotpSecret, ) -> Result<Vec<u8>, Error>
Sourcepub fn open_totp(
&self,
user: UserId,
stored: &[u8],
) -> Result<TotpSecret, Error>
pub fn open_totp( &self, user: UserId, stored: &[u8], ) -> Result<TotpSecret, Error>
Opens a TOTP secret of user.
§Errors
Error::Crypto when it does not open: a wrong key, another account’s value or a
plaintext leftover from latchkey 0.1.
Sourcepub fn seal_passkey<R: CryptoRng + ?Sized>(
&self,
rng: &mut R,
user: UserId,
id: PasskeyId,
passkey: &Passkey,
) -> Result<String, Error>
Available on crate feature passkeys only.
pub fn seal_passkey<R: CryptoRng + ?Sized>( &self, rng: &mut R, user: UserId, id: PasskeyId, passkey: &Passkey, ) -> Result<String, Error>
passkeys only.Trait Implementations§
Auto Trait Implementations§
impl Freeze for DataKey
impl RefUnwindSafe for DataKey
impl Send for DataKey
impl Sync for DataKey
impl Unpin for DataKey
impl UnsafeUnpin for DataKey
impl UnwindSafe for DataKey
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more