Skip to content

Step 1 of 5 · Reading · ~1 min

Read

Modes of Operation

Putting It All Together

You've built every piece of AES:

PieceWhat you wrote
State matrix16 bytes into the column-major 4x4, and back out
GF(2^8) mathxtime and the peasant multiply, reduced by 0x11B
SubBytesthe 256-entry S-box and its inverted permutation
ShiftRowsrow r rotated left by r, and the right rotation that undoes it
MixColumnsthe fixed matrix, and the {0e, 0b, 0d, 09} inverse
Key scheduleRotWord / SubWord / Rcon expanding 16 bytes into 11 round keys
Block cipherthe ten-round pipeline, and its inverse
ECB and CBCindependent blocks vs. chaining through the IV
CTRthe counter keystream, and why a repeated nonce is fatal
PKCS#7padding, strict unpadding, and the oracle a sloppy unpadder opens
GCMGHASH, 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-gcm crates
  • 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…