pub struct KeyMaterial { /* private fields */ }Expand description
Raw 32-byte SQLCipher key. Always wrapped in Zeroizing so the underlying
bytes are wiped when the value drops.
The struct is Clone (each clone produces its own zeroized buffer) but
deliberately does NOT impl Copy — that would defeat zeroization.
Implementations§
Source§impl KeyMaterial
impl KeyMaterial
Sourcepub fn derive(passphrase: &str, salt: &[u8; 16]) -> Result<Self>
pub fn derive(passphrase: &str, salt: &[u8; 16]) -> Result<Self>
Derive a 32-byte SQLCipher key from a UTF-8 passphrase + 16-byte salt.
Argon2id with the parameters specified in ADR-0003 §P8-F. Takes ~500 ms on a modern laptop — call this once at daemon startup, never per-write.
Sourcepub fn fresh_salt() -> Result<[u8; 16]>
pub fn fresh_salt() -> Result<[u8; 16]>
Generate a fresh cryptographically random 16-byte salt for first-run
setup. Persist in solo.config.toml alongside the database.
Sourcepub fn as_hex(&self) -> Zeroizing<String>
pub fn as_hex(&self) -> Zeroizing<String>
Raw 32-byte key as 64-character lowercase hex, wrapped in
Zeroizing so the underlying buffer is wiped on drop. Used to
build the PRAGMA key = "x'<hex>'" statement on every fresh
SQLCipher connection.
Callers should hold the returned value just long enough to build
the PRAGMA, then let it drop. The PRAGMA string itself isn’t
wrapped — once it’s been formatted into a static prefix +
dynamic hex + static suffix, the resulting String doesn’t
zeroize on its own. That’s a known v0.2 hardening item; for now
the smaller Zeroizing<String> from this method is the cleanest
boundary.
Trait Implementations§
Source§impl Clone for KeyMaterial
impl Clone for KeyMaterial
Auto Trait Implementations§
impl Freeze for KeyMaterial
impl RefUnwindSafe for KeyMaterial
impl Send for KeyMaterial
impl Sync for KeyMaterial
impl Unpin for KeyMaterial
impl UnsafeUnpin for KeyMaterial
impl UnwindSafe for KeyMaterial
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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