K032 / Cipher modes and AEAD
ECB mode
ECB is the simplest block cipher mode and encrypts plaintext blocks independently.
CRYPTOGRAPHY LAB / K032
Cryptography Lab · ECB mode
Run real computations and inspect intermediate states step by step.
Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.
AES-ECB (raw, no padding)
See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.Output
Previous state
- Definition and overview
- ECB is the simplest block cipher mode and encrypts plaintext blocks independently. Source document ↗
- Classification and reversibility
- Reversible block cipher mode mapping plaintext blocks to ciphertext blocks. Source document ↗
- Key or secret requirements
- Requires a secret random symmetric key K shared by communicating parties. Source document ↗
- Operating principle and structure
- Split plaintext into fixed-size blocks, encrypt each independently with same key, no IV. Source document ↗
- Key size, block size and parameters
- AES-ECB uses 16-byte blocks and 128/192/256-bit keys. Source document ↗
- Security strength and recommendation
- Defined in SP 800-38A but generally not recommended due to inherent weakness, including NIST's 2023 announcement. Source document ↗
- Known attacks and vulnerabilities
- Pattern leakage makes it vulnerable to known- and chosen-plaintext attacks. Source document ↗
- Standards and certification
- NIST SP 800-38A defines five confidentiality modes including ECB. Source document ↗
- Typical uses
- Consider only for unupgradable legacy systems or when a standard requires ECB. Source document ↗
- Implementations, libraries and tools
- Crypto++ uses an ECB_Mode<AES> object with SetKey. Source document ↗
- Decryption or decoding
- Decrypt each ciphertext block independently with the same key. Source document ↗
- Advantages
- Simple and fast, particularly advantageous on multicore systems. Source document ↗
- Limitations and cautions
- Not semantically secure; exposes inter-block correlations and should be avoided. Source document ↗
- Distinguishing encryption, encoding and hashing
- ECB is an encryption mode using a block cipher, not encoding or hashing. Source document ↗
Practical examples
Example
Split plaintext into 16-byte AES blocks and encrypt independently; identical plaintext blocks yield identical ciphertext. Decrypt each block and remove padding.
Procedure
Pad plaintext to block multiple, split, encrypt independently with same key and concatenate. Decrypt by splitting ciphertext, independently decrypting and removing padding. Encoding/decoding is separate keyless format conversion.
Scenario
For legacy devices supporting only ECB, minimize data scope and add integrity protection. Replace with AES-GCM/AEAD in new designs; restrict ECB to mandated standards or interoperability tests.
Pitfalls and alternatives
ECB is deterministic, leaks patterns and provides no integrity authentication. Use an authenticated construction or AEAD such as GCM, not ECB except for legacy compatibility.
References
- Classic modes of operation for symmetric block ciphers - PyCryptodome ↗
- Electronic Code Book (ECB) | TechTarget ↗
- NIST SP 800-38A, Recommendation for Block Cipher Modes of Operation Methods and Techniques ↗
- AES - ECB | NoxTLS Documentation ↗
- AES (ECB) - @agntn/ciphers ↗
- MASTG-TEST-0232: Broken Symmetric Encryption Modes - OWASP Mobile Application Security ↗
- Report on the Block Cipher Modes of Operation in the NIST SP 800-38 Series ↗
- AESECB.h File Reference ↗
- ECB Mode - Crypto++ Wiki ↗
- Block cipher modes – Secgroup @ Ca' Foscari ↗