@@ -64,20 +64,30 @@ buffer. This reduces easy timing and retention pitfalls, but `base64-ng` does
6464not currently claim a formally verified cryptographic constant-time encode or
6565decode API.
6666
67+ If a deployment treats final success/failure timing or exact ciphertext length
68+ as sensitive, the caller must continue protocol processing in a fixed-shape
69+ way after decode failure, for example by substituting dummy output and running
70+ the same downstream validation or comparison steps. The ` ct ` module narrows
71+ the Base64 symbol-mapping timing target; it does not hide the public ` Result ` ,
72+ input length, padding length, or decoded length from the surrounding protocol.
73+
6774The clear-tail encode and decode APIs provide best-effort cleanup for
6875caller-owned buffers by writing zero bytes over unused tail bytes on success and
69- over the whole buffer on encode/decode error. Because the scalar crate forbids
70- unsafe code and has no runtime dependencies, this cleanup uses ordinary Rust
71- writes plus a compiler fence, not volatile writes or a formally verified
72- zeroization primitive. Treat these APIs as buffer-retention reduction, not as a
73- complete secret-erasure guarantee against compiler optimizations, core dumps,
74- swap, hardware observation, or other process memory disclosure bugs.
76+ over the whole buffer on encode/decode error. The cleanup primitive uses
77+ volatile byte writes plus a ` SeqCst ` compiler fence so cleanup writes are not
78+ optimized away. Treat these APIs as buffer-retention reduction, not as a
79+ complete secret-erasure guarantee against historical stack-frame copies,
80+ compiler spills, CPU registers, allocator behavior, core dumps, swap, hardware
81+ observation, or other process memory disclosure bugs. Callers that require a
82+ platform-specific formal zeroization policy should apply that policy to their
83+ own buffers in addition to using crate cleanup APIs.
7584
7685The ` SecretBuffer ` owned wrapper is available with the ` alloc ` feature for
7786sensitive encoded or decoded bytes that should not be accidentally logged. It
7887redacts ` Debug ` and ` Display ` , requires explicit reveal methods, and clears
79- initialized bytes on drop with the same best-effort cleanup helper. It cannot
80- clean historical copies outside the wrapper or allocator spare capacity.
88+ initialized bytes and vector spare capacity on drop with the same best-effort
89+ cleanup helper. It cannot clean historical copies outside the wrapper or make
90+ guarantees about allocator internals after ownership is exposed.
8191
8292Streaming wrappers apply best-effort cleanup to their small internal staging
8393buffers. Encoders clear pending plaintext bytes when those bytes are consumed
@@ -95,7 +105,9 @@ helpers before allocating or accepting framed payloads.
95105Runtime scalar APIs are expected to return ` Result ` or ` Option ` for malformed
96106input and size errors instead of unwinding. Compile-time array encoding is the
97107exception: it intentionally fails const evaluation when the caller supplies an
98- incorrect output array length.
108+ incorrect output array length. Do not use ` Engine::encode_array ` as a runtime
109+ API for untrusted size decisions; use ` checked_encoded_len ` , ` encoded_len ` , or
110+ caller-owned slice APIs instead.
99111` scripts/validate-panic-policy.sh ` release-gates new non-test panic-like sites
100112and requires reviewed exceptions to remain documented in ` docs/PANIC_POLICY.md ` .
101113
0 commit comments