Stream Ciphers
1. What Is a Stream Cipher? (beginner — bit-by-bit!)
Stream cipher = encrypts ONE bit/byte at a time with a pseudorandom keystream ( XOR !). Opposite of block ciphers (64-bit chunks!). Fast in hardware, no buffering — perfect for calls/video! Ideal = one-time pad (random key = message length!); real = short key stretched to long keystream!
2. Synchronous vs Self-Synchronizing (exam table!)
| Synchronous | Self-synchronizing | |
|---|---|---|
| Keystream from | key + state only (NOT data!) | key + past CIPHERTEXT! |
| Sync loss | fatal (must resync markers!) | auto-heals after digits! |
| Error spread | none (1 bad bit = 1 bad bit!) | bits garbled, then OK! |
| Example | RC4, ChaCha20, OFB mode! | CFB mode! |
3. LFSR Engine (exam hardware!)
Linear-Feedback Shift Register: bits shift right, new bit = XOR of taps!
4-bit example taps (3,0): 1000 → 0100 → 0010 → ... period up to 2⁴-1 = 15!
Pure LFSR = LINEAR (Berlekamp-Massey cracks from 2L bits!) → harden:
combine LFSRs (Geffe!), nonlinear filter, irregular clocking (A5/1!), or ditch LFSR (ChaCha ARX!)
4. Golden Rules (traps!)
- NEVER reuse key+nonce (two-time pad: XOR = XOR — reads both!).
- Stream = privacy ONLY (no integrity! flip bit → flips plaintext bit! add MAC!).
- Need sync markers/nonces per message!
5. Exam Points
- Stream vs block + sync table — 5-7 marks, very frequent.
- LFSR idea + why harden — 3-5 marks, frequent.
- Never-reuse rule — 2-3 marks, evergreen.