ECB (Electronic Codebook)
ECB mode encrypts each block independently, so identical plaintext blocks produce identical ciphertext blocks; it is insecure and suitable only for single-block or random data.
Purpose
It is the simplest block-cipher mode, requiring no IV, but it exposes plaintext patterns.
Mechanism
Encryption is C_i = E_K(P_i), each block on its own: no chaining, no IV. Identical plaintext blocks map to identical ciphertext blocks, leaking data patterns (the famous ECB penguin). It is safe only when the data is smaller than one block or random (e.g., wrapping an RSA key).
Use cases
- Encrypting a single key block (e.g., wrapping an RSA key)
- Teaching counterexample
- Legacy systems (should be migrated)
- Random-data encryption
Examples
- Input
P1 P1 P2OutputC1 C1 C2Identical plaintext → identical ciphertext
Common errors
- Encrypting structured or repetitive data with ECB
- Use GCM, or CBC with a random IV
Related terms
CBC (Cipher Block Chaining)
CBC mode XORs the previous ciphertext block with the current plaintext before encrypting, so identical plaintext blocks yield different ciphertexts; it requires a random IV but provides no integrity authentication. GLOSSARY
CTR (Counter Mode)
CTR mode turns a block cipher into a stream cipher: it encrypts an incrementing counter to generate a keystream that is XORed with the plaintext, supporting parallelism and random access, but provides no integrity. GLOSSARY
GCM (Galois/Counter Mode)
GCM is an AEAD mode that combines CTR encryption with GHASH authentication, providing confidentiality and integrity at once, and is the preferred mode of TLS 1.2/1.3. GLOSSARY
Mode of Operation
A mode of operation is a scheme that lets a block cipher handle arbitrary-length data, defining how multiple plaintext blocks are chained during encryption; common ones include ECB, CBC, CTR, and GCM. GLOSSARY