Cryptography Reference
In-Depth Information
( ( key_length / 4 ) + 6 ) * 4 iterations of the key schedule computation
described above — if the iteration number is an even multiple of the key
size, a rotation, substitution and XOR by the round constant of the previous
four-byte word is performed. In any case, the result is XORed with the value
of the previous key_length word.
The following code:
else if ( ( key_words > 6 ) && ( ( i % key_words ) == 4 ) )
{
sub_word( w[ i ] );
}
covers the exceptional case of a 256-bit key. Remember, for a 256-bit key, you
have to perform a substitution every four iterations.
AES Encryption
With the key schedule computation defi ned, you can look at the actual encryp-
tion process. AES operates on 16-byte blocks of input, regardless of key size; the
input is treated as a 4
4 two-dimensional array of bytes. The input is mapped
vertically into this array as shown in Figure 2-11.
0
1
2
3
4
5
6
7
8
9
A
B
C
DE
F
0
4
8
C
1
5
9
D
2
6
A
E
3
7
B
F
Figure 2-11: AES state mapping initialization
4 array of input is referred to as the state . It should come as no sur-
prise that the encryption process, then, consists of permuting, substituting, and
combining the keying material with this state to produce the output.
The fi rst thing to do is to XOR the state with the fi rst 16 bytes of keying mate-
rial, which comes directly from the key itself (see Figure 2-12). This is illustrated
in Listing 2-33.
This 4
Search WWH ::




Custom Search