cipher.ink Write a message

Ciphers · Modern symmetric ciphers

AES, the Advanced Encryption Standard

The reference card for AES: key sizes, rounds, standards, attacks, hardware speed, and how it compares with its rivals.

AES (the Advanced Encryption Standard, a variant of the Rijndael cipher) is a block cipher with a 128-bit block and a key of 128, 192 or 256 bits. It's the world's default symmetric cipher. NIST standardized it in 2001, the US government approved it for protecting secrets, nearly every processor has it built in, and it's the cipher behind every message sealed on cipher.ink. This page is the reference card. For how the rounds work, with a worked example, read AES explained.

Try it

Three tools use AES, each from a different angle.

Specifications

Round 1 of the FIPS 197 example: shaded bytes changed in that step19a09ae93df4c6f8e3e28d48be2b2a08startSubBytesd4e0b81e27bfb44111985d52aef1e530ShiftRowsd4e0b81ebfb441275d52119830aef1e5MixColumns04e0482866cbf8068119d326e59a7a4cAddRoundKeya4686b029c9f5b6a7f35ea50f22b4349XOR round key
One AES round with the real values from the standard's worked example.
AES-128AES-192AES-256
Block size128 bits128 bits128 bits
Key size128 bits192 bits256 bits
Rounds101214
Round keys11 × 128 bits13 × 128 bits15 × 128 bits
Best published attack on the full cipher2126.2 (biclique, 2011)2190.22254.6
Against Grover's quantum searchabout 264about 296about 2128

Rijndael, the original design by Joan Daemen and Vincent Rijmen, allowed block sizes of 128, 192 and 256 bits. AES is the subset with a fixed 128-bit block. Each round applies SubBytes (an S-box on every byte), ShiftRows, MixColumns and AddRoundKey, and the last round skips MixColumns. The explainer takes each in turn.

Where AES is standardized and used

  • FIPS 197, published by NIST on 26 November 2001 and in force from 26 May 2002.
  • US classified information. In June 2003 the US government said AES with any of the three key lengths could protect information up to SECRET, and that TOP SECRET needed 192 or 256-bit keys. Later NSA guidance allows classified information only with 256-bit keys.
  • Everyday protocols. TLS 1.3 requires every implementation to support an AES-GCM cipher suite (TLS_AES_128_GCM_SHA256). SSH, IPsec and Wi-Fi's WPA2 (as AES-CCMP) use it, and disk encryption such as BitLocker and FileVault uses AES in XTS mode.
  • Hardware. Intel, AMD and ARM processors have AES instructions (AES-NI on x86). With them AES-128 runs at about 1.3 cycles per byte and AES-256 at about 1.8, many times faster than software and in constant time.

What it has going for it

  • No practical attack. The best published attack on the full cipher (biclique, Bogdanov, Khovratovich and Rechberger, 2011) is only 2 to 4 times faster than brute force, which makes no difference to anyone. Attacks on reduced-round versions exist, with a wide margin left.
  • Brute force is out of reach. 2128 keys, searched at 1018 a second, take about 1013 years, some 780 times the age of the universe.
  • Quantum computers matter little. Grover's algorithm halves the key length in bits, so AES-256 still has an effective 128 bits. That's why the cipher.ink key is 256 bits.

Where it's weaker

  • Related-key attacks. In 2009 researchers found attacks on AES-192 and AES-256 costing about 299.5 (192) and 2176 (256) work when the attacker can get ciphertexts under keys related in a chosen way. A well-designed protocol never lets an attacker choose related keys, but the results suggest AES-256's key schedule is no better than AES-128's.
  • Side channels. Software that looks values up in tables takes slightly different times depending on the key, and the processor's cache shows it. Bernstein (2005) and Osvik, Shamir and Tromer (2005) demonstrated attacks, the second recovering a key after 800 encryptions. Hardware AES instructions and bitsliced software avoid the problem.
  • The mode is up to you. AES alone encrypts one 16-byte block. Use it with an authenticated mode, as in AES-GCM. ECB mode, which encrypts each block separately, leaks patterns, as the picture demo shows.
  • Nonce reuse. In GCM and CTR modes, one repeated nonce under the same key is a disaster.

How it compares

CipherBlockKeyRoundsStatus
AES128128, 192, 25610, 12, 14The standard; no practical attack
DES645616Broken by brute force since 1998
Triple DES64112 or 168 (strength about 112)48Deprecated by NIST; disallowed after 2023
Blowfish6432–44816Old; 64-bit block limits it
Twofish128128, 192, 25616An AES finalist; no practical attack
Serpent128128, 192, 25632An AES finalist with a large margin
ChaCha20stream (64-byte blocks)25620The common alternative where there is no AES hardware

The code

AES-GCM through Web Crypto: what cipher.ink does. The round-by-round version in the explorer is a separate, readable implementation.

// AES-GCM with the browser's Web Crypto: the same calls cipher.ink makes. `key` is 16, 24 or 32 bytes, `nonce` 12 bytes that are never reused with this key.
async function seal(key, nonce, plaintext) {
  var k = await crypto.subtle.importKey('raw', key, 'AES-GCM', false, ['encrypt', 'decrypt']);
  var ct = await crypto.subtle.encrypt({ name: 'AES-GCM', iv: nonce, tagLength: 128 }, k, plaintext);   // ciphertext with the 16-byte tag at the end
  return new Uint8Array(ct);
}

// Decryption refuses (rejects) if a single bit of the ciphertext, tag or nonce is wrong.
async function open(key, nonce, sealed) {
  var k = await crypto.subtle.importKey('raw', key, 'AES-GCM', false, ['decrypt']);
  return new Uint8Array(await crypto.subtle.decrypt({ name: 'AES-GCM', iv: nonce, tagLength: 128 }, k, sealed));
}

Common questions

Is AES-256 stronger than AES-128?

It has a larger key space, which matters against quantum search and over the very long term, but both are far beyond any attack. The 128-bit version is perfectly adequate for most uses, and cipher.ink uses 256 bits because the cost is negligible.

Is AES the same as Rijndael?

Nearly. AES is the version of Rijndael with a fixed 128-bit block, while Rijndael itself also had 192- and 256-bit blocks.

Has AES been broken?

No. Attacks exist on reduced-round versions and in special settings (related keys, side channels), but nothing practical against correctly used full AES.

Do I need AES hardware to use it?

No. It runs fine in software, though hardware instructions make it faster and safer against timing attacks. Where there's no hardware, ChaCha20 is often preferred.

On the timeline

Further reading

  1. FIPS 197: Advanced Encryption Standard (2001)
  2. Daemen and Rijmen: The Design of Rijndael (2002)
  3. Bogdanov, Khovratovich, Rechberger: Biclique Cryptanalysis of the Full AES (2011)
  4. Wikipedia: Advanced Encryption Standard
  5. CNSS Policy 15 fact sheet on AES (2003)