pub struct RandomDecoy;Expand description
Decoy strategy that produces uniformly-random bytes from the OS CSPRNG.
Threat profile. RandomDecoy is the fastest of the three built-in
strategies and the easiest to reason about, but it is also the weakest:
the byte distribution it produces is uniformly random, which is
distinguishable from key material that has visible structure (DER
envelopes, ASCII-armored data, PEM markers, MAC-based keys with header
bytes, etc.). For maximum indistinguishability prefer
SelfReferenceDecoy.
Use RandomDecoy when:
- The keys you store are already uniformly random (256-bit symmetric keys from a CSPRNG, for example) — there is nothing to distinguish.
- You want the lowest decoy-generation cost on the hot path.
§Examples
use key_vault::decoy::{DecoyStrategy, RandomDecoy};
use key_vault::RawKey;
let key = RawKey::new(b"some key material".to_vec());
let decoy = RandomDecoy.generate(&key, 32).unwrap();
assert_eq!(decoy.len(), 32);Trait Implementations§
Source§impl Clone for RandomDecoy
impl Clone for RandomDecoy
Source§fn clone(&self) -> RandomDecoy
fn clone(&self) -> RandomDecoy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RandomDecoy
impl Debug for RandomDecoy
Source§impl DecoyStrategy for RandomDecoy
impl DecoyStrategy for RandomDecoy
Source§impl Default for RandomDecoy
impl Default for RandomDecoy
Source§fn default() -> RandomDecoy
fn default() -> RandomDecoy
Returns the “default value” for a type. Read more
impl Copy for RandomDecoy
Auto Trait Implementations§
impl Freeze for RandomDecoy
impl RefUnwindSafe for RandomDecoy
impl Send for RandomDecoy
impl Sync for RandomDecoy
impl Unpin for RandomDecoy
impl UnsafeUnpin for RandomDecoy
impl UnwindSafe for RandomDecoy
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