Block Cipher Modes of Operation
1. Why Modes? (beginner!)
Block ciphers eat FIXED blocks (DES 64-bit, AES 128-bit!). Modes = recipes to encrypt LONG messages: ECB (each block alone!), CBC (chain!), CFB/OFB (stream-ify!), CTR (counter!). NIST SP 800-38A standard!
2. Five Modes (exam table — memorize!)
ECB: C[i] = E(P[i]) — same P → same C (PENGUIN shows! NEVER for data!)
CBC: C[i] = E(P[i] XOR C[i-1]), C[0] uses IV (random! chaining hides patterns!)
CFB: shift register of ciphertext → E → XOR s bits (self-heals! segment stream!)
OFB: E applied to IV repeatedly → keystream XOR (no error spread!)
CTR: C[i] = P[i] XOR E(nonce + i) (parallel! random-access! best modern!)
| Mode | IV? | Parallel? | Error spread | Padding? |
|---|---|---|---|---|
| ECB | no | yes | 1 block | yes |
| CBC | random unpredictable! | decrypt only | 2 blocks | yes |
| CFB | random! | decrypt only | few segments | no (stream!) |
| OFB | unique nonce! | no | 1 bit | no |
| CTR | unique nonce! | YES both! | 1 bit | no |
3. ECB Penguin (exam picture!)
same plaintext blocks → same ciphertext (image outline visible!)
CBC/CTR → random-looking (patterns hidden!)
RULE: ECB only for single blocks/keys — NEVER for messages!
4. Traps (favourite exam traps!)
- CBC IV must be RANDOM + unpredictable (predictable → chosen-plaintext reveals first block!). OFB/CTR need UNIQUE nonce (reuse = two-time pad!).
- Bit-flip in CBC garbles 2 blocks; in CTR flips SAME bit (malleable — need MAC! none give integrity alone!).
- CTR encrypt-only (no decrypt function needed — AES bonus!). CFB/OFB use E for decrypt too!
5. Exam Points
- Five-mode table + ECB penguin — 7 marks, very frequent.
- IV rules + error spread — 5 marks, favourite traps.
- CTR best (parallel, nonce) — 3 marks, frequent viva.