liveBook · Manning

Counter mode encryption

As explained in Real-World Cryptography

AES-CTR is a counter-mode construction that applies AES to successive counter values to generate a keystream or pseudorandom-looking output.

Counter mode turns AES into a stream-like encryption method. AES encrypts a unique nonce joined to a counter, producing a keystream that is XORed with plaintext. section 4.5.2

The construction works in a few practical steps:

  • Choose a nonce that does not repeat; it need not be unpredictable. section 4.5.2
  • Concatenate the nonce with a counter beginning at 1, then encrypt each block with AES. section 4.5.2
  • XOR the resulting keystream with plaintext; truncate excess keystream so padding is unnecessary. section 4.5.2
  • Never reuse a nonce: repeated keystreams let an observer XOR ciphertexts and recover the XOR of the plaintexts. section 4.5.2

A typical AES-CTR layout

AES-CTR uses a 96-bit nonce and a 32-bit counter inside each 16-byte AES block. The counter increments for each block and permits less than 69 GB with one nonce. section 4.5.2

How Real-World Cryptography covers it

How deep it goes
Explains nonce construction, counters, keystream XOR, truncation, capacity, and nonce-reuse failure without implementation detail.
Examples
Uses 96-bit nonces, 32-bit counters, 16-byte blocks, keystream truncation, and repeated-nonce ciphertext comparison.
What it assumes
Assumes familiarity with AES, plaintext, ciphertext, XOR, and block encryption while clarifying nonce and keystream roles.
What you can do after
Operate AES-CTR by generating nonce-counter keystream blocks, XORing them with plaintext, and avoiding nonce reuse.
How it connects
Connects AES-CTR with AES-GCM, GMAC, nonces, IVs, XOR, keystreams, and CBC mode.

Also explained in

Compare how 2 books explain counter mode encryption →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Real-World Cryptography. The section links point to the parts of the book it draws on.