The Problem with Naive Modes
A mode of operation defines how a block cipher handles messages longer than one block. The simplest mode, called ECB, encrypts every block independently with the same key. This is dangerous because identical plaintext blocks produce identical ciphertext blocks, so structure and repeated patterns leak straight through the encryption.
The Initialization Vector
Better modes such as CBC and CTR use an initialization vector, or IV. The IV is a non secret starting value that is mixed into encryption so that the same plaintext encrypted twice yields different ciphertext.
Rules for an IV matter:
- The IV must be unpredictable or unique depending on the mode.
- The IV does not need to be secret, but it must never silently repeat with the same key.
- Store or transmit the IV alongside the ciphertext, since decryption needs it.
Reusing an IV with the same key undermines the whole point and can expose plaintext relationships.
Key idea
Never encrypt blocks independently with ECB, instead use a chaining mode with a fresh unique initialization vector so identical plaintext never produces identical ciphertext.