1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Layer 4 — Decoy bytes.
//!
//! Decoy strategies produce filler bytes that surround real key fragments in
//! storage. The goal is statistical indistinguishability: an attacker scraping
//! memory should not be able to tell which bytes are real and which are filler
//! without the position map.
//!
//! The strongest built-in strategy (`SelfReferenceDecoy`) lifts bytes from the
//! real key itself, so the filler is by definition drawn from the same
//! distribution as the secret. The weakest (`RandomDecoy`) uses raw CSPRNG
//! output, which is easy to compute but tends to stand out from key material
//! that has structure (DER-encoded RSA, ASCII-armored data, etc.).
//!
//! In this phase the trait surface is defined; implementations arrive in
//! Phase 0.4.
use Cow;
use Vec;
use crateResult;
use crateRawKey;
/// Strategy for producing decoy filler bytes.
///
/// # Implementor contract
///
/// - **Deterministic for a given seed but not for a given key.** Strategies
/// that derive filler from the key (`SelfReferenceDecoy`,
/// `KeyDerivedDecoy`) must use a per-vault random seed so that two vaults
/// holding the same key produce different decoy bytes.
/// - **No accidental key recovery.** A decoy strategy must never emit a
/// contiguous run of bytes that matches the real key — verify this in tests
/// for any implementation.
/// - **`Send + Sync`.** May be invoked from any thread.