Skip to content

ShiftRows

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

The ShiftRows operation is fairly straightforward. The bytes in each row are shifted to the left:

  • Each byte in row 0 is shifted 0 places (so this row remains unchanged in this operation).
  • Each byte in row 1 is shifted 1 place.
  • Each byte in row 2 is shifted 2 places.
  • Each byte in row 3 is shifted 3 places.

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

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

As explained, row 0 remains unchanged so we can jump straight to row 1. So we shift each byte in row 1 to the left by 1 place.

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

Next, we shift each byte in row 2 by 2 places.

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

Lastly, we shift each byte in row 3 by 3 places.

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

Inverse operation

The inverse operation of ShiftRows simply shifts to the right (which is the inverse of shifting to the left). The shift amounts are identical to the standard operation (i.e. row 2 is shift 2 places, row 3 is shifted 3 places, etc.).

Clone this wiki locally