Key Expansion / Key Schedule
Each round use its own round key into the "Add Key" step that is derived from the original encryption key.
So, the Key Schedule will allow creating a different key for each encryption round, each of these sub-keys being 128 bits
To make the key expansion, the original key is divided into 32 bits blocks called words
The next words are calculated following these graph :



Algorithm steps
The following explanation will be based on AES-128. Some little ajustement ( such as the amount of generated words ) have to be done to make it applicable to the others key size.
As explained before, AES-128 need a total key lenght of 1408 bits ( ).
As each word has a size of 32 bits, ( )44 words are needed.
The first four words group
The first four words are provided by the original key.
W0 =
key[0:31]W1 =
key[32:63]W2 =
key[64:95]W3 =
key[96:127]
The others words groups
Let’s say that we have the four words of the round key for the i th round:
And we need to determine the words
Using the Figure 1, we can write :
The first word of each groups
is the beginning of the 4-word group and is obtained by using :
The g() function
The function consists of the following 3 steps :
Perform a one-byte left circular rotation on the argument 4-byte word.
Perform a byte substitution for each byte of the word using the same "S-box" in the SubBytes step of the encryption rounds
XOR the bytes obtained from the previous step with a round constant.
The round constant for the round is noted .
The only non-zero byte in the round constants, , obeys the following recursion:
The multiplication applied here is the same as in Mix Column operation when multiplying by 2.
Python implementation
Last updated