pub struct GuardedKey { /* private fields */ }Expand description
Memory-hardened key vault backed by 128 indistinguishable static arrays.
Implementations§
Source§impl GuardedKey
impl GuardedKey
pub const fn empty() -> Self
Sourcepub fn store_from_keys(&self, keys: &Keys, others: &[&GuardedKey])
pub fn store_from_keys(&self, keys: &Keys, others: &[&GuardedKey])
Extract the secret key from a Keys struct, store it in the vault,
and zeroize the intermediate bytes. One-liner replacement for the
repeated extract -> set -> zeroize pattern across login paths.
others is a slice of references to other active GuardedKey instances
for cross-key protection during decoy writes.
Sourcepub fn set(&self, key: [u8; 32], others: &[&GuardedKey])
pub fn set(&self, key: [u8; 32], others: &[&GuardedKey])
Store a key. XOR-split into 4 shares scattered across the 128 arrays, with decoy writes to ALL arrays so real writes are indistinguishable.
others is a slice of references to other active GuardedKey instances
for cross-key protection during decoy writes.
INVARIANT: pass EVERY other live key. A key’s lane is chosen by excluding only others’
lanes, so an omitted live key can collide and clobber it.
Sourcepub fn get(&self) -> Option<[u8; 32]>
pub fn get(&self) -> Option<[u8; 32]>
Recover the key. Zero writes — invisible to snapshot diffing.
Sourcepub fn clear(&self, others: &[&GuardedKey])
pub fn clear(&self, others: &[&GuardedKey])
Clear the key. Overwrites shares with random values, writes decoys to all arrays.
others is a slice of references to other active GuardedKey instances
for cross-key protection during decoy writes.
pub fn has_key(&self) -> bool
pub fn to_keys(&self) -> Option<Keys>
Auto Trait Implementations§
impl !Freeze for GuardedKey
impl RefUnwindSafe for GuardedKey
impl Send for GuardedKey
impl Sync for GuardedKey
impl Unpin for GuardedKey
impl UnsafeUnpin for GuardedKey
impl UnwindSafe for GuardedKey
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> 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