49 votesby crypto.stackexchange.com/users/58written 2011-12-21last updated 2017-04-13
The actual encryption algorithm is almost the same between all variants of AES. They all take a 128-bit block and apply a sequence of identical "rounds", each of which consists of some linear and non-linear shuffling steps. Between the rounds, a round key is applied (by XOR), also before the first and after the last round.
The differences are:
The longer key sizes use more rounds: AES-128 uses 10 rounds, AES-192 uses 12 rounds and AES-256 uses 14 rounds.
The derivation of the round keys looks a bit different.
For AES-128, we need 11 round keys, each of which consisting of 128 bits, i.e. 4 32-bit columns. The original cipher key consists of 128 bits (i.e. 4 columns). Call these $k_0$, $k_1$, $k_2$ and $k_3$. The key expansion algorithm now expands these to $k_0$ to $k_{43}$ (so we get 44 columns in total).
The key expansion works in a way that $k_i$ only depends directly on $k_{i-1}$ and $k_{i -N_k}$ (where $N_k$ is the number of columns in the key, i.e. 4 for AES-128). In most cases it is a simple $\oplus$, but after each $N_k$ key columns, a non-linear function $f_i$ is applied.
âââââ
k_0 k_1 k_2 k_3 âââf_1âââ®
â â â â âââââ â
ââââââââââââââââââââââââââââââââââââ¯
â â â â â
â°âââ ââââ ââââ ââââ
â â â â â â â
â â â â â â â âââââ
k_4 â⯠k_5 â⯠k_6 â⯠k_7 âââf_2âââ®
â â â â âââââ â
ââââââââââââââââââââââââââââââââââââ¯
â â â â â
â°âââ ââââ ââââ ââââ
â â â â â â â
â â â â â â â âââââ
k_8 â⯠k_9 â⯠k_10 ⯠k_11 âââf_3âââ®
â â â â âââââ â
âââââââââââââââââââââââââââââââââââââ¯
â â â â â
.......................................
â â â â â
â°âââ ââââ ââââ ââââ
â â â â â â â
â â â â â â â
k_40 ⯠k_41 ⯠k_42 ⯠k_43
The functions $f_i$ are nonlinear functions build from the AES S-box (applied on each byte separately), a rotation by one byte, and an XOR with a round constant depending on $i$ (this is the element of $GF(2^8)$ corresponding to $x^{i-1}$, but there also is a table in the standard).
Then the key selection algorithm simply takes $k_0 \dots k_3$ as the first round key, $k_4\dots k_7$ as the second one, until $k_{40} \dots k_{43}$ as the last one.
AES-192 looks almost the same, but with six columns in parallel (A similar diagram you can see in my answer to a different question). As we need 13 round keys (=52 key columns), this will be done until $k_{51}$ (i.e. 8 full rows and four keys in the ninth row).
For AES-256 (and all variants of Rijndael with more than 192 bits of key), there is an additional non-linear transformation after the fourth column:
âââââ
k_0 k_1 k_2 k_3 k_4 k_5 k_6 k_7 ââââf_1âââ®
â â â â â â â â âââââ â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¯
â â â â â âââ â â â â
â°âââ ââââ ââââ ââââ âââgâââ ââââ ââââ ââââ
â â â â â â â â âââ â â â â â â â
â â â â â â â â â â â â â â â âââââ
k_8 â⯠k_9 â⯠k_10 ⯠k_11 ⯠k_12 ⯠k_13 ⯠k_14 ⯠k_15 âââf_2âââ®
â â â â â â â â âââââ â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¯
â â â â â âââ â â â â
â°âââ ââââ ââââ ââââ âââgâââ ââââ ââââ ââââ
â â â â â â â â âââ â â â â â â â
â â â â â â â â â â â â â â â âââââ
k_16 ⯠k_17 ⯠k_18 ⯠k_19 ⯠k_20 ⯠k_21 ⯠k_22 ⯠k_23 âââf_3âââ®
â â â â â â â â âââââ â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¯
â â â â â â â â â
....................................................................
â â â â â âââ â â â â
â°âââ ââââ ââââ ââââ âââgâââ ââââ ââââ ââââ
â â â â â â â â âââ â â â â â â â
â â â â â â â â â â â â â â â âââââ
k_48 ⯠k_49 ⯠k_50 ⯠k_51 ⯠k_52 ⯠k_53 ⯠k_54 ⯠k_55 âââf_7âââ®
â â â â âââââ â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¯
â â â â â
â°âââ ââââ ââââ ââââ
â â â â â â â
â â â â â â â
k_56 ⯠k_57 ⯠k_58 ⯠k_59
$g$ is a simpler variant of $f_i$: simply the application of the AES S-box on every byte of the column in parallel (without the rotation or the round constant, thus without an index).
Here we need 15 round keys, i.e. 60 columns, which means to do seven and a half round of key expansion.
(I now did read the word practical in the question, and my post doesn't really apply here ... but there seems to be no better question to post this as an answer, so I still post it here.)