目录
一、理论基础
步骤1:密钥生成
步骤2:填充数据
步骤3:分组加密
步骤4:密文输出
二、核心程序
三、仿真结论
数据加解密是信息安全领域中的一个重要问题。在现代通信和计算机网络中,我们经常需要通过公共网络传输敏感信息,例如个人身份信息、财务信息等。因此,数据加解密技术在保护信息安全和隐私方面具有重要的作用。基于AES算法的数据加解密方法主要包括以下步骤:
首先,需要生成一个密钥。密钥的长度可以是128位、192位或256位,根据需要选择适当的密钥长度。密钥的生成可以使用随机数生成器,以确保密钥的安全性。
接下来,需要对要加密的数据进行填充。由于AES算法是块加密算法,要求输入数据的长度必须是16的倍数。如果输入数据长度不是16的倍数,则需要进行填充。可以使用标准的填充方法,例如PKCS#7填充方法。
当数据填充完成后,需要将数据分组,并对每个分组进行加密。AES算法使用的是分组密码模式,可以选择使用ECB、CBC、CFB或OFB等模式。可以根据需要选择适当的分组密码模式,并对每个分组进行加密。
最后,将加密后的数据输出为密文。可以将每个分组的密文连接起来,形成最终的密文。如果需要传输密文,则需要将密文进行传输。下面给出一些相关的数学公式,以帮助更好地理解基于AES算法的数据加解密方法。
密钥扩展:
$$
w_i =
\begin{cases}
\operatorname{Word}(i) & \text{if } i \in [0,N-1]\
\operatorname{SubWord}(\operatorname{RotWord}(w_{i-1}) \oplus w_{i-N}) \oplus r_i & \text{if } i \in [N, Nb(Nr+1)-1]
\end{cases}
$$
其中,$w_i$是密钥扩展中的第$i$个字,$\operatorname{Word}(i)$是密钥中的第$i$个字,$N$是密钥字数,$Nb$是每个分组中的字数,$Nr$是加密轮数,$\operatorname{RotWord}$是循环移位操作,$\operatorname{SubWord}$是字节替代操作,$r_i$是轮常数。
字节替代:
$$
\operatorname{SubWord}(w) = [sbox(w_0), sbox(w_1), sbox(w_2), sbox(w_3)]
$$
其中,$w$是一个字,$sbox$是字节替代表。
循环移位:
$$
\operatorname{RotWord}([a,b,c,d]) = [b,c,d,a]
$$
其中,$[a,b,c,d]$是一个字。
密钥加:
$$
\operatorname{AddRoundKey}(s,k) = s \oplus k
$$
其中,$s$是状态矩阵,$k$是轮密钥。
字节替代:
$$
\operatorname{SubBytes}(s) = [sbox(s_{i,j})]
$$
其中,$s_{i,j}$是状态矩阵中的一个字节,$sbox$是字节替代表。
行移位:
$$
\operatorname{ShiftRows}(s) =
\begin{bmatrix}
s_{0,0} & s_{0,1} & s_{0,2} & s_{0,3} \
s_{1,1} & s_{1,2} & s_{1,3} & s_{1,0} \
s_{2,2} & s_{2,3} & s_{2,0} & s_{2,1} \
s_{3,3} & s_{3,0} & s_{3,1} & s_{3,2}
\end{bmatrix}
$$
其中,$s$是状态矩阵。
列混淆:
$$
\operatorname{MixColumns}(s) =
\begin{bmatrix}
\operatorname{MixColumn}(s_{0,0}, s_{1,0}, s_{2,0}, s_{3,0}) \
\operatorname{MixColumn}(s_{0,1}, s_{1,1}, s_{2,1}, s_{3,1}) \
\operatorname{MixColumn}(s_{0,2}, s_{1,2}, s_{2,2}, s_{3,2}) \
\operatorname{MixColumn}(s_{0,3}, s_{1,3}, s_{2,3}, s_{3,3})
\end{bmatrix}
$$
其中,$\operatorname{MixColumn}$是列混淆操作。
逆字节替代:
$$
\operatorname{InvSubBytes}(s) = [\operatorname{inv_sbox}(s_{i,j})]
$$
其中,$s_{i,j}$是状态矩阵中的一个字节,$\operatorname{inv_sbox}$是逆字节替代表。
逆行移位:
$$
\operatorname{InvShiftRows}(s) =
\begin{bmatrix}
s_{0,0} & s_{0,1} & s_{0,2} & s_{0,3} \
s_{1,3} & s_{1,0} & s_{1,1} & s_{1,2} \
s_{2,2} & s_{2,3} & s_{2,0} & s_{2,1} \
s_{3,1} & s_{3,2} & s_{3,3} & s_{3,0}
\end{bmatrix}
$$
其中,$s$是状态矩阵。
逆列混淆:
$$
\operatorname{InvMixColumns}(s) =
\begin{bmatrix}
\operatorname{InvMixColumn}(s_{0,0}, s_{1,0}, s_{2,0}, s_{3,0}) \
\operatorname{InvMixColumn}(s_{0,1}, s_{1,1}, s_{2,1}, s_{3,1}) \
\operatorname{InvMixColumn}(s_{0,2}, s_{1,2}, s_{2,2}, s_{3,2}) \
\operatorname{InvMixColumn}(s_{0,3}, s_{1,3}, s_{2,3}, s_{3,3})
\end{bmatrix}
$$
其中,$\operatorname{InvMixColumn}$是逆列混淆操作。
加密算法:
$$
\operatorname{AES}(s, k) = \operatorname{AddRoundKey}(\operatorname{SubBytes}(\operatorname{ShiftRows}(\operatorname{MixColumns}(s))), k)
$$
其中,$s$是状态矩阵,$k$是轮密钥。
解密算法:
$$
\operatorname{AES}^{-1}(s, k) = \operatorname{AddRoundKey}(\operatorname{InvMixColumns}(\operatorname{InvShiftRows}(\operatorname{InvSubBytes}(s))), k)
$$
其中,$s$是状态矩阵,$k$是轮密钥。
function state_out = mix_columns (state_in, poly_mat)
mod_pol = bin2dec ('100011011');
% Loop over all columns of the state matrix
for i_col_state = 1 : 4
% Loop over all rows of the state matrix
for i_row_state = 1 : 4
% Initialize the scalar product accumulator
temp_state = 0;
% For the (innner) matrix vector product we want to do
% a scalar product
% of the current row vector of poly_mat
% and the current column vector of the state matrix.
% Therefore we need a counter over
% all elements of the current row vector of poly_mat and
% all elements of the current column vector of the state matrix
for i_inner = 1 : 4
% Multiply (GF(2^8) polynomial multiplication)
% the current element of the current row vector of poly_mat with
% the current element of the current column vector of the state matrix
temp_prod = poly_mult (...
poly_mat(i_row_state, i_inner), ...
state_in(i_inner, i_col_state), ...
mod_pol);
% Add (XOR) the recently calculated product
% to the scalar product accumulator
temp_state = bitxor (temp_state, temp_prod);
end
% Declare (save and return) the final scalar product accumulator
% as the current state matrix element
state_out(i_row_state, i_col_state) = temp_state;
end
end
up2160
s_box : 63 7c 77 7b f2 6b 6f c5 30 01 67 2b fe d7 ab 76
ca 82 c9 7d fa 59 47 f0 ad d4 a2 af 9c a4 72 c0
b7 fd 93 26 36 3f f7 cc 34 a5 e5 f1 71 d8 31 15
04 c7 23 c3 18 96 05 9a 07 12 80 e2 eb 27 b2 75
09 83 2c 1a 1b 6e 5a a0 52 3b d6 b3 29 e3 2f 84
53 d1 00 ed 20 fc b1 5b 6a cb be 39 4a 4c 58 cf
d0 ef aa fb 43 4d 33 85 45 f9 02 7f 50 3c 9f a8
51 a3 40 8f 92 9d 38 f5 bc b6 da 21 10 ff f3 d2
cd 0c 13 ec 5f 97 44 17 c4 a7 7e 3d 64 5d 19 73
60 81 4f dc 22 2a 90 88 46 ee b8 14 de 5e 0b db
e0 32 3a 0a 49 06 24 5c c2 d3 ac 62 91 95 e4 79
e7 c8 37 6d 8d d5 4e a9 6c 56 f4 ea 65 7a ae 08
ba 78 25 2e 1c a6 b4 c6 e8 dd 74 1f 4b bd 8b 8a
70 3e b5 66 48 03 f6 0e 61 35 57 b9 86 c1 1d 9e
e1 f8 98 11 69 d9 8e 94 9b 1e 87 e9 ce 55 28 df
8c a1 89 0d bf e6 42 68 41 99 2d 0f b0 54 bb 16
inv_s_box : 52 09 6a d5 30 36 a5 38 bf 40 a3 9e 81 f3 d7 fb
7c e3 39 82 9b 2f ff 87 34 8e 43 44 c4 de e9 cb
54 7b 94 32 a6 c2 23 3d ee 4c 95 0b 42 fa c3 4e
08 2e a1 66 28 d9 24 b2 76 5b a2 49 6d 8b d1 25
72 f8 f6 64 86 68 98 16 d4 a4 5c cc 5d 65 b6 92
6c 70 48 50 fd ed b9 da 5e 15 46 57 a7 8d 9d 84
90 d8 ab 00 8c bc d3 0a f7 e4 58 05 b8 b3 45 06
d0 2c 1e 8f ca 3f 0f 02 c1 af bd 03 01 13 8a 6b
3a 91 11 41 4f 67 dc ea 97 f2 cf ce f0 b4 e6 73
96 ac 74 22 e7 ad 35 85 e2 f9 37 e8 1c 75 df 6e
47 f1 1a 71 1d 29 c5 89 6f b7 62 0e aa 18 be 1b
fc 56 3e 4b c6 d2 79 20 9a db c0 fe 78 cd 5a f4
1f dd a8 33 88 07 c7 31 b1 12 10 59 27 80 ec 5f
60 51 7f a9 19 b5 4a 0d 2d e5 7a 9f 93 c9 9c ef
a0 e0 3b 4d ae 2a f5 b0 c8 eb bb 3c 83 53 99 61
17 2b 04 7e ba 77 d6 26 e1 69 14 63 55 21 0c 7d
********************************************
* *
* R C O N C R E A T I O N *
* *
********************************************
rcon : 01 00 00 00
02 00 00 00
04 00 00 00
08 00 00 00
10 00 00 00
20 00 00 00
40 00 00 00
80 00 00 00
1b 00 00 00
36 00 00 00
********************************************
* *
* K E Y E X P A N S I O N *
* *
********************************************
w(1:4, :) : 00 01 02 03
04 05 06 07
08 09 0a 0b
0c 0d 0e 0f
After rot_word : 0d 0e 0f 0c
After sub_bytes : d7 ab 76 fe
rcon(05, :) : 01 00 00 00
After rcon xor : d6 ab 76 fe
w(05, :) : d6 aa 74 fd
w(06, :) : d2 af 72 fa
w(07, :) : da a6 78 f1
w(08, :) : d6 ab 76 fe
After rot_word : ab 76 fe d6
After sub_bytes : 62 38 bb f6
rcon(09, :) : 02 00 00 00
After rcon xor : 60 38 bb f6
w(09, :) : b6 92 cf 0b
w(10, :) : 64 3d bd f1
w(11, :) : be 9b c5 00
w(12, :) : 68 30 b3 fe
After rot_word : 30 b3 fe 68
After sub_bytes : 04 6d bb 45
rcon(13, :) : 04 00 00 00
After rcon xor : 00 6d bb 45
w(13, :) : b6 ff 74 4e
w(14, :) : d2 c2 c9 bf
w(15, :) : 6c 59 0c bf
w(16, :) : 04 69 bf 41
After rot_word : 69 bf 41 04
After sub_bytes : f9 08 83 f2
rcon(17, :) : 08 00 00 00
After rcon xor : f1 08 83 f2
w(17, :) : 47 f7 f7 bc
w(18, :) : 95 35 3e 03
w(19, :) : f9 6c 32 bc
w(20, :) : fd 05 8d fd
After rot_word : 05 8d fd fd
After sub_bytes : 6b 5d 54 54
rcon(21, :) : 10 00 00 00
After rcon xor : 7b 5d 54 54
w(21, :) : 3c aa a3 e8
w(22, :) : a9 9f 9d eb
w(23, :) : 50 f3 af 57
w(24, :) : ad f6 22 aa
After rot_word : f6 22 aa ad
After sub_bytes : 42 93 ac 95
rcon(25, :) : 20 00 00 00
After rcon xor : 62 93 ac 95
w(25, :) : 5e 39 0f 7d
w(26, :) : f7 a6 92 96
w(27, :) : a7 55 3d c1
w(28, :) : 0a a3 1f 6b
After rot_word : a3 1f 6b 0a
After sub_bytes : 0a c0 7f 67
rcon(29, :) : 40 00 00 00
After rcon xor : 4a c0 7f 67
w(29, :) : 14 f9 70 1a
w(30, :) : e3 5f e2 8c
w(31, :) : 44 0a df 4d
w(32, :) : 4e a9 c0 26
After rot_word : a9 c0 26 4e
After sub_bytes : d3 ba f7 2f
rcon(33, :) : 80 00 00 00
After rcon xor : 53 ba f7 2f
w(33, :) : 47 43 87 35
w(34, :) : a4 1c 65 b9
w(35, :) : e0 16 ba f4
w(36, :) : ae bf 7a d2
After rot_word : bf 7a d2 ae
After sub_bytes : 08 da b5 e4
rcon(37, :) : 1b 00 00 00
After rcon xor : 13 da b5 e4
w(37, :) : 54 99 32 d1
w(38, :) : f0 85 57 68
w(39, :) : 10 93 ed 9c
w(40, :) : be 2c 97 4e
After rot_word : 2c 97 4e be
After sub_bytes : 71 88 2f ae
rcon(41, :) : 36 00 00 00
After rcon xor : 47 88 2f ae
w(41, :) : 13 11 1d 7f
w(42, :) : e3 94 4a 17
w(43, :) : f3 07 a7 8b
w(44, :) : 4d 2b 30 c5
********************************************
* *
* P O L Y _ M A T C R E A T I O N *
* *
********************************************
poly_mat : 02 03 01 01
01 02 03 01
01 01 02 03
03 01 01 02
inv_poly_mat : 0e 0b 0d 09
09 0e 0b 0d
0d 09 0e 0b
0b 0d 09 0e
********************************************
* *
* C I P H E R *
* *
********************************************
Initial state : 00 44 88 cc
11 55 99 dd
22 66 aa ee
33 77 bb ff
Initial round key : 00 04 08 0c
01 05 09 0d
02 06 0a 0e
03 07 0b 0f
State at start of round 1 : 00 40 80 c0
10 50 90 d0
20 60 a0 e0
30 70 b0 f0
After sub_bytes : 63 09 cd ba
ca 53 60 70
b7 d0 e0 e1
04 51 e7 8c
After shift_rows : 63 09 cd ba
53 60 70 ca
e0 e1 b7 d0
8c 04 51 e7
After mix_columns : 5f 57 f7 1d
72 f5 be b9
64 bc 3b f9
15 92 29 1a
Round key : d6 d2 da d6
aa af a6 ab
74 72 78 76
fd fa f1 fe
State at start of round 2 : 89 85 2d cb
d8 5a 18 12
10 ce 43 8f
e8 68 d8 e4
After sub_bytes : a7 97 d8 1f
61 be ad c9
ca 8b 1a 73
9b 45 61 69
After shift_rows : a7 97 d8 1f
be ad c9 61
1a 73 ca 8b
69 9b 45 61
After mix_columns : ff 31 64 77
87 d8 51 3a
96 6a 51 d0
84 51 fa 09
Round key : b6 64 be 68
92 3d 9b 30
cf bd c5 b3
0b f1 00 fe
State at start of round 3 : 49 55 da 1f
15 e5 ca 0a
59 d7 94 63
8f a0 fa f7
After sub_bytes : 3b fc 57 c0
59 d9 74 67
cb 0e 22 fb
73 e0 2d 68
After shift_rows : 3b fc 57 c0
d9 74 67 59
22 fb cb 0e
68 73 e0 2d
After mix_columns : 4c f7 2c 53
9c 71 3f 4d
1e f0 86 f2
66 76 8e 56
Round key : b6 d2 6c 04
ff c2 59 69
74 c9 0c bf
4e bf bf 41
State at start of round 4 : fa 25 40 57
63 b3 66 24
6a 39 8a 4d
28 c9 31 17
After sub_bytes : 2d 3f 09 5b
fb 6d 33 36
02 12 7e e3
34 dd c7 f0
After shift_rows : 2d 3f 09 5b
6d 33 36 fb
7e e3 02 12
f0 34 dd c7
After mix_columns : 63 fc 97 75
85 53 be 47
b7 8d 47 d6
9f f9 8e 91
Round key : 47 95 f9 fd
f7 35 6c 05
f7 3e 32 8d
bc 03 bc fd
State at start of round 5 : 24 69 6e 88
72 66 d2 42
40 b3 75 5b
23 fa 32 6c
After sub_bytes : 36 f9 9f c4
40 33 b5 2c
09 6d 9d 39
26 2d 23 50
After shift_rows : 36 f9 9f c4
33 b5 2c 40
9d 39 09 6d
50 26 2d 23
After mix_columns : f4 32 75 1d
bc e5 f1 d0
d4 54 d6 3b
54 d0 c5 3c
Round key : 3c a9 50 ad
aa 9f f3 f6
a3 9d af 22
e8 eb 57 aa
State at start of round 6 : c8 9b 25 b0
16 7a 02 26
77 c9 79 19
bc 3b 92 96
After sub_bytes : e8 14 3f e7
47 da 77 f7
f5 dd b6 d4
65 e2 4f 90
After shift_rows : e8 14 3f e7
da 77 f7 47
b6 d4 f5 dd
90 65 e2 4f
After mix_columns : 98 00 6b 8e
16 f8 2c 5a
ee 7f 04 d0
74 55 9c 36
Round key : 5e f7 a7 0a
39 a6 55 a3
0f 92 3d 1f
7d 96 c1 6b
State at start of round 7 : c6 f7 cc 84
2f 5e 79 f9
e1 ed 39 cf
09 c3 5d 5d
After sub_bytes : b4 68 4b 5f
15 58 b6 99
f8 55 12 8a
01 2e 4c 4c
After shift_rows : b4 68 4b 5f
58 b6 99 15
12 8a f8 55
4c 01 2e 4c
After mix_columns : c5 9a f0 98
7e 9b 5f c6
1c d2 4b 34
15 86 e0 39
Round key : 14 e3 44 4e
f9 5f 0a a9
70 e2 df c0
1a 8c 4d 26
State at start of round 8 : d1 79 b4 d6
87 c4 55 6f
6c 30 94 f4
0f 0a ad 1f
After sub_bytes : 3e b6 8d f6
17 1c fc a8
50 04 22 bf
76 67 95 c0
After shift_rows : 3e b6 8d f6
1c fc a8 17
22 bf 50 04
c0 76 67 95
After mix_columns : ba a1 d5 5f
a0 f9 51 41
3d b5 2c 4d
e7 6e ba 23
Round key : 47 a4 e0 ae
43 1c 16 bf
87 65 ba 7a
35 b9 f4 d2
State at start of round 9 : fd 05 35 f1
e3 e5 47 fe
ba d0 96 37
d2 d7 4e f1
After sub_bytes : 54 6b 96 a1
11 d9 a0 bb
f4 70 90 9a
b5 0e 2f a1
After shift_rows : 54 6b 96 a1
d9 a0 bb 11
90 9a f4 70
a1 b5 0e 2f
After mix_columns : e9 02 1b 35
f7 30 f2 3c
4e 20 cc 21
ec f6 f2 c7
Round key : 54 f0 10 be
99 85 93 2c
32 57 ed 97
d1 68 9c 4e
State at start of final round : bd f2 0b 8b
6e b5 61 10
7c 77 21 b6
3d 9e 6e 89
After sub_bytes : 7a 89 2b 3d
9f d5 ef ca
10 f5 fd 4e
27 0b 9f a7
After shift_rows : 7a 89 2b 3d
d5 ef ca 9f
fd 4e 10 f5
a7 27 0b 9f
Round key : 13 e3 f3 4d
11 94 07 2b
1d 4a a7 30
7f 17 8b c5
Final state : 69 6a d8 70
c4 7b cd b4
e0 04 b7 c5
d8 30 80 5a
********************************************
* *
* I N V E R S E C I P H E R *
* *
********************************************
Initial state : 69 6a d8 70
c4 7b cd b4
e0 04 b7 c5
d8 30 80 5a
Initial round key : 13 e3 f3 4d
11 94 07 2b
1d 4a a7 30
7f 17 8b c5
State at start of round 9 : 7a 89 2b 3d
d5 ef ca 9f
fd 4e 10 f5
a7 27 0b 9f
After inv_shift_rows : 7a 89 2b 3d
9f d5 ef ca
10 f5 fd 4e
27 0b 9f a7
After inv_sub_bytes : bd f2 0b 8b
6e b5 61 10
7c 77 21 b6
3d 9e 6e 89
Round key : 54 f0 10 be
99 85 93 2c
32 57 ed 97
d1 68 9c 4e
After add_round_key : e9 02 1b 35
f7 30 f2 3c
4e 20 cc 21
ec f6 f2 c7
State at start of round 8 : 54 6b 96 a1
d9 a0 bb 11
90 9a f4 70
a1 b5 0e 2f
After inv_shift_rows : 54 6b 96 a1
11 d9 a0 bb
f4 70 90 9a
b5 0e 2f a1
After inv_sub_bytes : fd 05 35 f1
e3 e5 47 fe
ba d0 96 37
d2 d7 4e f1
Round key : 47 a4 e0 ae
43 1c 16 bf
87 65 ba 7a
35 b9 f4 d2
After add_round_key : ba a1 d5 5f
a0 f9 51 41
3d b5 2c 4d
e7 6e ba 23
State at start of round 7 : 3e b6 8d f6
1c fc a8 17
22 bf 50 04
c0 76 67 95
After inv_shift_rows : 3e b6 8d f6
17 1c fc a8
50 04 22 bf
76 67 95 c0
After inv_sub_bytes : d1 79 b4 d6
87 c4 55 6f
6c 30 94 f4
0f 0a ad 1f
Round key : 14 e3 44 4e
f9 5f 0a a9
70 e2 df c0
1a 8c 4d 26
After add_round_key : c5 9a f0 98
7e 9b 5f c6
1c d2 4b 34
15 86 e0 39
State at start of round 6 : b4 68 4b 5f
58 b6 99 15
12 8a f8 55
4c 01 2e 4c
After inv_shift_rows : b4 68 4b 5f
15 58 b6 99
f8 55 12 8a
01 2e 4c 4c
After inv_sub_bytes : c6 f7 cc 84
2f 5e 79 f9
e1 ed 39 cf
09 c3 5d 5d
Round key : 5e f7 a7 0a
39 a6 55 a3
0f 92 3d 1f
7d 96 c1 6b
After add_round_key : 98 00 6b 8e
16 f8 2c 5a
ee 7f 04 d0
74 55 9c 36
State at start of round 5 : e8 14 3f e7
da 77 f7 47
b6 d4 f5 dd
90 65 e2 4f
After inv_shift_rows : e8 14 3f e7
47 da 77 f7
f5 dd b6 d4
65 e2 4f 90
After inv_sub_bytes : c8 9b 25 b0
16 7a 02 26
77 c9 79 19
bc 3b 92 96
Round key : 3c a9 50 ad
aa 9f f3 f6
a3 9d af 22
e8 eb 57 aa
After add_round_key : f4 32 75 1d
bc e5 f1 d0
d4 54 d6 3b
54 d0 c5 3c
State at start of round 4 : 36 f9 9f c4
33 b5 2c 40
9d 39 09 6d
50 26 2d 23
After inv_shift_rows : 36 f9 9f c4
40 33 b5 2c
09 6d 9d 39
26 2d 23 50
After inv_sub_bytes : 24 69 6e 88
72 66 d2 42
40 b3 75 5b
23 fa 32 6c
Round key : 47 95 f9 fd
f7 35 6c 05
f7 3e 32 8d
bc 03 bc fd
After add_round_key : 63 fc 97 75
85 53 be 47
b7 8d 47 d6
9f f9 8e 91
State at start of round 3 : 2d 3f 09 5b
6d 33 36 fb
7e e3 02 12
f0 34 dd c7
After inv_shift_rows : 2d 3f 09 5b
fb 6d 33 36
02 12 7e e3
34 dd c7 f0
After inv_sub_bytes : fa 25 40 57
63 b3 66 24
6a 39 8a 4d
28 c9 31 17
Round key : b6 d2 6c 04
ff c2 59 69
74 c9 0c bf
4e bf bf 41
After add_round_key : 4c f7 2c 53
9c 71 3f 4d
1e f0 86 f2
66 76 8e 56
State at start of round 2 : 3b fc 57 c0
d9 74 67 59
22 fb cb 0e
68 73 e0 2d
After inv_shift_rows : 3b fc 57 c0
59 d9 74 67
cb 0e 22 fb
73 e0 2d 68
After inv_sub_bytes : 49 55 da 1f
15 e5 ca 0a
59 d7 94 63
8f a0 fa f7
Round key : b6 64 be 68
92 3d 9b 30
cf bd c5 b3
0b f1 00 fe
After add_round_key : ff 31 64 77
87 d8 51 3a
96 6a 51 d0
84 51 fa 09
State at start of round 1 : a7 97 d8 1f
be ad c9 61
1a 73 ca 8b
69 9b 45 61
After inv_shift_rows : a7 97 d8 1f
61 be ad c9
ca 8b 1a 73
9b 45 61 69
After inv_sub_bytes : 89 85 2d cb
d8 5a 18 12
10 ce 43 8f
e8 68 d8 e4
Round key : d6 d2 da d6
aa af a6 ab
74 72 78 76
fd fa f1 fe
After add_round_key : 5f 57 f7 1d
72 f5 be b9
64 bc 3b f9
15 92 29 1a
State at start of final round : 63 09 cd ba
53 60 70 ca
e0 e1 b7 d0
8c 04 51 e7
After inv_shift_rows : 63 09 cd ba
ca 53 60 70
b7 d0 e0 e1
04 51 e7 8c
After inv_sub_bytes : 00 40 80 c0
10 50 90 d0
20 60 a0 e0
30 70 b0 f0
Round key : 00 04 08 0c
01 05 09 0d
02 06 0a 0e
03 07 0b 0f
Final state : 00 44 88 cc
11 55 99 dd
22 66 aa ee
33 77 bb ff
ans =
0 17 34 51 68 85 102 119 136 153 170 187 204 221 238 255
ciphertext =105 196 224 216 106 123 4 48 216 205 183 128 112 180 197 90
re_plaintext =0 17 34 51 68 85 102 119 136 153 170 187 204 221 238 255
>>