Improvements for Finding Impossible Differentials of Block Cipher Structures

In this paper we improve Wu and Wang’s method for finding impossible differentials of block cipher structures. This improvement is more general than Wu and Wang’s method that it can find more impossible differentials with less time. We apply it on GenCAST256, Misty, Gen-Skipjack, Four-Cell, Gen-MARS, SMS4, MIBS, Camellia*, LBlock, E2 and SNAKE block ciphers. All impossible differentials discovered by the algorithm are the same as Wu’s method. Besides, for the 8-round MIBS block cipher, we find 4 new impossible differentials, which are not listed in Wu and Wang’s results. The experiment results show that the improved algorithm can not only find more impossible differentials, but also largely reduce the search time.


Introduction
Impossible differential cryptanalysis, introduced by Biham et al. [1] and Knudsen [2] independently, is a special case of differential cryptanalysis that uses differentials with probability zero to sieve the right keys from the wrong keys.It is one of the most powerful attacks for block ciphers and is considered in many block cipher designs [3][4][5][6][7][8][9][10]. The best cryptanalytic results for some block ciphers are obtained by impossible differential cryptanalysis [1,11].For example, the currently best attack on the 31-round Skipjack is still the impossible differential cryptanalysis by Biham et al. [1].
The key step in impossible differential cryptanalysis of a block cipher is to find the longest impossible differential.Given two variables  1 ,  2 ∈ F  2 , the difference of  1 and  2 is usually denoted as Δ =  1 ⊕  2 .An impossible differential for an -subblock block cipher is in the form (Δin   Δout), where Δin = (Δ 1 , . . ., Δ  ) and Δout = (Δ 1 , . . ., Δ  ).(Δin   Δout) means the probability of the output difference is Δout after  rounds of a block cipher for an input difference Δin is zero.At the first glance, impossible differentials are obtained manually by observing the block cipher structure.However, since the emergence of impossible differential cryptanalysis, automated techniques for finding impossible differentials have been introduced.
The first automated technique is called the Shrinking method introduced by Biham et al. [1].This method is simple but very useful.It only considers truncated differentials whose differences distinguish only between zero and arbitrary nonzero difference.Given a block cipher, the adversary first designs a mini version of this block cipher, which scales down the block cipher but preserves the global structure.Then the adversary exhaustively searches for this mini cipher and obtains some truncated impossible differentials.Usually these truncated impossible differentials of the mini cipher remain impossible differentials in the normal version.This method can deal with most block ciphers in the real world.However, it becomes very slow if the number of subblocks of a block cipher is as large as 16, since exhaustive search on the mini version of this type of cipher is still a heavy load for most computers.
The second automated technique is based on the miss in the middle approach.This method combines two differentials, one from the input and the other from the output, both with probability 1.However, these two differentials cannot meet in the middle since they can never be equal in the middle.The U method [12,13] and the UID method [14] both belong to this category.In the U method and the UID method, the adversary first represents the block cipher structure as a matrix; then given a differential pair (Δin, Δout), he calculates the -round intermediate difference from Δin forwardly and the ( − )-round intermediate difference from Δout backwardly by the matrix method.If there is a contradiction for these two intermediate differences, then an impossible differential (Δin   Δout) is verified.Representing a block cipher by the matrix has been a popular method in impossible differential and integral and zero correlation linear cryptanalysis [8,10,[15][16][17][18][19][20].
In [21], Wu and Wang extend the U-method and UID method to a more generalized method which does not use the miss in the middle approach.They treat the -round block cipher structure as a system of equations, which describe the propagation behavior of differences in the inner primitives, especially sbox permutations or branch swapping of the block cipher structure.To judge if a truncated differential (Δin, Δout) is impossible, they predict information about unknown variables from the known ones iteratively.Finally a truncated differential is verified by checking the constrained conditions in the system.This method is similar to a linear programming method for solving optimization problems.
In [22], Sun et al. show that Wu and Wang's automatic search method can find all impossible differentials of a cipher that are independent of the choices of the inner primitives.However, Wu and Wang's method can only find all truncated impossible differentials since the choice of truncated difference may result in missing some impossible differentials.Wu and Wang's method only considers differences Δin = ( 1 , . . .,   ) and Δout = ( 1 , . . .,   ), where   and   are zero or nonzero values.They assign an indicator to indicate the choice of   and   , representing by 0 a subblock without difference and by 1 a subblock with a difference.The relationships between nonzero differences have been omitted.For example,   may be equal to some   , where 1 ≤ ,  ≤ .If some linear constraints between nonzero variables in Δin and Δout are needed, Wu and Wang claimed their method could still work by translating all linear constraints into the system of equations.However, this method increases the run complexity and implementation of the search method.Since it changes the equation system for every value of (Δin, Δout) and if the relationship between Δin and Δout is complicated, the matrix will be very large.
The idea of the UID method is that it represents the differential with symbols and utilizes the propagation property of the linear accumulated symbols.The idea of the Wu-Wang method is to utilize solving linear equations to determine an impossible differential.We show that the Wu-Wang method can be improved by combining the idea of the UID method and Wu-Wang method.Instead of using 1 to represent the nonzero difference, we use a letter symbol to represent a difference and different symbols represent different nonzero values.This method can represent more relationships between these subblocks.For example, if Δin = (, 0, 0, ) and Δout = (, 0, 0, ) for a 4-subblock structure where  and  are different nonzero values, then we have  1 =  4 =  1 and  4 ̸ =  1 .In our method, the matrix of the system does not need to be changed with (Δin, Δout).We also improve the Wu-Wang method by simplifying the test of whether there are solutions for linear systems.Since the most time consuming part is the matrix operation, our improved method can find more impossible differentials in less time.

Preliminaries
In this section we introduce some basic concepts and notions used in this paper.We first introduce the block cipher structures.Next we review the solvability of a system of linear equations.

Block Cipher Structures.
There are mainly two block cipher structures, which are the Feistel structure and its generalizations and the substitute permutation network (SPN).The round function of most of those structures consists of three basic operations: the sbox look-up, the exclusiveor addition (Xor), and the branch swapping, where the only nonlinear component is the sbox look-up operation.In differential cryptanalysis, the Xor differences of plaintext/ciphertext pairs are considered; we omit the key and constant addition since they have no relevance to our analysis.We assume that a block cipher structure has  subblocks (branches), and the input and output differences are denoted by (Δ 1 , . . ., Δ  ) and (Δ 1 , . . ., Δ  ), respectively.

The Solvability of a Linear
System.Now we review the basics in linear algebra of determining the solvability of a system of linear equations.Let ,  be two positive integers,  < ; let  =  be a system of  linear equations with  variables, where  is  ×  matrix over F 2 ; and  = ( 1 , . . .,   ) and  = ( 1 , . . .,   ) are two bit vectors; then the augmented  × ( + 1) matrix  = [ | ] can determine the solvability of the linear system.
A regular method is to deduce the reduced row echelon form (a.k.a.row canonical form) of matrix  by Gauss-Jordan elimination algorithm.The reduced row echelon form of a matrix is unique and denoted by   .One starts to check   from the last row to the first, to see if there exists a row in which the first  entries are zeros and the last entry is nonzero.If there are such rows, then the linear system has no solution.
For example, if the augmented matrix  of a linear system in reduced row echelon form is where  3 is nonzero, then the linear system has no solution.Here we take the 5-round Feistel structure as an example.We first assign differential variables for 5-round Feistel structure.In Figure 1,   , 1 ≤  ≤ 5 are permutations; the output difference of   for input difference   is   ; thus   ∼   .According to the computation graph of 5-round Feistel structure, we obtain the following system S of equations and constraints:
(2) Assign differential variables according to the computation figure of the -round block cipher structure.
Generate the system S of linear equations and constraints with the differential variables.
(3) For each (Δin, Δout) ∈ D, solve the system S with initial value (Δin, Δout) and check if S has no solution.If there is no solution, then (Δin → Δout) is an impossible differential.After all cases are checked we obtain all impossible differentials.

The Detailed Algorithm
In this section we describe the detailed algorithm and implementation details.

Generate All
will not be zero since this will be trivial in differential cryptanalysis.Thus there are total (( + 1)  − 1) ⋅ ((2 + 1)  − 1) differential pairs.This value is large for many block cipher structures.
However, an impossible differential (Δ 1 , . . ., Δ  )   (Δ 1 , . . ., Δ  ) for a block cipher structure is usually simple; that is, there are very few nonzero values in (Δ 1 , . . ., Δ  ) and (Δ 1 , . . ., Δ  ).Since the input or output differential are complicate, it will propagate fast due to the round structure of the cipher.Thus it is reasonable to consider simple differential pairs.Actually all the impossible differentials found for block cipher structures in the literature are simple.

Generate the System S.
Given a block cipher structure, we first need to draw the computational figure and assign differential variables, as introduced in the analysis of 5round Feistel structure.This step is varying according to different block cipher structures.However, since most block cipher structures iterate the same round structure for several times, these variables are regular and easy to implement in a computer program.As in the analysis of 5-round Feistel structure, the input difference of a nonlinear permutation is denoted by variable   and the output difference is denoted by variable   .Thus if we see a variable   , it must be some output difference of a nonlinear permutation.
For a block cipher structure with  rounds, there are  variables   , 0 ≤  ≤ , and  numbers of variables   , 1 ≤  ≤ .The numbers  and  are determined by the round structure and the round number .For the -round Feistel structure,  =  + 2 and  = .We first denote all variables in a variable vector as  = ( 0 , . . .,  −1 ,  1 , . . .,   ) , and then linear equations in system S can be written as  = 0, where  is a  × ( + ) matrix over  2 and 0 is a ( + )dimensional zero vector, where  is the number of linear equations in one round of the block cipher structure.The augmented matrix of these linear equations is  = [ | 0].For the 5-round Feistel structure, the augmented matrix  is denoted in Table 1.
The set of constraints in S can be maintained as a map N. Let id(  ) denote the index of the variable   in vector ; given a constraint   ∼   , we add (id(  ), id(  )) into the map N.For the 5-round Feistel structure, N = {⟨1, 7⟩, ⟨2, 8⟩, ⟨3, 9⟩, ⟨4, 10⟩, ⟨5, 11⟩}.In the real implementation, it is noted that, for most block cipher structures, the distance between constraints   and   is fixed and determined by the round structure and the round number; that is, id(  ) − id(  ) is a constant.For example, the distance of constraints   and   for a -round Feistel structure is +1.Thus the map N is not needed to be implemented but only the fixed index distance is needed.This observation facilitates the real implementation of the algorithm.

Determine the Solvability of S.
In the beginning, we assign a symbol "?" to each variable in the variable vector , which means every variable is undetermined.Given a differential pair (Δin, Δout), we need to check if there exist solutions of the system S with the initial value (Δin, Δout).We first need to initialize the variable vector  according to (Δin, Δout).As in the 5-round Feistel structure, for a differential pair Δin = (, 0), Δout = (, 0), the variable vector  is initialized as follows:  We use ⊕ to denote the symmetrical difference (Xor) of  1 and  2 .For example, if The function UpdateMatrix(, ) updates the augmented matrix  according to the variable vector .If the th variable in  is 0, then the corresponding th column of  is set to a zero vector.As in [21], this method keeps solutions // Update the augmented matrix  according to the variable vector  (1)  ← the size of ; (2) for  ← 0 to  − 1 do Every element of the th column of  is set to 0. (6) else if  is not "?" and  is not " * " then (7)  ← the number of rows of ; (8) for  ← 0 to  − 1 do (9) if [, ] is 1 then (10)  of the augmented matrix  unchanged.If   is not in the set {0, ?, * }, we check each row of ; if the value of the th column at the th row  , is 1, then we set Xor  i to the last element of the th row of  and set  , to 0 (Algorithm 1).
The function UpdateVector(, N, , ) updates the th variable   with the value ; at the same time all constraints in N are maintained.As described in the beginning of this subsection, the function updates   with the value  by checking each constraint in N and returns true if it succeeds or false if there is a contradiction.There are many subcases, as described in the detailed algorithm.During the updating process, there may be contradictions.For example, if   = {} and  = {, } which means  =  ⊕ , there is a contradiction since  ⊕  can never be .If  is {0} but the corresponding variable which is the sbox output of   is nonzero or  is {0} but the corresponding variable which is the sbox input of   is nonzero, there will be contradictions (Algorithm 2).
The function ReducedRowEchelon() transforms the  ×  matrix  into the reduced row echelon form by Gauss-Elimination algorithm.Note that every element in the first − 1 columns of  is in F 2 , while elements in the last column of  are represented by a set of symbols.Thus the Xor operation in the last column of  is the symmetrical difference operation.The readers can refer to [32] for the detailed algorithm of transforming a matrix into the reduced row echelon form.
The detailed algorithm for checking if a differential is impossible is described in Algorithm 3. In Algorithm 3, the variable vector  is first initialized according to the differential pair (Δin, Δout) and the constraint array N. Then the algorithm continues checks if there is a contradiction with a loop test until  and  are not updated any more.During the loop the algorithm first updates  according to  by the UpdateMatrix(, ) function and then transforms  into the reduced row echelon form by the ReducedRowEchelon() function to see if  has solutions.If  has no solutions, the algorithm obtains a contradiction and stops.Otherwise if there exists a solution for a variable from the reduced row echelon form, the index and the value of the variable are denoted as (, ).The algorithm updates the variable vector  with (, ) by the UpdateVector(, N, , ) function; if the updating process returns false, a contradiction is obtained and the algorithm stops; otherwise, the algorithm continues to run.

Complexity.
For the  ×  matrix  and the  − 1 dimension vector , the time complexity of the function UpdateMatrix is  ⋅ , the time complexity of the function ReducedRowEchelon is  2 ⋅ , and the time complexity of the function UpdateVector is a constant , while loop continues running /2 times since there at most  − 1 values in  and in each loop either 2 variables are updated or there is a contradiction.Thus the total complexity of the algorithm is (/2) ⋅  2  2 , where  is a small constant.The space complexity is dominated by storing the matrix  and is about  ⋅ .The time complexity of the Wu-Wang method is  ⋅  2  2 and this  is much larger than our .The Wu-Wang method stores 3 matrices; thus its space complexity is at least triple our method.

Comparison with Previous Method.
In [31], Wu and Wang proved that the U-method and the UID method are specific cases of the Wu-Wang method.They found that their method can find longer impossible differential for the MIBS cipher than by U-method and the UID method.However, in the UID method, for an impossible differential pair ((Δ 1 , . . ., Δ  ), (Δ 1 , . . ., Δ  )), the relationship between input variables and output variables is considered since UID method uses symbols to denote values.For example, the UID method considers the relation between Δ  and Δ  and checks if they are equal; however the U-method and Wu-Wang method only use 0 and 1 to denote zero and nonzero // Update the variable vector  according to the variable (, ) where  is the value of the th variable in .N is the array of constraints.input: the variable vector , the constraint array N, (, ).output: A boolean flag indicates if the update procedure success.
Our improved method combines the advantages of the UID method and Wu-Wang method.Every impossible differential found by the UID method and Wu-Wang method can be found by our improved method.As Wu and Wang's method, impossible differentials found by our improved method must be correct if the algorithm is implemented correctly.Compared with Wu and Wang's method, our improved method is more complete.The symbol representation of a difference can represent more relationships between different difference values.Thus it can find more impossible differentials and the matrix  does not change with different values of (Δin, Δout) in the beginning of the algorithm, while, in the Wu-Wang method, to add linear relationships between nonzero values in (Δin, Δout), the matrix  must change with different values of (Δin, Δout).This will consume more time during the run of the algorithm.
The most time consuming part in the algorithm is the matrix operation.To check if the augmented matrix has any solutions, the Wu-Wang method needs to compute the rank of the matrices  and .We show that this step is not required since we can check the solvability of the system from the reduced row echelon form of the matrix , as introduced in the preliminaries section.Thus our improvement largely reduces the search time of finding impossible differentials of a block cipher structure.

Applications and Experiment Results
We implement the algorithm in java language and apply it to many block cipher structures, including Gen-CAST256 [33], Misty [25], Gen-Skipjack [23], Four-Cell [24], Gen-MARS [33], Gen-RC6 [33], SMS4 [34], MIBS [26], Camellia * [27,31], LBlock [28], E2 [29], and SNAKE [30].We present the java code of this algorithm and complete impossible differential results in GitHub [35].To reduce the space of this paper, we present some of the impossible differential results in Table 2.The file Impossible Differential.txt in [35] lists the complete impossible differential results for these block cipher structures.Most impossible differentials discovered by our algorithm are the same as the Wu-Wang method.
(i) The value   is updated: (a) If   = 0 and   = ?, then   is set to 0. (b) If   is a nonzero symbol and   = ?, then   is set to the nonzero symbol " * ."(c) If   = 0 and   is an nonzero symbol, then we obtain a contradiction.(ii) The value   is updated: (a) If   = 0 and   = ?, then   is set to 0. (b) If   = 0 and   is an nonzero symbol, then we obtain a contradiction.
Our improvement is based on Wu and Wang's method.If the nonlinear sbox   in a block cipher structure is a permutation, then there is a constraint on the input difference   and output difference   for   ; that is,   and   can only both be zero or both be nonzero, denoted by   ∼   .The intermediate value of a block cipher structure is called the state.The state is updated with the round structure.In order to find impossible differential for an -round block cipher structure, we first set differential variables for the states and then transform the - round block cipher structure into a system of linear equations and constraints, denoted by S. Then for a given differential (Δin, Δout), where Δin = ( 1 , . . .,   ) and Δout = ( 1 , . . .,   ), we can check if it is impossible by solving S with initial values ( 1 , . . .,   ,  1 , . . .,   ); if S has no solution, then Δin   Δout.

Table 2 :
(21)o 1 do(17) → V ← Row  of ;(18) if the sum of the first  − 1 elements of  → V is 1 then  ← the last element of  → V ; // the solution of the th variable in (21)/ * update the variable vector  with (, ) and return true if there is no contradiction and return false otherwise.Algorithm 3: The algorithm for checking an impossible differential.Summary of impossible differentials (IDs) of some well-known block ciphers structures found by different methods.