AES Modes of Operation

How one 16-byte block cipher encrypts messages of any length: padding, ECB, CBC and CTR, what a flipped bit does in each, why a padding error is a signal, and why none of the modes detects a change. Real AES-128 through OpenSSL, with test keys.

Blocks and Chaining

Padding to whole blocks, ECB with its repeats, and CBC with its chain and its IV.

  1. One Block at a Time

    why a 20-byte message becomes 32 bytes

  2. ECB Shows the Pattern

    equal blocks in, equal blocks out

  3. CBC Chains the Blocks

    the chain from the IV through every block

  4. The IV Must Not Repeat

    what a repeated IV gives away

Streams and Failures

CTR as a keystream, what a flipped bit does, padding errors, and the lack of authentication.

  1. CTR Turns AES Into a Keystream

    counter blocks make a keystream, with no padding

  2. A CBC Bit Flip Garbles a Block

    one flipped bit changes two plaintext blocks in different ways

  3. Padding Errors Leak Information

    whether the padding is valid is itself information

  4. Modes Do Not Authenticate

    no mode notices a change; each spreads it differently