diff --git a/SM4-with-AESENCLAST.md b/SM4-with-AESENCLAST.md index 4f524b4..707769a 100644 --- a/SM4-with-AESENCLAST.md +++ b/SM4-with-AESENCLAST.md @@ -554,47 +554,66 @@ print(gen_matrix_based_high_low([0x00,0x50,0x14,0x44,0x89,0xd9,0x9d,0xcd,0xde,0x 16字节State是这样存储的: $in_0 \ in_1 \ in_2 \ in_3 \ in_4\ in_5\ in_6\ in_7\ in_8\ in_9\ in_{10}\ in_{11}\ in_{12}\ in_{13}\ in_{14}\ in_{15}$ -ShiftRows操作: -| | | | | -|------|------|------|------| -|0 | 4 | 8 | c | -|1 | 5 | 9 | d | -|2 | 6 | a | e | -|3 | 7 | b | f | - ShiftRows后,变成 -| | | | | -|------|------|------|------| -|0 | 4 | 8 | c | -|5 | 9 | d | 1 | -|a | e | 2 | 6 | -|f | 3 | 7 | b | +STATE先逆ShiftRows, 再ShiftRows回到初始STATE。 + + + + + + + +
+ + + + + + + + + + + + + +
048c
159d
26ae
37bf
+
+逆ShiftRows后=> + + + + + + + + + + + + + + +
048c
d159
ae26
7bf3
+
+再ShiftRows后=> + + + + + + + + + + + + + + +
048c
159d
26ae
37bf
+
-再来看STATE 先逆ShiftRows, 再ShiftRows -| | | | | -|------|------|------|------| -|0 | 4 | 8 | c | -|1 | 5 | 9 | d | -|2 | 6 | a | e | -|3 | 7 | b | f | - -STATE逆ShiftRows后 -| | | | | -|------|------|------|------| -|0 | 4 | 8 | c | -|d | 1 | 5 | 9 | -|a | e | 2 | 6 | -|7 | b | f | 3 | - -再ShiftRows后, -| | | | | -|------|------|------|------| -|0 | 4 | 8 | c | -|1 | 5 | 9 | d | -|2 | 6 | a | e | -|3 | 7 | b | f | - -回到初始STATE。 # Reference * [AES-NI used in SM4](https://github.com/mjosaarinen/sm4ni)