Struct lock_keeper::crypto::MasterKey
source · pub struct MasterKey(EncryptionKey);
Expand description
The master key is a default-length symmetric encryption key for an AEAD scheme.
The master key is used by the client to securely encrypt their
StorageKey
. It should not be stored or saved beyond the lifetime of a
single authentication session. It should never be sent to the server or
passed out to the local calling application.
Tuple Fields§
§0: EncryptionKey
Implementations§
source§impl MasterKey
impl MasterKey
sourcepub fn derive_master_key(
export_key: Output<Sha512>
) -> Result<Self, LockKeeperError>
pub fn derive_master_key( export_key: Output<Sha512> ) -> Result<Self, LockKeeperError>
sourcepub fn create_and_encrypt_storage_key(
self,
rng: &mut (impl CryptoRng + RngCore),
user_id: &UserId
) -> Result<Encrypted<StorageKey>, LockKeeperError>
pub fn create_and_encrypt_storage_key( self, rng: &mut (impl CryptoRng + RngCore), user_id: &UserId ) -> Result<Encrypted<StorageKey>, LockKeeperError>
Create an encrypted storage key. This is part of the registration flow and is executed during a registration session with the server. This key should be sent to the server for storage.
This must be run by the client. It takes the following steps:
- Generate a new
StorageKey
to encrypt stored data with - Derive the decryption key from the master key, using the associated data
- Encrypt the storage key under the encryption key, using an AEAD scheme
- Return the encrypted storage key
sourcefn encrypt_storage_key(
self,
rng: &mut (impl CryptoRng + RngCore),
storage_key: StorageKey,
user_id: &UserId
) -> Result<Encrypted<StorageKey>, CryptoError>
fn encrypt_storage_key( self, rng: &mut (impl CryptoRng + RngCore), storage_key: StorageKey, user_id: &UserId ) -> Result<Encrypted<StorageKey>, CryptoError>
Encrypt the given StorageKey
under a derivation from the
MasterKey
using an AEAD scheme.
sourcefn derive_key(
self,
context: AssociatedData
) -> Result<EncryptionKey, CryptoError>
fn derive_key( self, context: AssociatedData ) -> Result<EncryptionKey, CryptoError>
Derive a new key from MasterKey
using AssociatedData
as the
domain separator. MasterKey
should not be used directly to
encrypt something, instead use this method to derive a key for
a specific use-case using a domain separator.
Trait Implementations§
source§impl PartialEq for MasterKey
impl PartialEq for MasterKey
impl Eq for MasterKey
impl StructuralPartialEq for MasterKey
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request