Skip to content

AddRoundKey

Michael Mattioli edited this page Feb 24, 2020 · 3 revisions

The AddRoundKey operation is fairly straightforward. You perform an XOR operation on each byte in your data grid with a corresponding byte in the round key grid.

Let's begin with the resulting data from the MixColumns operation; this is the data before performing the AddRoundKey operation.

04 e0 48 28
66 cb f8 06
81 19 d3 26
e5 9a 7a 4c

Let's assume this is our round key for this particular round. If you don't already understand how the round keys are generated, read the documentation which explains the key schedule.

a0 88 23 2a
fa 54 a3 6c
fe 2c 39 76
17 b1 39 05

Starting with the first columns each from the data and the round key, apply an XOR operation to each of the bytes in both columns.

  • 04 XOR a0 = a4
  • 66 XOR fa = 9c
  • 81 XOR fe = 7f
  • e5 XOR 17 = f2

Now we have our first column replaced.

a4 e0 48 28
9c cb f8 06
7f 19 d3 26
f2 9a 7a 4c

We repeat this for the remaining columns until all of the bytes are replaced.

a4 68 6b 02
9c 9f 5b 6a
7f 35 ea 50
f2 2b 43 49
Clone this wiki locally