← Back to section · Foundations of Cryptography

Modes of Operation Compared: The Lesson of ECB and the Division of Labor Among CBC, CTR, and GCM

A block cipher handles 128 bits at a time; how to encrypt long messages is the job of a mode of operation. ECB leaks patterns by encrypting blocks independently, CBC chains, CTR counts, and GCM adds authentication on top of the counter — pick the wrong mode and the strongest algorithm is wasted.

Published 22 November 2026 · 5 min read · PQ Frontier

Modes of Operation Compared: The Lesson of ECB and the Division of Labor Among CBC, CTR, and GCM
AI-generated site artwork
Video explainer · Symmetric encryption: blocks and modes

A block cipher does exactly one thing: turn 128 bits into another 128 bits. Real messages, however, come in every length — disks count in sectors, networks in packets. Extending a single-block transformation into an encryption scheme for arbitrary lengths is the job of a mode of operation. A mode is no accessory to the algorithm; it is half of the security story. Many headlines about “AES broken” turn out, on inspection, to be a mode misused or its parameters mismanaged. The four classic modes below, in historical order, show what each generation was patching.

ECB: handing over the pattern intact

Electronic Codebook mode (ECB) is the most straightforward approach: slice the plaintext into blocks and encrypt each independently under the same key. Its flaw is equally straightforward: a block cipher is a deterministic transformation, so identical plaintext blocks always produce identical ciphertext blocks. For text this leaks block-level repetition; for images the consequence is famous — the ECB penguin: a penguin picture encrypted under ECB keeps its contours and color regions clearly visible, because large areas of one color map to identical ciphertext blocks.

ECB’s lesson is the first in cryptographic engineering: the bar for encryption is not “a single block reveals nothing” but “the whole reveals no structure at all.” Today ECB is permitted only for encrypting single random blocks (such as key wrapping); no confidentiality requirement over multiple blocks should ever meet it.

CBC: the previous ciphertext as a mask

Cipher Block Chaining (CBC) XORs each plaintext block with the previous block’s ciphertext before encrypting it; the first block uses a random initialization vector (IV) instead. Identical plaintext blocks now encrypt differently because their predecessors differ, and the chain dissolves block-level structure. Decryption needs only each block and its predecessor, so it parallelizes; encryption, however, is strictly serial — the chain cannot be broken.

CBC’s security details live in its IV and its integrity — or lack thereof. The IV must be unpredictable: if an attacker can foresee the next IV and craft plaintext accordingly, confidentiality erodes step by step (the BEAST attack on TLS 1.0 exploited exactly predictable IVs). Worse, CBC provides no integrity protection at all: tampered ciphertext is accepted wholesale, and padding rules leak plaintext through error messages — padding oracle attacks felled a whole generation of protocol implementations after Vaudenay. The lesson: a mode that encrypts without authenticating must be paired with a message authentication code, verified before decryption.

CTR: turning a block cipher into a stream cipher

Counter mode (CTR) changes the approach: instead of encrypting the plaintext, it encrypts “nonce plus counter” block by block to generate a keystream, which is XORed with the plaintext. The block cipher is demoted to a high-quality keystream generator, and the counter counts as far as the plaintext runs.

CTR’s engineering properties are nearly all advantages: one operation for both directions, fully parallel, keystream precomputable, and random access to any ciphertext block — a favorite of disk encryption and streaming media. The cost is stream-cipher discipline: under one key, counter ranges must never overlap; nonce reuse is keystream reuse, and two plaintexts are exposed. CTR also carries no integrity and needs external authentication.

GCM: authentication on top of the counter

Galois/Counter Mode (GCM) is CTR’s direct descendant and the workhorse of contemporary protocols. It keeps CTR’s encryption skeleton and runs a finite-field-multiplication hash (GHASH) over the ciphertext and associated data to produce an authentication tag, merging “confidentiality” and “tamper resistance” into a single primitive — the flagship of the AEAD idea treated in the next article. GCM is parallelizable and hardware-friendly (especially fast with carry-less multiplication instructions) and is a standard TLS 1.3 suite.

But GCM’s discipline line is harder than CTR’s. If a nonce is ever reused under the same key, an attacker can not only XOR out plaintext relationships but also recover the GHASH authentication key, after which arbitrary forgeries pass — confidentiality and integrity collapse together. Large-scale measurements have indeed found batches of nonce-reusing GCM implementations on the Internet. The engineering countermeasure is to derive nonces deterministically (for example from record sequence numbers) rather than gambling on randomness.

Addendum: XTS for disk encryption, and the parametrics of modes

One scenario fits none of the four classic modes: disk sector encryption. Storage media demand ciphertext exactly as long as plaintext (nowhere to put expanded tags or randomness), random access by sector, and repeated rewriting of the same sector. The XTS mode, designed for this, gives each sector a “tweak” derived from its sector number, so identical plaintext written to different sectors — or rewritten to the same sector — meets a different input each time, approximating inter-block isolation without randomness. It provides no integrity: the disk-encryption threat model usually guards only against offline reading, a reminder that mode choices are inseparable from threat models and there is no context-free optimum.

In retrospect, the parametrics of modes run as deep as the algorithms: how long an IV must be, whether it must be random or merely unique, how counter space is partitioned, how far a tag may be truncated safely — every choice has its attack literature. The sound engineering practice is to adopt the combinations given by standards and mainstream libraries rather than assembling one’s own; the degrees of freedom in modes belong to standards authors, not application developers.

Common sense in choosing

Lined up together, the four generations trace a clear arc: first fix inter-block structure leakage (CBC/CTR), then parallelism and random access (CTR), finally fold authentication into the mode itself (GCM). New systems today generally start directly from authenticated-encryption modes, while legacy CBC and bare CTR deployments need their IV management and bolted-on authentication audited item by item. A mode is to a block cipher what a protocol is to an algorithm — the algorithm sets the ceiling; the mode decides where you actually stand.

Tags: Modes of OperationECBCBCCTRGCM