Step 1 of 5 · Reading · ~1 min
Read
Modes of Operation
Putting It All Together
You've built every piece of AES:
| Piece | What you wrote |
|---|---|
| State matrix | 16 bytes into the column-major 4x4, and back out |
| GF(2^8) math | xtime and the peasant multiply, reduced by 0x11B |
| SubBytes | the 256-entry S-box and its inverted permutation |
| ShiftRows | row r rotated left by r, and the right rotation that undoes it |
| MixColumns | the fixed matrix, and the {0e, 0b, 0d, 09} inverse |
| Key schedule | RotWord / SubWord / Rcon expanding 16 bytes into 11 round keys |
| Block cipher | the ten-round pipeline, and its inverse |
| ECB and CBC | independent blocks vs. chaining through the IV |
| CTR | the counter keystream, and why a repeated nonce is fatal |
| PKCS#7 | padding, strict unpadding, and the oracle a sloppy unpadder opens |
| GCM | GHASH, J0, and the tag that makes it AEAD |
Where AES is used:
- TLS (AES-GCM cipher suites)
- WPA2/WPA3 Wi-Fi (AES-CCMP)
- Linux dm-crypt / BitLocker / FileVault (disk encryption with XTS mode)
- iMessage, Signal, WhatsApp (AES-256-CBC for content)
- AWS KMS, Azure Key Vault (envelope encryption)
Hardware acceleration:
- AES-NI (Intel, since 2010): instructions like
aesenc,aesdec,aeskeygenassist. ~10x faster than software. - ARMv8 Cryptographic Extensions: same idea on ARM (Apple Silicon, modern Android).
Don't roll your own crypto in production. Use:
- libsodium (curated, simple API)
- BoringSSL / OpenSSL (battle-tested)
- WebCrypto / Node crypto (built-in)
- Rust:
ring,aes-gcmcrates - Java: javax.crypto
Your implementation here is for LEARNING. Production code must consider timing attacks, key handling, secure RNG for nonces, etc.
Up nextPKCS#7 Padding & Padding Oracle AttacksModes of Operation
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…