Cryptography Reference
In-Depth Information
ShiftRows() Transformation
The ShiftRows() transformation cyclically shifts left the bytes in row
r
(0
≤
r
≤
3)
for
r
bytes. This means that the bytes in the first row (i.e.,
r
=0) are not shifted at
all, the bytes in the second row (i.e.,
r
=1) are cyclically shifted left one byte, the
bytes in the third row (i.e.,
r
=2) are cyclically shifted left two bytes, and the bytes
in the fourth row (i.e.,
r
=3) are cyclically shifted left three bytes. Consequently,
for 0
≤
r<
4 and 0
≤
c<N
b
=4, the ShiftRows() transformation can be formally
expressed as follows:
s
r,c
=
s
r,c
+
shif t
(
r,N
b
)mod
N
b
(10.5)
In this formula, the shift value
shift
(
r, N
b
) depends only on the row number
r
(remember that
N
b
is always equal to 4):
shift
(1
,
4)
=
1
shift
(2
,
4)
=
2
shift
(3
,
4)
=
3
For example,
s
2
,
1
=
s
2
,
1+
shif t
(2
,
4) mod 4
=
s
2
,
1+2 mod 4
=
s
2
,
3
.The
ShiftRows() transformation is illustrated in Figure 10.7. Note that the elements of
s
are the same as the elements of
s
, and that only their ordering changes when the
State is being tranformed.
I
+
+
+
+1
+
+3
+1
+3
+
+3
+1
+
+
+
+3
+1
3+
3+3
3+1
3+
3+
3+3
3+1
3+
1+
1+
1+
1+3
1+1
1+1
1+
1+3
Figure 10.7
The ShiftRows() transformation of the AES encryption algorithm.