Course contentsShow
← Security
Lesson 132 of 3,0523. Symmetric Cryptography Deep DiveFree lesson

IV Requirements for Different Modes

Learn the specific IV requirements for CBC, CTR, GCM, and other modes—when IVs must be unpredictable vs merely unique.

IV Requirements for Different Modes

What you'll learn: You'll discover that different cipher modes have very different rules about what makes an IV safe—and confusing them can break your encryption completely.


Why IV Requirements Vary

Just as nonces vs IVs have different definitions, cipher modes themselves impose different security requirements on their IVs. Some modes catastrophically fail if an IV is predictable, while others only require uniqueness. Using the wrong type of IV for a mode is like using the wrong key for a lock—it simply won't provide the security you expect.

Mode-by-Mode Requirements

CBC Mode: Unpredictable IVs Required

CBC needs cryptographically random, unpredictable IVs. If an attacker can predict your next IV, they can perform chosen-plaintext attacks to decrypt data. Think of CBC's IV like a poker hand—if opponents know your cards before you play them, the game is over.

CTR Mode: Unique IVs (Nonces) Required

CTR mode only requires IVs to be unique (never reused with the same key), but they don't need to be unpredictable. A simple counter works perfectly. Predictability isn't a problem here—only repetition is catastrophic, as it reuses the same keystream.

GCM Mode: Unique IVs, Catastrophic if Reused

GCM also needs unique IVs, and IV reuse is devastating—it breaks both confidentiality AND authentication. However, like CTR, predictability isn't the concern; uniqueness is everything.

CFB and OFB Modes: Similar to CBC

These modes generally need unpredictable IVs like CBC, though the exact security implications vary slightly by mode.

The Critical Distinction

  • Unpredictable = cryptographically random (use a secure random generator)
  • Unique = never repeated (a counter is fine)

Mixing these up means using a counter where randomness is required (vulnerable) or wasting entropy where a counter would suffice (inefficient but safe).

Key Takeaway: CBC requires unpredictable IVs; CTR and GCM only require unique ones. Know your mode's requirements—using the wrong IV type can completely compromise your encryption.