ZUC祖冲之序列密码算法
ZUC主要由LFSR线性反馈移位寄存器, BR比特重组和F非线性函数三部分组成;
输入: 128位长的密钥, 128位长的初始化向量;
输出: \(n, n \in N^+\)个32位长的字串, \(n\)为节拍数(轮数);
算法过程ZUC(KEY, IV, n):
初始化阶段:
for i in 0..32:
-BitReconstruction();
W = F(X_0, X_1, X_2);
LFSRWithInitializationMode(W >> 1);
工作阶段:
BitReconstruction();
F(X_0, X_1, X_2);
LFSRWithWorkMode();
for i in 0..n:
BitReconstruction();
z_i = F(X_0, X_1, X_2) ^ X_3;
LFSRWithWorkMode();
\(z_0||z_1||z_2||z_3\);
\(s_0, s_1, \dots, s_{15}\)为LFSR的16个31位长的寄存器(涉及到s寄存器的是按31位处理的, 注意不是32位, 如循环移位是不同的);
LFSRWithInitilizationMode(u):
\(v=2^{15} s_{15} + 2^{17} s_{13} + 2^{21}s_{10} + 2^{20}s_{4}+(1+2^8)s_0 \mod (2^{31}-1)\);
\(s_{16} = (v + u)\mod (2^{31} - 1)\);
if \(s_{16} = 0\):
\(s_{16} = 2^{31} - 1\);
\(s_0, s_1, \dots, s_{15} = s_1, s_2,\dots, s_{16}\)
LFSRWithWorkMode(u):
\(s_{16}=2^{15} s_{15} + 2^{17} s_{13} + 2^{21}s_{10} + 2^{20}s_{4}+(1+2^8)s_0 \mod (2^{31}-1)\);
if \(s_{16} = 0\):
\(s_{16} = 2^{31} - 1\);
\(s_0, s_1, \dots, s_{15} = s_1, s_2,\dots, s_{16}\)
BitReconstruction():
\(X_0 = ((s_{15} \land 0x7fff8000) \ll 1) \lor (s_{14} \land 0x0000ffff)\);
\(X_1 = ((s_{9} \land 0x7fff8000) \gg 15) \lor ((s_{11} \land 0x0000ffff) \ll 16)\);
\(X_2 = ((s_{5} \land 0x7fff8000) \gg 15) \lor ((s_{7} \land 0x0000ffff) \ll 16)\);
\(X_3 = ((s_{0} \land 0x7fff8000) \gg 15) \lor ((s_{2} \land 0x0000ffff) \ll 16)\);
F(X_0, X_1, X_2):
\(W = (X_0 \oplus R_1) + R_2 \mod 2^{