AES algorithm
• The Advanced Encryption Standard (AES) is a widely used symmetric encryption
algorithm. It works by taking a block of plaintext and converting it into ciphertext
using a secret key.
• AES works on blocks of 128 bits and supports key sizes of 128, 192, or 256 bits.
• The number of rounds depends on the key size: 10 rounds for 128-bit key
AES Encryption Steps
Step 1: Convert Plaintext into a 4x4 State Matrix
• The plaintext is divided into blocks of 16 bytes (128 bits).
• These bytes are arranged in a 4x4 matrix (State matrix).
Example
Plaintext: HelloAESWorld123 (16 characters)
This matrix is the State matrix.
Step 2: Key Expansion
• The original key (128-bit) is expanded into 11 round keys (one for each round,
including the initial round).
• A key schedule algorithm is used to generate these keys.
Key Schedule Steps:
1. Divide the original key into four 32-bit words.
2. Use the previous word to generate the next one using substitution and rotation.
3. Apply the round constant for security.
Step 3: Initial Round (AddRoundKey)
• The input data (plaintext) is XORed with the first round key.
Step 4: Main Rounds
Each round consists of 4 steps:
1. SubBytes (Byte Substitution)
• Each byte in the State matrix is replaced with another byte from the S-Box.
• The S-Box is a pre-defined lookup table.
2. ShiftRows (Row Shifting)
• The rows of the State matrix are shifted left by different amounts:
o Row 0: No shift.
o Row 1: Shift left by 1 byte.
o Row 2: Shift left by 2 bytes.
o Row 3: Shift left by 3 bytes.
3. MixColumns
• Each column in the State matrix is transformed using matrix multiplication.
4. AddRoundKey
• The State matrix is XORed with the next round key.
Step 5: Final Round (10th Round in AES-128)
The final round is similar to the previous rounds but without Mix Columns.
Final Round Steps:
1. SubBytes 2. ShiftRows 3. AddRoundKey
Now, the State matrix contains the final encrypted ciphertext.
AES Decryption Steps
Decryption follows the same steps in reverse using the same round keys.
Step 1: Convert Ciphertext into a 4x4 State Matrix
• Arrange the encrypted ciphertext into a 4x4 matrix.
Step 2: Initial Round(AddRoundKey)
• The ciphertext is XORed with the Round Key 10 that was generated during
encryption.
Step 3: Main Rounds : Each round consists of:
1. Inverse ShiftRows
• The rows are shifted right instead of left.
2. Inverse SubBytes
• Each byte is replaced using the Inverse S-Box.
3. Inverse MixColumns
• The columns are transformed back using the inverse matrix.
4. AddRoundKey
• XOR the State matrix with the round key.
Step 4: Final Round
The final round is the same as the main rounds but without Inverse MixColumns:
1. Inverse ShiftRows
2. Inverse SubBytes
3. AddRoundKey
After the final step, the decrypted data is obtained, which should match the original
plaintext.