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

Padding in Authenticated Encryption Modes

Understand how modern AEAD modes like GCM eliminate padding oracle risks and when padding is still relevant.

Padding in Authenticated Encryption Modes

What you'll learn: How modern authenticated encryption modes handle padding and why some eliminate padding oracle risks entirely.

The Padding Problem Solved (Mostly)

Remember how CBC mode required padding, which led to padding oracle attacks? Modern Authenticated Encryption with Associated Data (AEAD) modes like GCM dramatically change this landscape.

GCM and CTR-based modes don't require padding at all. Why? Because they operate like stream ciphers—encrypting data bit-by-bit (or byte-by-byte) using a counter-generated keystream. If your plaintext is 37 bytes, GCM produces exactly 37 bytes of ciphertext. No padding needed, no padding oracle possible.

Think of it like shrink-wrap versus a shipping box: CBC mode is like a box that must be filled completely (requiring padding material), while GCM is like shrink-wrap that conforms exactly to your item's shape.

When Padding Still Matters

However, padding isn't completely extinct:

  1. CCM mode (Counter with CBC-MAC) uses CBC-MAC internally for authentication, which does require padding—but the authentication tag protects against tampering, preventing traditional padding oracle exploitation.

  2. Legacy systems still using CBC mode with HMAC for authentication must pad correctly, though the HMAC verification should happen before unpadding.

  3. Block-oriented modes like XTS for disk encryption still operate on fixed block boundaries, though disk sectors naturally align to block sizes.

The Security Advantage

AEAD modes provide integrity protection that detects any modification before decryption occurs. Even if padding exists internally, an attacker can't exploit padding errors because the authentication check fails first—the decryption never completes, and no oracle signal leaks.

Key Takeaway: Modern AEAD modes like GCM eliminate padding requirements entirely through stream-cipher-like operation, making padding oracle attacks obsolete; when padding exists in other modes like CCM, authentication protections prevent exploitation.