AES ROUND (TRANSFORMATION) FUNCTIONS
Introduction
The Advanced Encryption Standard (AES) is a symmetric-key block cipher
standardized by the National Institute of Standards and Technology (NIST). It
encrypts a fixed block of 128 bits using cryptographic keys of 128, 192, or
256 bits. Depending on the key size, AES performs 10, 12, or 14 rounds of
encryption.
AES represents the plaintext as a 4 × 4 matrix of bytes, known as the State
Matrix. During each round, a sequence of transformation functions is applied
to the State matrix to convert the plaintext into ciphertext. These
transformations provide the essential cryptographic properties of confusion
and diffusion, making AES highly secure against cryptographic attacks.
The four transformation functions performed during each encryption round are:
1. SubBytes
2. ShiftRows
3. MixColumns
4. AddRoundKey
The initial round performs only the AddRoundKey transformation, while the
final round omits the MixColumns transformation.
SubBytes Transformation
Definition
The SubBytes transformation is a non-linear byte substitution operation in
which every byte of the State matrix is replaced with another byte using a
predefined lookup table called the Substitution Box (S-Box). This
transformation is performed independently on each byte and introduces non-
linearity into the encryption process.
Working Principle
The input data is arranged in a 4 × 4 State matrix. Each byte of the matrix is
substituted according to the AES S-Box.
The substitution process consists of the following steps:
The byte is represented in hexadecimal format.
The first hexadecimal digit identifies the row in the S-Box.
The second hexadecimal digit identifies the column.
The value stored at the corresponding row and column replaces the
original byte.
Construction of the S-Box
The AES S-Box is generated mathematically rather than randomly. It is
constructed in two stages:
1. Each byte is replaced by its multiplicative inverse in the finite field
GF(2⁸).
2. An Affine Transformation is applied to the resulting byte to obtain the
final substituted value.
This mathematical construction provides strong resistance against linear and
differential cryptanalysis.
Example
Consider the input byte
Input Byte = 53
Step 1: Split the hexadecimal byte into row and column.
Row = 5
Column = 3
Step 2: Locate Row 5 and Column 3 in the AES S-Box.
The value obtained is
ED
Therefore,
SubBytes (53) = ED
Thus, the byte 53 is replaced with ED in the State matrix.
Purpose
The SubBytes transformation is performed to:
Introduce non-linearity into AES.
Provide confusion in the encryption process.
Protect against linear and differential cryptanalysis.
Make the relationship between plaintext and ciphertext highly complex.
Inverse Transformation
During decryption, the Inverse SubBytes (InvSubBytes) transformation is
used. It employs the Inverse S-Box to replace every substituted byte with its
original value.
ShiftRows Transformation
Definition
The ShiftRows transformation is a transposition operation that cyclically shifts
the rows of the State matrix towards the left. Unlike SubBytes, this
transformation changes only the positions of the bytes and not their values.
Working Principle
The rows of the State matrix are shifted as follows:
Row Shift Operation
First Row No shift
Second Row Left shift by one byte
Third Row Left shift by two bytes
Fourth Row Left shift by three bytes
The shifting operation is circular, meaning that bytes shifted out from the left
side reappear at the right end of the same row.
Example
Before ShiftRows
63 09 CD BA
53 D0 70 CA
E0 E1 B7 D0
8C 04 51 E7
Apply the row shifts:
First row → No change
Second row → Shift left by one byte
Third row → Shift left by two bytes
Fourth row → Shift left by three bytes
After ShiftRows
63 09 CD BA
D0 70 CA 53
B7 D0 E0 E1
E7 8C 04 51
The values remain unchanged; only their positions are modified.
Purpose
The ShiftRows transformation:
Rearranges the positions of bytes.
Distributes data across different columns.
Improves diffusion.
Enhances the effectiveness of the MixColumns transformation.
Inverse Transformation
During decryption, InvShiftRows performs circular right shifts by the same
number of positions to restore the original arrangement of the State matrix.
MixColumns Transformation
Definition
The MixColumns transformation operates on each column of the State matrix
independently. Each column is transformed by multiplying it with a fixed matrix
over the finite field GF(2⁸). This operation changes the values of all bytes
within a column and provides strong diffusion.
Working Principle
Each column of the State matrix is considered as a four-byte vector and
multiplied by the following transformation matrix:
The multiplication and addition operations are performed using finite field
arithmetic.
As a result, every output byte depends on all four input bytes of the
corresponding column.
Example
Consider the following input column:
DB
13
53
45
After applying the MixColumns transformation, the output column becomes:
8E
4D
A1
BC
This transformation ensures that even a small change in one input byte
affects all four output bytes.
Purpose
The MixColumns transformation is used to:
Mix the bytes within each column.
Increase diffusion.
Strengthen the avalanche effect.
Improve resistance against statistical attacks.
Inverse Transformation
During decryption, the Inverse MixColumns (InvMixColumns)
transformation multiplies each column by the inverse transformation matrix
over GF(2⁸) to recover the original column values.
AddRoundKey Transformation
Definition
The AddRoundKey transformation combines the State matrix with the Round
Key generated during the key expansion process. It is the only AES
transformation that directly uses the secret encryption key.
Working Principle
Each byte of the State matrix is combined with the corresponding byte of the
Round Key using the Exclusive-OR (XOR) operation.
The operation is represented as:
State = State ⊕ Round Key
A different Round Key is used in every encryption round.
Example
Consider the following values:
State Byte = 47
Round Key Byte = AC
Step 1: Convert the values into binary.
47 = 01000111
AC = 10101100
Step 2: Perform the XOR operation.
01000111
10101100
----------
11101011
Step 3: Convert the binary result back into hexadecimal.
11101011 = EB
Therefore,
47 ⊕ AC = EB
Hence, the new State byte becomes EB.
Purpose
The AddRoundKey transformation:
Introduces the secret key into every encryption round.
Makes the ciphertext dependent on the encryption key.
Enhances the security of the encryption process.
Inverse Transformation
Since the XOR operation is its own inverse, the same AddRoundKey
transformation is performed during decryption to recover the original State
matrix.
AES Encryption Round Structure
The AES encryption process consists of three stages.
Initial Round
AddRoundKey
Intermediate Rounds
SubBytes
ShiftRows
MixColumns
AddRoundKey
Final Round
SubBytes
ShiftRows
AddRoundKey
The MixColumns transformation is omitted in the final round, enabling
efficient decryption while preserving the security of the AES algorithm.