AES key schedule

From testwiki
Jump to navigation Jump to search

Template:Short description 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.[note 1] The key schedule produces the needed round keys from the initial key.

Round constants

Values of Template:Mvar in hexadecimal
Template:Mvar 12345678910
Template:Mvar 01020408102040801B36

The round constant Template:Mvar for round Template:Mvar of the key expansion is the 32-bit word:Template:Refn

rconi=[rci001600160016]

where Template:Mvar 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 Template:Math and Template:Math are given in hexadecimal. Equivalently:

rci=xi−1

where the bits of Template:Mvar 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 Template:Math for AES-128 (as 11 round keys are needed), up to Template:Math for AES-192, and up to Template:Math for AES-256.[note 2]

The key schedule

AES key schedule for a 128-bit key.

Define:

Also define Template:Math as a one-byte left circular shift:Template:Refn

RotWord⁡([b0b1b2b3])=[b1b2b3b0]

and Template:Math 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

Template:Reflist

References

Template:Reflist

  1. ↑ Non-AES Rijndael variants require up to 256 bits of expanded key per round
  2. ↑ The Rijndael variants with larger block sizes use more of these constants, up to Template:Math for Rijndael with 128-bit keys and 256 bit blocks (needs 15 round keys of each 256 bit, which means 30 full rounds of key expansion, which means 29 calls to the key schedule core using the round constants). The remaining constants for Template:Math are: 6C, D8, AB, 4D, 9A, 2F, 5E, BC, 63, C6, 97, 35, 6A, D4, B3, 7D, FA, EF and C5
  3. ↑ Other Rijndael variants require Template:Math round keys, where Template:Mvar is the block size in words
  4. ↑ Other Rijndael variants require Template:Math words of expanded key, where Template:Mvar is the block size in words
Cite error: <ref> tags exist for a group named "note", but no corresponding <references group="note"/> tag was found.