A topic in the Open Knowledge Graph — a free, open map of 15,495 topics and the order to learn them in.

Modes of Operation: CBC, CTR, and GCM

Graduate Depth 89 in the knowledge graph ☐ I know this ☆ Set as goal
1topic build on this
385prerequisites beneath it
See this on the map →
Symmetric Encryption and Block Ciphers→→Authenticated Encryption
cbc ctr gcm initialization-vector nonce chosen-plaintext-security

Core Idea

A block cipher encrypts one fixed-size block deterministically. Modes of operation extend it to arbitrary-length messages while achieving semantic security (identical plaintexts produce different ciphertexts). ECB fails this by encrypting blocks independently. CBC chains blocks via XOR with the previous ciphertext (requiring a random IV). CTR turns the block cipher into a stream cipher by encrypting sequential counter values. GCM combines CTR encryption with a polynomial MAC for authenticated encryption. Each mode has distinct properties regarding parallelism, error propagation, and the consequences of nonce/IV misuse.

How It's Best Learned

Draw block diagrams for ECB, CBC and CTR on one page, with arrows for every XOR and cipher call. Then use the diagrams to answer the same three questions for each mode: what one flipped ciphertext bit does on decryption, which steps can run in parallel, and what goes wrong when the IV or nonce repeats. Encrypting an image with a simple block pattern in ECB and then CBC makes the first lesson visible.

Common Misconceptions

Explainer

A block cipher like AES is a primitive — it securely encrypts exactly one 128-bit block. Real messages are longer than 128 bits, and encrypting each block independently (ECB mode) leaks catastrophic information: identical plaintext blocks produce identical ciphertext blocks, preserving patterns visible to any observer. Modes of operation solve this by introducing randomness or state that ensures identical plaintexts produce different ciphertexts, achieving semantic security (formally, IND-CPA: indistinguishability under chosen-plaintext attack).

CBC (Cipher Block Chaining) XORs each plaintext block with the previous ciphertext block before encryption: c_i = E_k(p_i XOR c_{i-1}), with c_0 being a random initialization vector (IV). This chaining means identical plaintext blocks in different positions (or under different IVs) produce different ciphertexts. CBC is sequential for encryption (each block depends on the previous ciphertext) but parallelizable for decryption. Its main vulnerability is sensitivity to IV handling — a predictable IV enables chosen-plaintext attacks (as exploited in the BEAST attack on TLS). CBC also provides no integrity protection: an attacker can flip specific bits in the decrypted plaintext by manipulating ciphertext blocks.

CTR (Counter) mode takes a different approach: it turns the block cipher into a stream cipher by encrypting a sequence of counter values (nonce || 0, nonce || 1, nonce || 2, ...) to produce a keystream, then XORs the keystream with the plaintext. Both encryption and decryption are fully parallelizable since each block's keystream segment is computed independently. Random access is possible — you can decrypt block i without processing blocks 0 through i-1. The critical requirement is nonce uniqueness: reusing a nonce with the same key generates the same keystream, reducing security to XOR of two plaintexts (identical to one-time pad reuse).

GCM (Galois/Counter Mode) combines CTR-mode encryption with a polynomial-based authentication tag computed over the ciphertext and any associated data (like packet headers that must be authenticated but not encrypted). GCM is an AEAD (Authenticated Encryption with Associated Data) scheme: it guarantees confidentiality, integrity, and authenticity in a single pass. The authentication uses multiplication in a Galois field (GF(2128)), which is fast in hardware. GCM is the dominant mode in modern protocols (TLS 1.3, IPsec) because it provides the complete security package — encryption plus tamper detection — without requiring users to correctly compose separate encryption and MAC primitives, a task that has historically produced vulnerabilities when done incorrectly.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Combining Small Groups Within 5 → Number Bonds Within 5 → Number Bonds to 10 → Tens and Ones Place Value → Reading and Writing Three-Digit Numbers → Comparing Three-Digit Numbers → Comparing and Ordering Three-Digit Quantities → Comparing and Ordering Whole Numbers → Comparing Numbers 1 to 20 → Ordering Numbers to 20 → Number Line 0 to 20 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Opposites and Additive Inverses → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Set Operations: Union, Intersection, and Complement → Proof by Cases → Proving by Cases and Exhaustion → Vacuous Truth and Trivial Cases → Proof by Cases (Proof by Exhaustion) → Mathematical Induction → Divisibility and Greatest Common Divisor → The Euclidean Algorithm → Modular Arithmetic and Congruences → Classical Ciphers and Cryptanalysis → Perfect Secrecy and the One-Time Pad → Symmetric Encryption and Block Ciphers → Modes of Operation: CBC, CTR, and GCM

Longest path: 90 steps · 385 total prerequisite topics

Prerequisites (1)

Leads To (1)