Skip to content

SubBytes

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

In the SubBytes operation, you must replace each byte in the grid with one from a lookup table called the S-Box (or substitution box). Let's use the following data as an example; assume this is the data you have before performing the SubBytes operation.

19 a0 9a e9
3d f4 c6 f8
e3 e2 8d 48
be 2b 2a 08

The first byte in the grid (a0,0) is 19. The first 4 bits (1) refer to the row from the lookup table and the second 4 bits (9) refer to the column in the lookup table. So 19 would be replaced with d4.

d4 a0 9a e9
3d f4 c6 f8
e3 e2 8d 48
be 2b 2a 08

We would then repeat this for each byte in the grid moving column by column (so start at a0,0, then move to a1,0, then move to a2,0, and finally a3,0 before moving on to a0,1). The next byte (3d located at a1,0) would be replaced with 27.

d4 a0 9a e9
27 f4 c6 f8
e3 e2 8d 48
be 2b 2a 08

We would then continue on until all of the bytes in the grid are replaced.

d4 e0 b8 1e
27 bf b4 41
11 98 5d 52
ae f1 e5 30

Inverse operation

The inverse operation of SubBytes simply uses the inverse S-Box when performing byte substitution.

Clone this wiki locally