AES Cipher Algorithm Part 2
AES Cipher Algorithm Part 2
Origins
A replacement for DES was needed
Key size is too small in DES
Can use Triple-DES
But Triple-DES is slow and uses small plaintext block
US NIST issued call for ciphers in 1997 AES is the result of a three
year competition.
3
Multiple rounds
Rounds are (almost) identical
First and last round are a little different
Nr = Number of Rounds
4
High Level Description
• SubBytes
Final Round • ShiftRows MixColumns step is not
included in this round
• AddRoundKey
Overall Structure
128-bit values
Data block viewed as 4-by-4 table of bytes
Represented as 4 by 4 matrix of 8-bit bytes.
Key is expanded to array of 32 bits words
1 Byte
17
7
Details of Each Round
Each round is a repetition of functions that
perform a transformation over State array
Consists of 4 main functions: one permutation
and three substitutions
Substitute bytes, Shift rows, Mix columns, Add round key
Finite Field Arithmetic
Addition (XOR)
(x6 + x4 + x2 + x + 1) + (x7 + x + 1) = x7 + x6 + x4 + x2
{01010111} {10000011} = {11010100}
{57} {83} = {d4}
Multiplication is tricky
Finite Field Multiplication (•)
(x6 + x4 + x2 + x +1) (x7 + x +1) =
x13 + x11 + x9 + x8 + x7 + x7 + x5 + x3 + x2 + x + x6 + x4 + x2 + x +1
Irreducible Polynomial
SubBytes: Byte Substitution
Substitution Box
Multiplicative inverse of 3
3 In Binary = 0 0 0 0 0 0 1 1
= X1 1
= X + 1
X7 + X6 + X5 + X4 + X2 + X
X+1 X8 + X4 + X3 + X+1
X8 + X7
X7
X7 + X6
X6
X6 + X5
X5 + X4
X5 + X4
X3
X3 + X2
X2 + X
X2 + X
1
Substitution Box
Table of Multiplicative inverses
SubBytes and InvSubBytes
Modulo 2 arithmetic + = XOR
8 F
Output bits(what goes in the sbox) Input bits (the multiplicative inverse)
SubBytes and InvSubBytes
For 0
0 1 1
0 1 1
0 0 0
0 0
= 0
+ 0
= 0
0
= 63 in Hexa
0 1 1
0 1 1
0 0 0
0+0+0+0+0+0+0+0=0=0 MOD 2 = 0
0+0+0+0+0+0+0+0=0=0 MOD 2 = 0
0+0+0+0+0+0+0+0=0=0 MOD 2 = 0
0+0+0+0+0+0+0+0=0=0 MOD 2 = 0
0+0+0+0+0+0+0+0=0=0 MOD 2 = 0
0+0+0+0+0+0+0+0=0=0 MOD 2 = 0
0+0+0+0+0+0+0+0=0=0 MOD 2 = 0
0+0+0+0+0+0+0+0=0=0 MOD 2 = 0
SubBytes and InvSubBytes
For 1
1 1 0
1 1 0
1 0 1
= 1
1 + 0 = 1
1
= 7C
0
0 1 1
0 1 1
0 0 0
SubBytes and InvSubBytes
For 2
Inverse of 02 = 10001101 =
Written in reverse
0 1 1
1
0 0 1 1
1 1 0 1
0 + 0
1
0
= 1 0
= 0
1
= 77 in Hexa
0 0 1 1
0 0 1 1
1 0 0 0
1+0+0+0+0+0+0+1=2=2 MOD 2 = 0
1+0+0+0+0+0+0+1=2=2 MOD 2 = 0
1+0+1+0+0+0+0+1=3=3 MOD 2 = 1
1+0+1+1+0+0+0+1=4=4 MOD 2 = 0
1+0+1+1+0+0+0+0=3=3 MOD 2 = 1
0+0+1+1+0+0+0+0=2=2 MOD 2 = 0
0+0+1+1+0+0+0+0=2=2 MOD 2 = 0
0+0+0+1+0+0+0+1=2=2 MOD 2 = 0
SubBytes and InvSubBytes
For 3
Inverse of 03 = 11110110
0 1 1
0 1 1
0 0 0
1 + 0 1 = 7B in Hexa
= 1 0 = 1
0 1 1
0 1 1
0 0 0
0+0+0+0+1+1+1+1=4=4 MOD 2 = 0
0+1+0+0+0+1+1+1=4=4 MOD 2 = 0
0+1+1+0+0+0+1+1=4=4 MOD 2 = 0
0+1+1+0+0+0+0+1=3=3 MOD 2 = 1
0+1+1+0+1+0+0+0=3=3 MOD 2 = 1
0+1+1+0+1+1+0+0=4=4 MOD 2 = 0
0+0+1+0+1+1+1+0=4=4 MOD 2 = 0
0+0+0+0+1+1+1+1=4=4 MOD 2 = 0
SubBytes Operation
00 44 88 CC
11 55 99 DD
22 66 AA EE
33 77 BB FF
SubBytes Table
Implement by Table Lookup
Sample SubByte Transformation
Example :
MixClumns Scheme