Rijndael AES mathematical demonstration

Rijndael AES – An Example (mathematical demonstration)

The initial stage

 

Plain text:       LONDONMETROPOLIT

Password:       PASSWORDPASSWORD

STATE   KEY
L O T O P W P W
O N R L A O A O
N M O I S R S R
D E P T S D S D

       Converting above tables into Hexadecimal:

STATE   KEY
4C 4F 54 4F 50 57 50 57
4F 4E 52 4C 41 4F 41 4F
4E 4D 4F 49 53 52 53 52
44 45 50 54 53 44 53 44

 

Add Round Key:

Add key to the state values:

  • 4C + 50 => 01001100 + 01010000 = IC
  • 4F + 41 => 01001111 + 01000001 = 0E
  • 4E + 53 => 01001110 + 01010011 = 1D
  • 44 + 53 => 01000100 + 01010011 = 17
  • 4F + 57 => 01001111 + 01010111 = 18
  • 4E + 4F => 01001110 + 01001111 = 01
  • 4D + 52 => 01001101 + 01010010 = 1F
  • 45 + 44 => 01000101 + 01000100 = 01
  • 54 + 50 => 01010100 + 01010000 = 04
  • 52 + 41 => 01010010 + 01000001 = 13
  • 4F + 53 => 01001111 + 01010011 = 1C
  • 50 + 53 => 01010000 + 01010011 = 03
  • 4F + 57 => 01001111 + 01010111 = 18
  • 4C + 4F => 01001100 + 01001111 = 03
  • 49 + 52 => 01001001 + 01010010 = 1B
  • 54 + 44 => 01010100 + 01000100 = 10

 

After adding the key as shown above it produced the following state table:

Resulting New STATE table :

STATE
1C 18 04 18
0E 01 13 03
1D 1F 1C 1B
17 01 03 10

 

1.1.2        Key generation stage (key schedule)

 

Initial key
50 57 50 57
41 4F 41 4F
53 52 53 52
53 44 53 44

 

 

Key generation for 6th column   Key Generation for 7th column
1ST  

 

        +

4th  

 

+

Rcon  

 

=

5th Cl 2nd  

 

  +

5th  

 

=

8th Cl
50 84 01 D5 57 D5 82
41 d1 00 90 4F 90 DF
53 1b 00 48 52 48 15
53 57 00 08 44 08 4C

 

The generation of the 5th, 9th and 13th columns involve the Shifting of the most right column and Subbytes of the same as well as adding the Rcon. After calculations as demonstrated above, we deduced the following Keys for the next three rounds:

Key for First Round Key for 2nd Round Key for 3rd Round
D5 82 D2 85 E9 6B B9 36 C0 AB 12 2E
90 DF 9E D1 6A B5 2B FA 6F DA F1 0B
48 15 46 14 71 64 22 36 F9 9D BF 89
08 4C 1F 5B 9F D3 CC 97 74 A7 6B FC

 

1.1.3             Transformations stage

This stage has 10 rounds, the first three of which are represented below:

1.1.3.1               Round 1

1.     SubByte Transformation

After using substation table:

9C AD F2 AD
AB 7C 7D 7B
A4 C0 9C AF
F0 7C 7B CA

 

2.     ShiftRows
9C AD F2 AD ß                    No shift
 7C 7D 7B AB ß  Rotate over 1 byte
9C AF A4 C0 ß  Rotate over 2 bytes
CA F0 7C 7B ß  Rotate over 3 bytes

 

3.     MixColumns

 

State  

 

X

 
9C AD F2 AD 02 03 01 01
 7C 7D 7B AB 01 02 03 01
9C AF A4 C0 01 01 02 03
CA F0 7C 7B 03 01 01 02

 

 

Column       New Column
9C  

x

(9c x 2) + (7c x 3) + (9c x 1) + (ca x 1)  

=

F1
7C (9c x 1) + (7c x 2) + (9c x 3) + (ca x 1) 11
9C (9c x 1) + (7c x 1) + (9c x 2) + (ca x 3) 86
CA (9c x 3) + (7c x 1) + (9c x 1) + (ca x 2) D0
 
AD  

x

(ad x 2) + (7d x 3) + (af x 1) + (f0 x 1)  

=

99
7D (ad x 1) + (7d x 2) + (af x 3) + (f0 x 1) 4D
AF (ad x 1) + (7d x 1) + (af x 2) + (f0 x 3) F0
F0 (ad x 3) + (7d x 1) + (af x 1) + (f0 x 2) 71
 
F2  

x

(f2 x 2) + (7b x 3) + (a4 x 1) + (7c x 1)  

=

AA
7B (f2 x 1) + (7b x 2) + (a4 x 3) + (7c x 1) 2B
A4 (f2 x 1) + (7b x 1) + (a4 x 2) + (7c x 3) 5E
7C (f2 x 3) + (7b x 1) + (a4 x 1) + (7c x 2) DC
 
AD   (ad x 2) + (ab x 3) + (c0 x 1) + (7b x 1)  

=

