Pulsars
0 %
Log inSign up

Operating procedures

ECB mode and its flaw

AES encrypts 16-byte blocks. But your messages are rarely exactly 16 bytes long. How do you encrypt a 3 MB file? The answer lies in the encryption mode, and the choice of mode is just as important as the choice of algorithm.

The most straightforward mode

The ECB (Electronic Code Book) mode does the most obvious thing: it splits the data into blocks and then encrypts each block separately using the same key.

P1        P2        P3
 |         |         |
[E_K]     [E_K]     [E_K]
 |         |         |
C1        C2        C3

It’s simple, can be run in parallel… and seriously flawed.

The flaw

Two identical plaintext blocks produce two identical ciphertext blocks:

P: [AAAA] [BBBB] [AAAA]
             |
           (ECB)
             |
C: [7f3e] [a91c] [7f3e]      (identical blocks appear)

The ciphertext reveals the structure of the plaintext. This is exactly the same flaw found in classical ciphers, but at the block level.

The now-famous illustration: encrypt an image using ECB, and the outlines of the drawing remain perfectly visible in the result. The colours change, but the shape does not.

Why this really matters

This is not a theoretical flaw. With structured data — a form, a database where many records are similar — an attacker spots repetitions, guesses fields, and sometimes re-encodes blocks to alter the message without ever possessing the key.

The rule to remember: never use ECB. No exception is worth learning. The modes covered in the following lessons cost barely any more and do not have this flaw.