liveBook · Manning

Cipher block chaining mode

As explained in Software Security for Developers

AES-CBC mode is a block-cipher operating mode that chains plaintext blocks through AES encryption using an initialization vector.

AES-CBC is a block-cipher mode that encrypts each plaintext block together with the previous ciphertext block. This chaining hides repeated patterns that would remain visible with ECB mode. CBC provides confidentiality only; it does not provide integrity or authenticity, so tampering can go undetected. section 5.2 section 5.2.1 section 5.7

Use CBC with these operational requirements:

  • Provide an AES secret key and a random 128-bit initialization vector (IV). section 5.2.1
  • Use a different IV for every encryption with the same key; the IV may be stored in cleartext beside the ciphertext. section 5.2.1
  • Do not select CBC merely because an application says AES-256; the operating mode determines important security properties. section 5.2
  • Prefer authenticated encryption such as AES-GCM when integrity and authenticity are required. section 5.7

Encrypting two files

If two files are encrypted with the same AES key, generate a fresh IV for each operation. CBC combines the IV with the first plaintext block, then feeds each ciphertext block into the next encryption step. A repeated plaintext can therefore produce different ciphertext when its IV changes. section 5.2.1

Figure 5.4 CBC takes the output of one block and feeds it into the next. The net result is that even if you encrypt the same data multiple times, the ciphertext looks random. An attacker can’t determine patterns in the underlying data by looking for patterns in the ciphertext.
figure

Trace how each ciphertext block feeds the next block and how chaining conceals repeated plaintext patterns. section 5.2.1

How Software Security for Developers covers it

How deep it goes
Details block chaining, key and IV requirements, cleartext IV storage, and the absence of integrity protection.
Examples
Uses repeated message sections, two files encrypted under one key, and an IV-ciphertext decryption layout.
What it assumes
Assumes only the distinction between AES keys, fixed-size blocks, and operating modes, while defining IVs and nonces.
What you can do after
Evaluate AES configurations, generate unique IVs, and recognize when authenticated encryption is required.
How it connects
Contrasts CBC with ECB and GCM and connects it to AES, initialization vectors, confidentiality, integrity, and authenticity.

Also explained in

Compare how 3 books explain cipher block chaining 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.