Use this when stream ciphers are used and keystream reuse must be avoided.
Stream Cipher
A stream cipher encrypts data by combining it with a keystream generated from a key and nonce, such as ChaCha20. Reusing a key and nonce pair breaks security completely.
1. Stream ciphers XOR plaintext with a keystream.
2. Keystream reuse is catastrophic.
3. Add authentication (AEAD).
4. RC4 is broken — disable.
5. ChaCha20 is the modern choice.
key + nonce → keystream ⊕ plaintext
Context & applicabilityCommon mistakes · platform/version boundaries
- Using stream ciphers without a MAC — bits can be flipped without detection.
- Generating nonces with a non-cryptographic random generator.
- Resetting counters after reboot and reusing nonces.
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 The nonce reuse problem Narrow the fault
A stream cipher XORs plaintext with a keystream. Reusing the same key and nonce gives the same keystream, so C1 ⊕ C2 = P1 ⊕ P2 and both plaintexts can often be recovered. This broke WEP and RC4 in various protocols. Use random 96-bit nonces only with low message counts, or counters, or XChaCha20 with 192-bit random nonces.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Stream ciphers XOR data with a keystream.
- Reusing a key and nonce pair breaks security completely.
- Combine with a MAC or use an AEAD construction.
- Keystream reuse checks — never reuse key+nonce
- Integrity added (Poly1305/HMAC) — authentication
- RC4 usage — must be none
ReferenceWhy it matters1 section · depth on demand
Key point
A stream cipher XORs data with a keystream. If the same key and nonce are used twice, XORing the two ciphertexts removes the keystream and reveals both plaintexts. Use AEAD constructions (ChaCha20-Poly1305) and unique nonces.
ReferenceImportant terms & boundaries2 sections · depth on demand
Examples
| Cipher | Status |
|---|---|
| ChaCha20 | Recommended (with Poly1305) |
| AES-CTR | Block cipher used as a stream cipher; needs a MAC |
| Salsa20 | Secure, predecessor of ChaCha20 |
| RC4 | Broken — banned in TLS (RFC 7465) |
In depth
A stream cipher generates a pseudorandom keystream from a key and nonce and combines it with the plaintext (XOR). It encrypts data of any length without padding and is efficient for streaming data.
| Cipher | Status |
|---|---|
| ChaCha20 | Modern, secure (with Poly1305 for integrity) |
| AES-CTR / AES-GCM | Block cipher used as a stream cipher |
| RC4 | Broken — removed from TLS and WPA |
The critical rule: never reuse a key/nonce pair. Reuse lets an attacker XOR two ciphertexts to cancel the keystream and recover plaintext — the flaw behind WEP's failure and some protocol vulnerabilities.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Symmetric Cryptography → Stream Cipher. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://csrc.nist.gov/pubs/fips/197/final · confidence 94%