Comparing Authenticated Encryption Modes
What you'll learn: How GCM, CCM, EAX, and OCB differ in performance, security guarantees, and when to use each one.
Why Multiple Authenticated Encryption Modes?
You've learned about GCM and CCM individually, but which should you actually use? Each authenticated encryption mode evolved to solve different problems—balancing speed, security properties, and implementation constraints. Think of them like different car models: all get you from A to B safely, but some excel at highway speed while others shine in tight parking scenarios.
The Four Major Modes Compared
GCM (Galois/Counter Mode) is the performance champion. It parallelizes beautifully, making it ideal for high-speed network encryption (TLS, IPsec). However, it's unforgiving: nonce reuse is catastrophic, and implementation bugs have plagued software libraries. Best for: high-throughput applications with good random number generation.
CCM (Counter with CBC-MAC) trades speed for simplicity. It requires two passes over data (encrypt, then MAC), making it slower, but it's easier to implement correctly using only a block cipher. Commonly used in constrained environments like wireless protocols (802.11i, Bluetooth). Best for: embedded systems and hardware with limited resources.
EAX offers flexibility with slightly better security proofs than GCM. It handles arbitrary-length nonces gracefully and has cleaner security arguments, but it's slower than GCM and less widely adopted. Best for: applications prioritizing security margins over raw speed.
OCB (Offset Codebook) is the fastest of all—even faster than GCM—with single-pass efficiency. The catch? Patent restrictions limited adoption until recently. Best for: applications where maximum performance matters and licensing allows.
Choosing the Right Mode
For most modern applications, GCM is the default choice due to hardware acceleration (AES-NI) and widespread support. Use CCM in resource-constrained devices. Consider EAX when security proofs matter more than speed. OCB remains niche due to historical patent concerns.
Key Takeaway: GCM dominates for speed and hardware support, CCM suits constrained devices, EAX prioritizes clean security properties, and OCB offers theoretical performance advantages with licensing considerations.