Advanced Encryption Standard (AES)
AES (Advanced Encryption Standard) is a symmetric encryption algorithm, meaning the same key is used for both encryption and decryption of data. It operates on fixed-size blocks of data, typically 128 bits (16 bytes), but supports key sizes of 128, 192, or 256 bits.
AES encryption involves a series of mathematical transformations on blocks of data. Here's a step-by-step breakdown of the AES process and the math behind each operation.
1. State Representation
AES operates on a 4x4 matrix of bytes (called the "state"). If the input data is 128 bits (16 bytes), it is split into 16-byte blocks that fit into this matrix.
Let’s represent the input block (plaintext) as a 4x4 matrix:
Where are the bytes from the plaintext.
2. Key Expansion
The 128-bit key is expanded into multiple round keys through a process called key schedule. Each round key is also a 4x4 matrix of bytes. The key schedule uses the original key and applies a series of transformations, including rotation, substitution using an S-box, and XORing with round constants.
The round key for each round is used in the AddRoundKey step.
3. AddRoundKey
In this step, each byte of the state matrix is XORed with the corresponding byte of the round key.
Let’s represent the round key as a 4x4 matrix:
The XOR operation is:
Where represents bitwise XOR.
4. SubBytes (Non-Linear Substitution)
Each byte in the state matrix is replaced by another byte using a substitution box (S-box). The S-box is a precomputed lookup table based on two mathematical operations:
- Multiplicative inverse over the finite field .
- An affine transformation in .
If a byte in the state is , its substitution is computed as:
- Find (the multiplicative inverse of in ).
- Apply an affine transformation:
Where is a fixed matrix and is a constant vector.
5. ShiftRows
In this step, the rows of the state matrix are cyclically shifted to the left by different offsets:
- Row 0 is not shifted.
- Row 1 is shifted 1 position to the left.
- Row 2 is shifted 2 positions to the left.
- Row 3 is shifted 3 positions to the left.
This step increases diffusion by rearranging the bytes.
6. MixColumns (Matrix Multiplication in )
In MixColumns, each column of the state matrix is multiplied by a fixed 4x4 matrix over the finite field . This operation ensures that each output byte is a function of all four input bytes in the column.
Let’s represent the state matrix column as a vector:
Each column is multiplied by the matrix:
The multiplication is done in , using polynomial arithmetic, which involves multiplying the bytes as polynomials modulo the irreducible polynomial .
The result is the new column:
7. Final Round
The final round is the same as the main rounds, except that it skips the MixColumns step. After completing all the rounds, the result is the ciphertext.
Summary of Mathematical Operations:
- Key Expansion: Involves byte-level operations like rotation, substitution (S-box), and XOR.
- AddRoundKey: Bitwise XOR of the state matrix with the round key.
- SubBytes: Non-linear byte substitution using an S-box based on the multiplicative inverse in .
- ShiftRows: Cyclic shifts of the rows in the state matrix.
- MixColumns: Linear transformation using matrix multiplication in .
These operations together provide strong diffusion and confusion, making AES resistant to most forms of cryptographic attacks.
Comments
Post a Comment