10
AB (ad x 1) + (ab x 2) + (c0 x 3) + (7b x 1) C0
C0 (ad x 1) + (ab x 1) + (c0 x 2) + (7b x 3) 10
7B (ad x 3) + (ab x 1) + (c0 x 1) + (7b x 2) 71

 

The Resulting Mixed Columns table:

F1 99 AA 10
11 4D 2B C0
86 F0 5E 10
D0 71 DC 71

 

4.     AddRoundKey

 

1st Round Key:  

 

+

Mixed Columns:
D5 82 D2 85 F1 99 AA 10
90 DF 9E D1 11 4D 2B C0
48 15 46 14 86 F0 5E 10
08 4C 1F 5B D0 71 DC 71

 

 

Mix Column  

+

Key Column  

=

New Column
F1 D5 24
11 90 81
86 48 CE
D0 08 D8
 
99  

+

82  

=

1B
4D DF 92
F0 15 E5
71 4C 83
 
AA  

+

D2  

=

78
2B 9E B5
5E 46 18
DC 1F C3
 
10  

+

85  

=

95
C0 D1 11
10 14 04
71 5B 2A

 

 

 

Resulting Add Round Key table:

24 1B 78 95
81 92 B5 11
CE E5 18 04
D8 83 C3 2A

1.1.3.2               Round 2

1.           SubByte Transformation
State table  

 

+ S-box =>

Resulting SubBytes Table
24 1B 78 95 36 AF BC 2A
81 92 B5 11 0C 4F D5 82
CE E5 18 04 8B D9 AD F2
D8 83 C3 2A 61 EC 2E 36

 

2.     ShiftRows
  Note:
36 AF BC 2A ß                    No shift
 4F D5 82 0C ß  Rotate over 1 byte
AD F2 8B D9 ß  Rotate over 2 bytes
36 61 EC 2E ß  Rotate over 3 bytes

 

 

3.     MixColums
Sate  

 

x

 
36 AF BC 2A 02 03 01 01
 4F D5 82 0C 01 02 03 01
AD F2 8B D9 01 01 02 03
36 61 EC 2E 03 01 01 02

 

 

Column       New Column
36  

x

(36 x 2) + (4f x 3) + (ad x 1) + (36 x 1)  

=

26
 4F (36 x 1) + (4f x 2) + (ad x 3) + (36 x 1) 73
AD (36 x 1) + (4f x 1) + (ad x 2) + (36 x 3) 62
36 (36 x 3) + (4f x 1) + (ad x 1) + (36 x 2) D4
 
AF  

x

(af x 2) + (d5 x 3) + (f2 x 1) + (61 x 1)  

=

B2
D5 (d5 x 1) + (d5 x 2) + (f2 x 3) + (61 x 1) 72
F2 (f2 x 1) + (d5 x 1) + (f2 x 2) + (61 x 3) 26
61 (61 x 3) + (d5 x 1) + (f2 x 1) + (61 x 2) 14
 
BC  

x

(bc x 2) + (82 x 3) + (8b x 1) + (ec x 1)  

=

99
82 (bc x 1) + (82 x 2) + (8b x 3) + (ec x 1) C9
8B (bc x 1) + (82 x 1) + (8b x 2) + (ec x 3) 1C
EC (bc x 3) + (82 x 1) + (8b x 1) + (ec x 2) 93
 
2A   (2a x 2) + (0c x 3) + (d9 x 1) + (2e x 1)  

=

B7
0C (2a x 1) + (0c x 2) + (d9 x 3) + (2e x 1) 6C
D9 (2a x 1) + (0c x 1) + (d9 x 2) + (2e x 3) FD
2E (2a x 3) + (0c x 1) + (d9 x 1) + (2e x 2) F7

 

Resulting Mixed columns:

26 B2 99 B7
73 72 C9 6C
62 26 1C FD
D4 14 93 F7

 

4.     AddRoundKey

 

2nd Round Key:  

 

+

Mixed Columns:
E9 6B B9 3C 26 B2 99 B7
6A B5 2B FA 73 72 C9 6C
71 64 22 36 62 26 1C FD
9F D3 CC 97 D4 14 93 F7

 

Mix Column  

+

Key Column  

=

New Column
26 E9 CF
73 6A 19
62 71 13
D4 9F 4B
 
B2  

+

6B  

=

D9
72 B5 C7
26 64 42
14 D3 C7
 
99  

+

B9  

=

20
C9 2B E2
1C 22 3E
93 CC 5F
 
B7  

+

3C  

=

8B
6C FA 96
FD 36 CB
F7 97 60

 

Resulting Add Round Key table:

CF D9 20 8B
19 C7 E2 96
13 42 3E CB
4B C7 5F 60

 

  • End of Round 2 –

 

1.1.3.3               Round 3

1.     SubBytes Transformation
State table  

 

+ S-box =>

Resulting SubBytes Table
CF D9 20 8B 8A 35 B7 3D
19 C7 E2 96 D4 C6 98 90
13 42 3E CB 7D 2C B2 1F
4B C7 5F 60 B3 8A CF D0

 

