The Advanced Encryption Standard uses a key schedule to expand a short key into a number of separate round keys. The three AES variants have a different number of rounds. Each variant requires a separate 128-bit round key for each round plus one more. The key schedule produces the needed round keys from the initial key.
Round constants
The round constant rconi for round i of the key expansion is the 32-bit word:
rconi=[rci001600160016] where rci is an eight-bit value defined as :
rci={1if i=12⋅rci−1if i>1 and rci−1<8016(((2⋅rci−1)⊕11B16) mod 10016)if i>1 and rci−1≥8016 where ⊕ is the bitwise XOR operator and constants such as 0016 and 11B16 are given in hexadecimal. Equivalently:
rci=xi−1 where the bits of rci are treated as the coefficients of an element of the finite field GF(2)[x]/(x8+x4+x3+x+1), so that e.g. rc10=3616=001101102 represents the polynomial x5+x4+x2+x. AES uses up to rcon10 for AES-128 (as 11 round keys are needed), up to rcon8 for AES-192, and up to rcon7 for AES-256.
The key schedule
Define:
N as the length of the key in 32-bit words: 4 words for AES-128, 6 words for AES-192, and 8 words for AES-256 K0, K1, ... KN-1 as the 32-bit words of the original key R as the number of round keys needed: 11 round keys for AES-128, 13 keys for AES-192, and 15 keys for AES-256 W0, W1, ... W4R-1 as the 32-bit words of the expanded key Also define RotWord as a one-byte left circular shift:
RotWord([b0b1b2b3])=[b1b2b3b0] and SubWord as an application of the AES S-box to each of the four bytes of the word:
SubWord([b0b1b2b3])=[S(b0)S(b1)S(b2)S(b3)] Then for i=0…4R−1:
Wi={Kiif i<NWi−N⊕SubWord(RotWord(Wi−1))⊕rconi/Nif i≥N and i≡0(modN)Wi−N⊕SubWord(Wi−1)if i≥N, N>6, and i≡4(modN)Wi−N⊕Wi−1otherwise.
Notes
References FIPS PUB 197: the official AES standard (PDF file)
External links Description of Rijndael's key schedule schematic view of the key schedule for 128 and 256 bit keys for 160-bit keys on Cryptography Stack Exchange
