liveBook · Manning

Electronic codebook mode

As explained in Software Security for Developers

Electronic Codebook mode, or ECB mode, is a block-cipher mode that encrypts each plaintext block independently with the same key.

Electronic Codebook (ECB) mode encrypts each plaintext block independently with the same secret key, then concatenates the ciphertext blocks. Because encryption is deterministic, repeated plaintext blocks produce repeated ciphertext blocks and reveal patterns. ECB is part of the AES standard but should never be used in applications. section 5.2

Repeated HTTP responses

If ECB encrypts HTTP responses, repeated blocks such as “HTTP/1.1 200 OK” produce identical ciphertext. An attacker can recognize and substitute that ciphertext pattern, changing the apparent response without cracking the key. section 5.2

Use these practical rules:

  • Never use ECB for application encryption. section 5.2
  • Prefer authenticated encryption such as AES-GCM, which provides confidentiality, integrity, and authenticity. section 5.7
Figure 5.3 ECB mode encrypts each input block independently using the secret key and concatenates the resulting ciphertext. ECB mode is simple but insecure; never use it.
figure

Visualizes independent block encryption, ciphertext concatenation, and the resulting security weakness. section 5.2

How Software Security for Developers covers it

How deep it goes
Defines independent block processing, demonstrates pattern leakage, and stops short of mathematical internals.
Examples
Uses repeated HTTP success-response blocks to demonstrate pattern recognition and ciphertext substitution.
What it assumes
Assumes basic awareness of AES and fixed-size blocks while defining modes of operation from their purpose.
What you can do after
Evaluate ciphertext for repeated-block leakage and choose authenticated encryption instead of ECB.
How it connects
Connects ECB with AES, block ciphers, ciphertext patterns, authenticated encryption, and GCM.

Also explained in

Compare how 3 books explain electronic codebook mode →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Security for Developers. The section links point to the parts of the book it draws on.