# A Novel Encryption Scheme in Ship Remote Control against Differential Fault Attack
## 2 Preliminaries
### SM4 Encryption Algorithm  
SM4 is a symmetric encryption algorithm, specifically a blockcipher, issued by the Organization of State Commercial Administration of China [10]. It has the advantages of easy implementation of software and hardware, and speed, etc. It has little impact on the stability of the intelligent ship information integration platform. SM4 algorithm has a block length of 128 bit and a key length of 128 bit, which is composed of two algorithm modules: the data encryption algorithm and key expansion algorithm. Both the data encryption algorithm and the key expansion algorithm adopt 32 rounds of function cyclic iteration with a similar structure [11]. Detailed descriptions of the data encryption algorithm and the key expansion algorithm are provided below:  
Data encryption and decryption. Define \(z_{2}^{e}\) is the vector product of \(e\) bits, \(<<<<i\) is a 32 bit cyclic left shift of \(i\) bits, \(\oplus\) represents XOR. Let the plaintext input be \(X=(X_{0},X_{1},X_{2},X_{3})\in(Z_{2}^{32})^{4}\) and the ciphertext output be \(Y=(Y_{0},Y_{1},Y_{2},Y_{3})=(X_{35},X_{34},\)\(X_{33},\)\(X_{32},\)\(X_{33},\)\(X_{32}). The round function of each iteration is:  
\[X_{i+4}=F(X_{i},X_{i+1},X_{i+2},X_{i+3},rk_{i})=X_{i}\oplus T(X_{i+1}\oplus X_{ i+2}\oplus X_{i+3}\oplus rk_{i}),i=0,1,2,\cdots,31 \tag{1}\]  
where, \(X_{i}\), \(Y_{i}\) and \(rk_{i}\) are 32 bit, and \(rk_{i}\) is the round key. The synthetic permutation \(\tau\) is a reversible transform, which consists of a nonlinear transform \(\tau\) and linear transform \(L\), i.e., \(T(*)=L(\tau(*))\). The nonlinear transform \(\tau\) is composed of four parallel S-boxes. If the input is \(A=(a_{0},a_{1},a_{2},a_{3})\in(F_{2}^{8})^{4}\) and the output is \(B=(b_{0},b_{1},b_{2},b_{3})\in(F_{2}^{8})^{4}\), then \((b_{0},b_{1},b_{2},b_{3})=\tau(A)=(S(a_{0}),S(a_{1}),S(a_{2}),S(a_{3}))\).  
The input of linear transform \(L\) is the output of nonlinear transform \(\tau\). If the input is \(B\in F_{2}^{32}\) and the output is \(C\in F_{2}^{32}\), then  
\[C=L(B)=B\oplus(B<<2)\oplus(B<<10)\oplus(B<<18)\oplus(B<<24) \tag{2}\]  
The last round of encryption is reverse transform R:  
\[R(Y_{3},Y_{2},Y_{1},Y_{0})=(Y_{0},Y_{1},Y_{2},Y_{3}),Y_{i}\in F_{2}^{32}(i=0, 1,2,3) \tag{3}\]  
The encryption process of SM4 algorithm is shown in Figure 2.  
The decryption algorithm has the same structure as the encryption algorithm, except the round key is used in reverse order.  
The function of the key expansion algorithm is to use the encryption key to generate the round key \(rk_{i}\) of the encryption algorithm. If encryption key \(MK=(MK_{0},MK_{1},MK_{2},MK_{3})\)\(\in(Z_{2}^{32})^{4}\) is set, the initial key is:  
\[(k_{0},k_{1},k_{2},k_{3})=(MK_{0}\oplus FK_{0},MK_{1}\oplus FK_{1},MK_{2} \oplus FK_{2},MK_{3}\oplus FK_{3}) \tag{4}\]  
\[rk_{i}=k_{i+4}=k_{i}\oplus T^{\prime}(k_{i+1},k_{i+2},k_{i+3},ck_{i}),i=0,1,2, \cdots,31 \tag{5}\]  
where, \(T^{\prime}\) transform is the result of changing linear transform \(L\) into \(L^{\prime}\) in \(T\) transform.  
\[L^{\prime}(B)=B\oplus(B<<<13)\oplus(B<<23) \tag{6}\]  
Figure 2: Principle of SM4 encryption algorithm.  
_FK_ of Equation (4) and \(ck_{i}\) of Equation (5) is the fixed value set in relevant standard documents [10].