AES key schedule

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

Values of rci in hexadecimal
i 12345678910
rci 01020408102040801B36

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

AES key schedule for a 128-bit key.

Define:

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.