2.     ShiftRows Transformation
State Note:
8A 35 B7 3D ß                    No shift
 C6 98 90 D4 ß  Rotate over 1 byte
B2 1F 7D 2C ß  Rotate over 2 bytes
D0 B3 8A CF ß  Rotate over 3 bytes

 

 

 

 

3.     MixColumns transformation

 

Sate  

 

X

 
8A 35 B7 3D 02 03 01 01
 C6 98 90 D4 01 02 03 01
B2 1F 7D 2C 01 01 02 03
D0 B3 8A CF 03 01 01 02

 

 

Column       New Column
8A  

x

(8a x 2) + (c6 x 3) + (b2 x 1) + (d0 x 1)  

=

3E
 C6 (8a x 1) + (c6 x 2) + (b2 x 3) + (d0 x 1) 00
B2 (8a x 1) + (c6 x 1) + (b2 x 2) + (d0 x 3) 58
D0 (8a x 3) + (c6 x 1) + (b2 x 1) + (d0 x 2) 4A
 
35  

x

(35 x 2) + (98 x 3) + (1f x 1) + (b3 x 1)  

=

75
98 (35 x 1) + (98 x 2) + (1f x 3) + (b3 x 1) 8C
1F (35 x 1) + (98 x 1) + (1f x 2) + (b3 x 3) 5D
B3 (35 x 3) + (98 x 1) + (1f x 1) + (b3 x 2) A5
 
B7  

x

(b7 x 2) + (90 x 3) + (7d x 1) + (8a x 1)  

=

29
90 (b7 x 1) + (90 x 2) + (7d x 3) + (8a x 1) 81
7D (b7 x 1) + (90 x 1) + (7d x 2) + (8a x 3) 58
8A (b7 x 3) + (90 x 1) + (7d x 1) + (8a x 2) 20
 
3D   (3d x 2) + (d4 x 3) + (2c x 1) + (cf x 1)  

=

FE
D4 (3d x 1) + (d4 x 2) + (2c x 3) + (cf x 1) 35
2C (3d x 1) + (d4 x 1) + (2c x 2) + (cf x 3) 7E
CF (3d x 3) + (d4 x 1) + (2c x 1) + (cf x 2) 85

 

Resulting Mixed Columns:

3E 75 29 FE
00 8C 81 35
58 5D 58 7E
4A A5 20 85

 

 

4.     AddRoundKey Transformation

 

3rd Round Key:  

 

+

Mixed Columns (State):
CO AB 12 2E 3E 75 29 FE
6F DA F1 0B 00 8C 81 35
F9 9D BF 89 58 5D 58 7E
74 A7 6B FC 4A A5 20 85

 

Mix Column  

+

Key Column  

=

New Column
3E CO FE
00 6F 6F
58 F9 A1
4A 74 3E
 
75  

+

AB  

=

DE
8C DA 56
5D 9D C0
A5 A7 02
 
29  

+

12  

=

3B
81 F1 70
58 BF E7
20 6B 4B
 
FE  

+

2E  

=

D0
35 0B 3E
7E 89 F7
85 FC 79

 

Resulting Add Round Key table:

FE DE 3B D0
6F 56 70 3E
A1 C0 E7 F7
3E 02 4B 79

 

 

 

 

1.1.4             Summary of all Rounds

Transformation Initial Round 1st Round 2nd Round 3rd Round
 

Initial Transformation

1C 18 04 18      
0E 01 13 03
1D 1F 1C 1B
17 01 03 10
 
 

Sub Bytes

  9C AD F2 AD 36 AF BC 2A 8A 35 B7 3D
AB 7C 7D 7B 0C 4F D5 82 D4 C6 98 90
A4 C0 9C AF 8B D9 AD F2 7D 2C B2 1F
F0 7C 7B CA 61 EC 2E 36 B3 8A CF D0
 
 

Shift Rows

  9C AD F2 AD 36 AF BC 2A 8A 35 B7 3D
7C 7D 7B AB  4F D5 82 0C  C6 98 90 D4
9C AF A4 C0 AD F2 8B D9 B2 1F 7D 2C
CA F0 7C 7B 36 61 EC 2E D0 B3 8A CF
 
 

Mixed Columns

  F1 99 AA 10 26 B2 99 B7 3E 75 29 FE
11 4D 2B C0 73 72 C9 6C 00 8C 81 35
86 F0 5E 10 62 26 1C FD 58 5D 58 7E
D0 71 DC 71 D4 14 93 F7 4A A5 20 85
 
 

Round Key

  D5 82 D2 85 E9 6B B9 3C CO AB 12 2E
90 DF 9E D1 6A B5 2B FA 6F DA F1 0B
48 15 46 14 71 64 22 36 F9 9D BF 89
08 4C 1F 5B 9F D3 CC 97 74 A7 6B FC
 
After Add Round Key   24 1B 78 95 CF D9 20 8B FE DE 3B D0
81 92 B5 11 19 C7 E2 96 6F 56 70 3E
CE E5 18 04 13 42 3E CB A1 C0 E7 F7
D8 83 C3 2A 4B C7 5F 60 3E 02 4B 79