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

Mode Selection for Different Scenarios

Learn decision criteria for choosing encryption modes based on data type, threat model, and performance needs.

Mode Selection for Different Scenarios

What you'll learn: How to choose the right encryption mode based on your specific data type, threats, and performance requirements.

Now that you've learned about ECB, CBC, CTR, GCM, CCM, and XTS modes, the critical question becomes: which one should you actually use? The answer depends on three key decision criteria:

1. Data Type and Storage Pattern

Streaming data (network packets, video) benefits from CTR or GCM modes because they don't require the entire message upfront and can parallelize encryption.

Fixed-size records (database fields) work well with CBC or authenticated modes like GCM, though you must handle padding carefully.

Disk sectors demand XTS specifically—it's designed to encrypt storage blocks independently without expansion, critical for file systems.

2. Threat Model Requirements

If authentication is essential (most scenarios!), use authenticated encryption: GCM for high performance or CCM for constrained devices. They prevent tampering attacks that plague CBC and CTR alone.

For low-stakes environments where only confidentiality matters and performance is critical, plain CTR might suffice—but this is rare in practice.

Never use ECB mode in production—it reveals patterns in your data and is fundamentally broken for real-world use.

3. Performance Constraints

GCM offers hardware acceleration (AES-NI) and parallelization—ideal for servers and modern processors.

CCM uses less memory and simpler logic—better for embedded devices and IoT.

CBC requires sequential processing—slower but universally supported in legacy systems.

Decision Framework Analogy

Think of modes like transportation: XTS is a subway (fixed routes, disk sectors), GCM is a highway (fast, authenticated travel), CBC is a train (sequential stations), and ECB is walking backward blindfolded (don't do it).

Key Takeaway: Choose GCM for general-purpose authenticated encryption, XTS for disk encryption, and CCM for resource-constrained devices—always prefer authenticated modes unless you have a specific technical reason not to.