pub struct SelfReferenceDecoy;Expand description
Decoy strategy that draws bytes from the real key at random positions.
Threat profile. SelfReferenceDecoy is the strongest of the three
built-in strategies and the recommended default. The decoy bytes are
literally drawn from the key’s own byte distribution, so any statistical
analysis of memory regions (byte-value histogram, entropy estimate,
chi-squared distinguisher) will report identical profiles for real
fragments and decoy fragments. An attacker has no statistical signal to
separate them.
The only way for an attacker to recover the key, given this strategy, is to (a) obtain the position map (separately mlock’d) and (b) reverse the fragmentation. Statistical attacks alone do not work.
§Why not just shuffle key bytes?
Sampling with replacement (which is what we do) is important: shuffling would still preserve the multiset of key bytes, and a long contiguous match would reveal a chunk boundary. With independent sampling, the decoy bytes match the key’s byte distribution without containing any contiguous run of key bytes long enough to be confirmed.
§Examples
use key_vault::decoy::{DecoyStrategy, SelfReferenceDecoy};
use key_vault::RawKey;
let key = RawKey::new(vec![0xa1, 0xb2, 0xc3, 0xd4, 0xe5]);
let decoy = SelfReferenceDecoy.generate(&key, 32).unwrap();
assert_eq!(decoy.len(), 32);
// Every decoy byte is drawn from the key's byte set.
for b in &decoy {
assert!([0xa1, 0xb2, 0xc3, 0xd4, 0xe5].contains(b));
}Trait Implementations§
Source§impl Clone for SelfReferenceDecoy
impl Clone for SelfReferenceDecoy
Source§fn clone(&self) -> SelfReferenceDecoy
fn clone(&self) -> SelfReferenceDecoy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more