pub struct InMemoryMasterKey(/* private fields */);Expand description
In-memory master key for development and testing.
Stores the master key material directly in memory. Suitable for:
- Development and testing
- Single-node deployments with disk encryption
- Environments without HSM access
§Security
The key material is zeroed on drop via ZeroizeOnDrop. However, for
production deployments handling sensitive data, prefer an HSM-backed
implementation.
§Example
use kimberlite_crypto::encryption::{InMemoryMasterKey, MasterKeyProvider, KeyEncryptionKey};
let master = InMemoryMasterKey::generate();
let (kek, wrapped_kek) = KeyEncryptionKey::generate_and_wrap(&master);
// Store wrapped_kek.to_bytes() on disk...Implementations§
Source§impl InMemoryMasterKey
impl InMemoryMasterKey
Sourcepub fn from_bytes(bytes: &[u8; 32]) -> Self
pub fn from_bytes(bytes: &[u8; 32]) -> Self
Restores a master key from its 32-byte representation.
§Security
Only use bytes from a previously generated key or secure backup. The bytes should come from encrypted-at-rest storage.
Sourcepub fn to_bytes(&self) -> [u8; 32]
pub fn to_bytes(&self) -> [u8; 32]
Returns the raw 32-byte key material for backup.
§Security
Handle with extreme care. This is the root secret of the entire key hierarchy. Only use this for:
- Secure backup to encrypted storage
- Key escrow with proper controls
Never log, transmit unencrypted, or store in plaintext.
Trait Implementations§
Source§impl Drop for InMemoryMasterKey
impl Drop for InMemoryMasterKey
Source§impl MasterKeyProvider for InMemoryMasterKey
impl MasterKeyProvider for InMemoryMasterKey
Source§fn wrap_kek(&self, kek_bytes: &[u8; 32]) -> WrappedKey
fn wrap_kek(&self, kek_bytes: &[u8; 32]) -> WrappedKey
Wraps a Key Encryption Key for secure storage. Read more
Source§fn unwrap_kek(&self, wrapped: &WrappedKey) -> Result<[u8; 32], CryptoError>
fn unwrap_kek(&self, wrapped: &WrappedKey) -> Result<[u8; 32], CryptoError>
Unwraps a Key Encryption Key from storage. Read more
Auto Trait Implementations§
impl Freeze for InMemoryMasterKey
impl RefUnwindSafe for InMemoryMasterKey
impl Send for InMemoryMasterKey
impl Sync for InMemoryMasterKey
impl Unpin for InMemoryMasterKey
impl UnwindSafe for InMemoryMasterKey
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