Security context

What an agent needs to avoid regressing past fixes and find the next vuln in this repo.

rustcrypto/stream-ciphers
master @ 5f3430b
4
Fixes
0
CVEs
CRITICAL
Peak severity
Highlights
Cryptographic Issues: 3 prior fixes. Scrutinize any change in this area.
chacha20/src/chacha.rs: most-fixed (1 issue). Treat as high-risk during review.
2 high-severity fixes in this history; regressions here are high-impact.
Recurring patterns

The bug types that recur here, drawn from past fixes, not open vulnerabilities.

Cryptographic Issues: An incorrect cast dereference acted as a copy rather than a mutable reference borrow, leading to predictable output from the ChaCha20 random number generator. Developers must ensure that unsafe pointer casts and buffer conversions preserve mutable reference semantics.
Cryptographic Issues: Failure to panic or return an error when the internal block counter exceeded MAX_BLOCKS resulted in a 32-bit counter overflow, leading to keystream reuse. Secure boundaries must be enforced on block counts.
Cryptographic Issues: Allowing seeks or encryption beyond the 256 GB stream limit led to counter wraps. Seeking and block offsets must be explicitly validated against the absolute stream limit.