Pseudocode for Key Expansion () Algorithm

1

procedure Key Expansion (key)

2

i ← 0 3

3

while i ≤ Nk −1 do 4

4

w[i] ← key[4 ∗ i..4 ∗ i + 3]

5

i ← i + 1 6

6

end while

7

while i ≤ 4 ∗Nr + 3 do

8

tempw [i − 1]

9

if i mod Nk = 0 then

10

temp ← SubWord(RotWord(temp))♁Rcon[i/Nk]

11

else if Nk > 6 and i mod Nk = 4 then

12

temp ← SubWord(temp)

13

end if

14

w[i] ← w[i−Nk]♁temp

15

: i i + 1

16

end while

17

return w

18

end procedure