Each mode makes a different security promise — and breaks in a different way when misused.
ECB — Electronic Codebook (never use it for real data):
Encrypt each block independently. Identical plaintext blocks produce identical ciphertext blocks. The mode is not semantically secure: an attacker who can see which blocks are the same learns structure about the plaintext without breaking AES at all. The ECB penguin is the canonical demonstration. ECB is only appropriate for encrypting a single block.
CBC — Cipher Block Chaining (widely used, widely broken):
Each plaintext block is XORed with the previous ciphertext block before encryption. This erases the block-repetition problem, but introduces padding. Because block ciphers require fixed-size blocks, you must pad the last block. That padding, combined with decryption APIs that reveal whether padding is correct, enables the padding oracle attack: an attacker who can submit ciphertexts and observe whether decryption succeeds can decrypt any CBC ciphertext one byte at a time without knowing the key. POODLE (SSL 3.0, 2014) and BEAST (TLS 1.0, 2011) are real-world SSL/TLS exploits built on exactly this weakness.
CTR — Counter Mode (excellent when used correctly):
Encrypt a counter that increments with each block and XOR the result with the plaintext. No padding needed; the cipher is used only for encryption (not decryption); and blocks can be processed in parallel. The one critical requirement: never reuse a (key, nonce) pair. If two messages are encrypted with the same nonce, XORing the two ciphertexts cancels the keystream and reveals the XOR of the two plaintexts — which is usually enough to recover both. Project Nayuki and others have published practical attacks on nonce-reusing CTR. See also lattice-based cryptography for attacks on systems that share similar structural weaknesses.
GCM — Galois/Counter Mode (the current standard):
CTR encryption plus a polynomial authentication tag over the ciphertext. GCM is authenticated encryption with associated data (AEAD): it simultaneously guarantees confidentiality and that the ciphertext has not been tampered with. It is the mode mandated in TLS 1.3, SSH, and modern HTTPS. The weakness: if the nonce is ever reused, the authentication key is revealed and an attacker can forge arbitrary authenticated ciphertexts. Nonce misuse resistance is an active research area (e.g., AES-GCM-SIV). GCM's provable security rests on the hardness of the discrete logarithm problem over a binary field.
The progression ECB → CBC → CTR → GCM is also the history of cryptographers learning that confidentiality and integrity must be provided together. Encrypting without authenticating (CBC without a MAC) has been broken over and over.
Comments
Loading comments...