@@ -50,6 +50,7 @@ Implemented now:
5050- optional ` alloc ` support with ` SecretVec ` and ` SecretString ` .
5151- optional Linux memory locking with ` LockedSecretBytes<N> ` .
5252- optional x86_64 assembly-backed equal-length comparison.
53+ - optional x86_64 volatile-clear plus cache-line eviction helpers.
5354- explicit volatile helper APIs for existing ordinary buffers.
5455- redacted ` Debug ` for secret-owning wrapper types.
5556- clear-on-drop behavior for crate-owned secret containers.
@@ -69,7 +70,7 @@ Implemented now:
6970| Heap support | ` alloc ` feature |
7071| Proc macros | none |
7172| Main guarantee | narrow ownership, redaction, and clear-on-drop hygiene |
72- | Out of scope | stack-history wiping, cache flushing , crash dumps, privileged reads |
73+ | Out of scope | stack-history wiping, global cache secrecy , crash dumps, privileged reads |
7374
7475Read [ THREAT_MODEL.md] ( THREAT_MODEL.md ) and [ SAFETY.md] ( SAFETY.md ) before
7576using this crate for high-assurance secret handling.
@@ -126,6 +127,7 @@ sanitization = { version = "1.0.0-rc.5", features = ["memory-lock"] }
126127| ` std ` | no | Currently aliases ` alloc ` for downstream convenience. |
127128| ` memory-lock ` | no | Enables Linux ` LockedSecretBytes<N> ` on ` x86_64 ` and ` aarch64 ` . |
128129| ` asm-compare ` | no | Uses an x86_64 inline-assembly loop for equal-length byte comparison. |
130+ | ` cache-flush ` | no | Enables explicit x86_64 clear-and-cache-line-evict helpers. |
129131| ` unsafe-wipe ` | no | Compatibility no-op; volatile wiping is default. |
130132
131133Default builds are dependency-free and ` no_std ` .
@@ -370,6 +372,33 @@ let secret = VolatileOnDrop::new([1_u8, 2, 3, 4]);
370372assert_eq! (secret . with_secret (| bytes | bytes . len ()), 4 );
371373```
372374
375+ ## Cache Flush Sanitization
376+
377+ Enable ` cache-flush ` on x86_64 when a call site explicitly needs volatile
378+ clearing followed by ` clflush ` /` mfence ` over the affected cache lines:
379+
380+ ``` toml
381+ [dependencies ]
382+ sanitization = { version = " 1.0.0-rc.5" , features = [" cache-flush" ] }
383+ ```
384+
385+ ``` rust
386+ use sanitization :: {cache_flush :: cache_flush_sanitize_bytes, SecretBytes };
387+
388+ let mut scratch = [0xA5 ; 32 ];
389+ cache_flush_sanitize_bytes (& mut scratch );
390+ assert_eq! (scratch , [0 ; 32 ]);
391+
392+ let mut key = SecretBytes :: <32 >:: from_array ([7 ; 32 ]);
393+ key . secure_clear_and_flush ();
394+ assert! (key . constant_time_eq (& [0 ; 32 ]));
395+ ```
396+
397+ With ` alloc ` , ` cache_flush_sanitize_vec ` and ` cache_flush_sanitize_string `
398+ clear the full allocation capacity before flushing the allocation's cache
399+ lines. Unsupported targets, Miri, and builds without ` cache-flush ` do not expose
400+ the ` cache_flush ` module.
401+
373402## Assembly Comparison
374403
375404Enable ` asm-compare ` on x86_64 when you want equal-length secret comparisons to
@@ -398,6 +427,7 @@ targets, Miri, and builds without `asm-compare` use the portable Rust fallback.
398427| Existing ordinary buffer | ` unsafe_wipe::volatile_sanitize_* ` |
399428| Generic clear-on-drop wrapper | ` Secret<T> ` |
400429| Explicit x86_64 comparison compiler boundary | ` asm-compare ` feature |
430+ | Explicit x86_64 cache-line eviction after clearing | ` cache-flush ` feature |
401431
402432## Relationship to ` zeroize `
403433
0 commit comments