pub struct Kek(/* private fields */);Expand description
Table-level Key-Encryption Key. Derived from a passphrase + salt via Argon2id (the extract step, memory-hard) followed by HKDF-SHA256 expand (domain separation). Never persisted; reconstructable only from the passphrase plus the stored salt.
Implementations§
Source§impl Kek
impl Kek
Sourcepub fn derive(passphrase: &str, salt: &[u8; 16]) -> Result<Self>
pub fn derive(passphrase: &str, salt: &[u8; 16]) -> Result<Self>
Derive a 256-bit KEK from passphrase and salt via Argon2id +
HKDF-SHA256.
Sourcepub fn from_raw_key(raw: &[u8], salt: &[u8; 16]) -> Result<Self>
pub fn from_raw_key(raw: &[u8], salt: &[u8; 16]) -> Result<Self>
Derive a 256-bit KEK from a raw key (e.g. a key file’s contents) via HKDF-SHA256 only — no Argon2id. The raw key must be >= 32 bytes and already high-entropy (machine-generated). ~0.1ms vs ~50ms for the passphrase path.
Sourcepub fn derive_wal_key(&self) -> Zeroizing<[u8; 32]>
pub fn derive_wal_key(&self) -> Zeroizing<[u8; 32]>
Derive a WAL DEK from this KEK for frame-level AEAD.
Derive the shared (multi-table) WAL DEK — domain-separated from the per-table WAL so the two logs never share key+nonce space under the same KEK (review fix from P2 peer review).
Sourcepub fn derive_table_wal_key(&self, table_id: u64) -> Zeroizing<[u8; 32]>
pub fn derive_table_wal_key(&self, table_id: u64) -> Zeroizing<[u8; 32]>
Derive a per-table WAL DEK unique to table_id, so no two tables
share the same DEK even under the same KEK.
Sourcepub fn derive_cache_key(&self) -> Zeroizing<[u8; 32]>
pub fn derive_cache_key(&self) -> Zeroizing<[u8; 32]>
Derive a result-cache DEK from this KEK for cache file AEAD.
Sourcepub fn derive_idx_key(&self) -> Zeroizing<[u8; 32]>
pub fn derive_idx_key(&self) -> Zeroizing<[u8; 32]>
Derive the index-checkpoint DEK from this KEK (_idx/global.idx).
Sourcepub fn derive_run_mac_key(&self) -> Zeroizing<[u8; 32]>
pub fn derive_run_mac_key(&self) -> Zeroizing<[u8; 32]>
Derive the run-metadata MAC key from this KEK (see run_metadata_mac).
Sourcepub fn derive_meta_key(&self) -> Zeroizing<[u8; 32]>
pub fn derive_meta_key(&self) -> Zeroizing<[u8; 32]>
Derive the meta DEK used to encrypt + authenticate DB-wide metadata
(catalog, manifest checkpoints). Mirrors Self::derive_idx_key.
Sourcepub fn wrap_dek(&self, dek: &[u8; 32], wrap_nonce: &[u8; 12]) -> Result<Vec<u8>>
pub fn wrap_dek(&self, dek: &[u8; 32], wrap_nonce: &[u8; 12]) -> Result<Vec<u8>>
Wrap a 32-byte DEK with the KEK using AES-256-GCM. wrap_nonce must
be unique per use under this KEK (a run’s random nonce_prefix
satisfies this).
Sourcepub fn unwrap_dek(
&self,
wrapped: &[u8],
wrap_nonce: &[u8; 12],
) -> Result<Zeroizing<[u8; 32]>>
pub fn unwrap_dek( &self, wrapped: &[u8], wrap_nonce: &[u8; 12], ) -> Result<Zeroizing<[u8; 32]>>
Unwrap a DEK previously produced by Self::wrap_dek.
Source§impl Kek
impl Kek
Sourcepub fn derive_subkey(&self, info: &[u8]) -> Zeroizing<[u8; 32]>
pub fn derive_subkey(&self, info: &[u8]) -> Zeroizing<[u8; 32]>
Derive a 256-bit sub-key from this KEK via HKDF-Expand, domain-
separated by info. Used for per-column indexable-encryption keys:
deriving deterministically from the (stable) KEK makes a column’s
tokens identical across runs, so cross-run indexes (bitmap / range)
unify them.
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 UnsafeUnpin 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
Source§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>
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>
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