pub struct MasterKey(SymmetricCryptoKey);
Expand description
Master Key.
Derived from the users master password, used to protect the UserKey.
Tuple Fields§
§0: SymmetricCryptoKey
Implementations§
Source§impl MasterKey
impl MasterKey
pub fn new(key: SymmetricCryptoKey) -> Self
Sourcepub fn generate(rng: impl RngCore) -> Self
pub fn generate(rng: impl RngCore) -> Self
Generate a new random master key. Primarily used for KeyConnector.
Sourcepub fn derive(
password: &str,
email: &str,
kdf: &Kdf,
) -> Result<Self, CryptoError>
pub fn derive( password: &str, email: &str, kdf: &Kdf, ) -> Result<Self, CryptoError>
Derives a users master key from their password, email and KDF.
Note: the email is trimmed and converted to lowercase before being used.
Sourcepub fn derive_master_key_hash(
&self,
password: &[u8],
purpose: HashPurpose,
) -> Result<String, CryptoError>
pub fn derive_master_key_hash( &self, password: &[u8], purpose: HashPurpose, ) -> Result<String, CryptoError>
Derive the master key hash, used for local and remote password validation.
Sourcepub fn make_user_key(&self) -> Result<(UserKey, EncString), CryptoError>
pub fn make_user_key(&self) -> Result<(UserKey, EncString), CryptoError>
Generate a new random user key and encrypt it with the master key.
Sourcepub fn encrypt_user_key(
&self,
user_key: &SymmetricCryptoKey,
) -> Result<EncString, CryptoError>
pub fn encrypt_user_key( &self, user_key: &SymmetricCryptoKey, ) -> Result<EncString, CryptoError>
Encrypt the users user key
Sourcepub fn decrypt_user_key(
&self,
user_key: EncString,
) -> Result<SymmetricCryptoKey, CryptoError>
pub fn decrypt_user_key( &self, user_key: EncString, ) -> Result<SymmetricCryptoKey, CryptoError>
Decrypt the users user key
pub fn to_base64(&self) -> String
Auto Trait Implementations§
impl Freeze for MasterKey
impl RefUnwindSafe for MasterKey
impl Send for MasterKey
impl Sync for MasterKey
impl Unpin for MasterKey
impl UnwindSafe for MasterKey
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
Mutably borrows from an owned value. Read more
§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
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
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>
Converts
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>
Converts
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