Symmetric Cryptography: Advanced Encryption Standard(AES)

Symmetric Cryptography: Advanced Encryption Standard(AES)

AES is a block cipher, which takes 128 bits message and encrypt the message into 128 bits ciphertext. The key of AES can be 128 bits(with 10 rounds of encryption), 192 bits(with 12 rounds of encryptio) or 256 bits(with 14 rounds of encryption). Here, we look at AES-128(the key size is 128 bits).

The encryption process is as follows:

aes_process

Let’s now look at the process in detail.

AES starts by arranging the 128 bits message in 4 × 4 matrix:

aes_matrix

Then we come to the key addition layer. We have a 128-bit key, and by key schedule we can obtain ten 128-bit round keys. Each round key can also be represented as 4 × 4 matrix. Therefore, in the key addition layer, we simply XOR the key matrix to the message matrix:

aes_key_addtion

After key additon, we step into round 1, which consists of four stages. The first stage is byte substitution. Each byte in the current 4 x 4 message matrix is used as an index to the S-box, obtaining a new byte for that position. For example, we have a 4 x 4 message matrix and the S-box:

aes_s_box

For the first btye 19(hex value), by looking up the table, we can substitute it with d4. And for the second btye 3d(hex value), we can substitute it with 27. We can keep looking up the table and substitute the whole matrix.

After the byte substitution, we come into the diffusion layer, which has two sub-layers. Firstly we shift the rows of the message matrix:

aes_shift_rows

Then we mix the columns, which is achieved by “matrix multiplication”:

aes_mix_columns

Note that the “matrix multiplication” is a special operation:

aes_mix_columns2

After the diffusion layer, we come to the key additon layer, which is same as the previous key addtion layer.