pub struct Kek { /* private fields */ }Expand description
Key Encryption Key derived from user password
Implementations§
Source§impl Kek
impl Kek
Sourcepub fn derive_from_password(password: &str, salt: &[u8]) -> CryptoResult<Self>
pub fn derive_from_password(password: &str, salt: &[u8]) -> CryptoResult<Self>
Derive a KEK from a password using Argon2id
Uses strong parameters:
- Memory: 64 MB
- Iterations: 3
- Parallelism: 4 threads
Sourcepub fn from_bytes(bytes: [u8; 32]) -> Self
pub fn from_bytes(bytes: [u8; 32]) -> Self
Create a KEK directly from raw key bytes (for testing)
Sourcepub fn encrypt_dek(&self, dek: &[u8]) -> CryptoResult<Vec<u8>>
pub fn encrypt_dek(&self, dek: &[u8]) -> CryptoResult<Vec<u8>>
Encrypt a Data Encryption Key (DEK) with this KEK
Returns: (nonce || ciphertext)
Sourcepub fn decrypt_dek(&self, encrypted_dek: &[u8]) -> CryptoResult<Vec<u8>>
pub fn decrypt_dek(&self, encrypted_dek: &[u8]) -> CryptoResult<Vec<u8>>
Decrypt a Data Encryption Key (DEK) with this KEK
Input: (nonce || ciphertext)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Kek
impl RefUnwindSafe for Kek
impl Send for Kek
impl Sync for Kek
impl Unpin for Kek
impl UnwindSafe for Kek
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