liveBook · Manning

Block cipher

As explained in Software Security for Developers

A block cipher is an encryption algorithm that divides data into fixed-size blocks and transforms each block using a secret key.

A block cipher encrypts fixed-size chunks of data, transforming each block into ciphertext with a secret key. AES is a symmetric block cipher: the same key encrypts and decrypts, and each AES block is 128 bits (16 bytes). section 5.1

Longer messages must be divided into blocks, with padding added when the final block is short. A mode of operation specifies how the cipher handles data larger than one block. section 5.1 section 5.2

Treat the block cipher and its configuration as separate security decisions:

  • Avoid ECB mode: independently encrypted identical blocks produce identical ciphertext, exposing repeating plaintext patterns. section 5.2
  • Prefer authenticated encryption such as AES-GCM, which provides confidentiality, integrity, and authenticity together. section 5.7
  • Use a random, unique IV for every encryption with the same key; AES-GCM also produces an authentication tag that detects tampering. section 5.7

Why ECB leaks structure

If an HTTP response repeatedly begins with the same 16-byte block, ECB produces the same ciphertext block each time. An observer can recognize the pattern and potentially substitute ciphertext without recovering the key. section 5.2

Figure 5.2 AES is a block cipher because it requires its input to be a fixed size: 128 bits. AES is a symmetric cipher because the key used for encryption is the same one used for decryption.
figure

Use the diagram to distinguish AES’s fixed 128-bit block requirement from its symmetric use of one key for encryption and decryption. section 5.1

How Software Security for Developers covers it

How deep it goes
Explains block sizing, padding, modes, ECB leakage, IVs, and authenticated encryption, but stops short of mathematical internals.
Examples
Uses a 1,605-byte message and repeated HTTP response blocks to demonstrate padding, block processing, and ECB pattern leakage.
What you can do after
Configure AES-GCM with secure IVs and authentication tags, while rejecting ECB for practical encryption tasks.
How it connects
Connects AES with symmetric encryption, modes of operation, ECB, CBC, IVs, authenticated encryption, AEAD, and GCM.

Also explained in

Compare how 3 books explain block cipher →

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.