Differential and Linear Cryptanalysis Using Mixed-Integer Linear Programming
Differential and Linear Cryptanalysis Using Mixed-Integer Linear Programming
Abstract. Differential and linear cryptanalysis are two of the most pow-
erful techniques to analyze symmetric-key primitives. For modern ci-
phers, resistance against these attacks is therefore a mandatory design
criterion. In this paper, we propose a novel technique to prove security
bounds against both differential and linear cryptanalysis. We use mixed-
integer linear programming (MILP), a method that is frequently used in
business and economics to solve optimization problems. Our technique
significantly reduces the workload of designers and cryptanalysts, be-
cause it only involves writing out simple equations that are input into
an MILP solver. As very little programming is required, both the time
spent on cryptanalysis and the possibility of human errors are greatly
reduced. Our method is used to analyze Enocoro-128v2, a stream cipher
that consists of 96 rounds. We prove that 38 rounds are sufficient for secu-
rity against differential cryptanalysis, and 61 rounds for security against
linear cryptanalysis. We also illustrate our technique by calculating the
number of active S-boxes for AES.
Keywords: Differential cryptanalysis, Linear Cryptanalysis, Mixed-Integer
Linear Programming, MILP, Enocoro, AES, CPLEX
1 Introduction
Differential cryptanalysis [1] and linear cryptanalysis [22] have shown to be two
of the most important techniques in the analysis of symmetric-key cryptographic
primitives. For block ciphers, differential cryptanalysis analyzes how input differ-
ences in the plaintext lead to output differences in the ciphertext. Linear crypt-
analysis studies probabilistic linear relations between plaintext, ciphertext and
⋆
This work was supported in part by the Research Council K.U.Leuven: GOA
TENSE, the IAP Program P6/26 BCRYPT of the Belgian State (Belgian Science
Policy), and in part by the European Commission through the ICT program un-
der contract ICT-2007-216676 ECRYPT II, and is funded by the National Natural
Science Foundation of China (No. 61073150).
⋆⋆
This author is funded by a research grant of the Institute for the Promotion of
Innovation through Science and Technology in Flanders (IWT-Vlaanderen).
key. If a cipher behaves differently from a random cipher for differential or linear
cryptanalysis, this can be used to build a distinguisher or even a key-recovery
attack.
For stream ciphers, differential cryptanalysis can be used in the context of a
resynchronization attack [13]. In one possible setting, the same data is encrypted
several times with the same key, but using a different initial value (IV). This
is referred to as the standard (non-related-key) model, where the IV value is
assumed to be under control of the attacker. An even stronger attack model
is the related-key setting, where the same data is encrypted with different IVs
and different keys. Not only the IV values, but also the differences between the
keys are assumed to be under control of the attacker. Similar to differential
cryptanalysis, linear cryptanalysis can also be used to attack stream ciphers in
both the standard and related-key model. In the case of stream ciphers, linear
cryptanalysis amounts to a known-IV attack instead of a chosen-IV attack.
Resistance against linear and differential cryptanalysis is a standard design
criterion for new ciphers. For the block cipher AES [15], provable security against
linear and differential cryptanalysis follows from the wide trail design strat-
egy [14]. In this work, we apply a similar strategy. After proving a lower bound
on the number of active S-boxes for both differential and linear cryptanalysis,
we use the maximum differential probability (MDP) of the S-boxes to derive an
upper bound for the probability of the best characteristic. We assume (as is com-
monly done) that the probability of the differential can accurately be estimated
by the probability of the best characteristic. Several works focus on calculat-
ing the minimum number of active S-boxes for both Substitution-Permutation
Networks (SPNs) [14] and (Generalized) Feistel Structures (GFSs) [5, 6, 19, 27].
Unfortunately, it seems that a lot of time and effort in programming is required to
apply those techniques. This may explain why many related constructions have
not yet been thoroughly analyzed. In this paper, we introduce a novel technique
using mixed-integer linear programming in order to overcome these problems.
Linear programming (LP) is the study of optimizing (minimizing or maximiz-
ing) a linear objective function f (x1 , x2 , . . . , xn ), subject to linear inequalities
involving decision variables xi , 1 ≤ i ≤ n. For many such optimization problems,
it is necessary to restrict certain decision variables to integer values, i.e. for some
values of i, we require xi ∈ Z. Methods to formulate and solve such programs
are called mixed-integer linear programming (MILP). If all decision variables xi
must be integer, the term (pure) integer linear programming (ILP) is used. MILP
techniques have found many practical applications in the fields of economy and
business, but their application in cryptography has so far been limited. For a
good introductory level text on LP and (M)ILP, we refer to Schrage [26].
In [7], Borghoff et al. transformed the quadratic equations describing the
stream cipher Bivium into a MILP problem. The commercial solver package
CPLEX [17] was then used to solve the resulting MILP problem, which cor-
responds to recovering the internal state of Bivium. In the case of Bivium A,
solving this MILP problem takes less than 4.5 hours, which is faster than Rad-
dum’s approach (about a day) [25], but much slower than using MiniSAT (21
seconds) [9].
For the hash function SIMD, Bouillaguet et al. [8] used an ILP solver to find
a differential characteristic based on local collisions. Using the SYMPHONY
solver [10], they could not find the optimal solution, but found lower bounds for
both SIMD-256 and SIMD-512. The computation for SIMD-512 took one month
on a dual quad-core computer.
In [5, 6], Bogdanov calculated the minimum number of linearly and differ-
entially active S-boxes of unbalanced Feistel networks with contracting MDS
diffusion. He proved that some truncated difference weight distributions are im-
possible or equivalent to others. For the remaining truncated difference weight
distributions, he constructed an MILP program which he then solved using the
MAGMA [11] Computational Algebra System [4]. Compared to Bogdanov’s tech-
nique, the fully automated method in this paper is much simpler to apply: Bog-
danov’s approach requires a significant amount of manual work, and the con-
struction of not one but several ILP programs. We will show how this can be
avoided by introducing extra dummy variables into the MILP program.
We apply our technique to the stream cipher Enocoro-128v2 [29, 30], in or-
der to obtain bounds against differential and linear cryptanalysis. We consider
both the standard and related-key model. All MILP programs are solved us-
ing the IBM ILOG CPLEX Optimizer [17]. There are 96 initialization rounds in
Enocoro-128v2. We prove that 38 rounds are sufficient for security against differ-
ential cryptanalysis, and 61 rounds against linear cryptanalysis. These security
bounds are obtained after 52.68 and 228.94 seconds respectively. We also calcu-
late the minimum number of active S-boxes for up to 14 rounds of AES, which
takes at most 0.40 seconds for each optimization program. Our experiments are
performed on a 24-core Intel Xeon X5670 Processor, with 16 GB of RAM.
This paper is organized as follows. Sect. 2 explains how to find the minimum
number of active S-boxes for a cryptographic primitive by solving an MILP
program. A brief description of Enocoro-128v2 is given in Sect. 3. In Sect. 4
and Sect. 5, we construct an MILP program to prove that Enocoro-128v2 is
secure against differential cryptanalysis and linear cryptanalysis respectively.
We provide some ideas for future work in Sect. 6, and conclude the paper in
Sect. 7. In App. A, we calculate the minimum number of active S-boxes for AES
using our technique, and provide the full source code of our program.
We now explain a technique to easily prove the security of many ciphers against
differential and linear cryptanalysis. Our method is based on counting the mini-
mum number of active S-boxes. To illustrate our technique, we use Enocoro-128v2
and AES as test cases in this paper. The equations we describe are not specific
to these ciphers, but can easily be applied to any cipher constructed using S-
box operations, linear permutation layers, three-forked branches and/or XOR
operations.
We consider truncated differences, that is, every byte in our analysis can have
either a zero or a non-zero difference. More formally, we define the following
difference vector:
Equations Describing the XOR Operation. Let the input difference vector
for the XOR operation be (x⊕ ⊕
in1 , xin2 ) and the corresponding output difference
⊕
vector be xout . The differential branch number is defined as the minimum number
of input and output bytes that contain differences, excluding the case where there
are no differences in inputs nor outputs. For XOR, the differential branch number
is 2. In order to express this branch number in equations, we need to introduce a
new binary dummy variable d⊕ .4 If and only if all of the three variables x⊕ ⊕
in1 ,xin2
and x⊕ ⊕
out are zero, d is zero, otherwise it should be one. Therefore we obtain the
following linear equations (in binary variables) to describe the relation between
the input and output difference vectors:
x⊕ ⊕ ⊕
in1 + xin2 + xout ≥ 2d
⊕
,
d⊕ ≥ x⊕
in1 ,
d⊕ ≥ x⊕
in2 ,
d⊕ ≥ x⊕
out .
4
Note that this extra variable was not added in [5, 6], which is why Bogdanov had to
solve several ILP programs instead of only one.
the linear transformation L can be constrained by the following linear equa-
tions:
xL L L L L L
in1 + xin2 + · · · + xinM + xout1 + xout2 + · · · + xoutM ≥ BD d
L
,
dL ≥ xL
in1 ,
dL ≥ xL
in2 ,
······
dL ≥ xL
inM ,
dL ≥ xL
out1 ,
dL ≥ xL
out2 ,
······
dL ≥ xL
outM .
The duality between differential and linear cryptanalysis was already pointed
out by Matsui [23]. The equations describing a linear function are the same as
in the case for differential cryptanalysis, however the differential branch number
BD is replaced by the linear branch number BL . The linear branch number is
the minimum number of non-zero linear masks for the input and output of a
function, excluding the all-zero case. No extra equations are introduced for the
XOR operations, because the input and output linear masks are the same.
For a three-forked branch, we proceed as follows. Let the input linear mask
⊢
vector for the three-forked branch be yin , and the corresponding output lin-
ear mask vector be (yout1 , yout2 ). We introduce a binary dummy variable l⊢ to
⊢ ⊢
3 Description of Enocoro-128v2
The first Enocoro specification was given in [28]. Enocoro is a stream cipher,
inspired by the Panama construction [12]. Two versions of Enocoro were speci-
fied: Enocoro-80v1 with a key size of 80 bits, and Enocoro-128v1 with a key size
of 128 bits. Later, a new version for the 128-bit key size appeared in [18]. It is re-
ferred to as Enocoro-128v1.1. We now give a short description of Enocoro-128v2.
For more details, we refer to the design document [29, 30].
Update Function. The update function N ext uses functions ρ and λ to update
the internal state as follows:
(a(t+1) , b(t+1) ) = N ext(S (t) ) = (ρ(a(t) , b(t) ), λ(a(t) , b(t) )) .
(t+1) (t)
a0 = v0 ⊕ S[b16 ] ,
(t+1) (t)
a1 = v1 ⊕ S[b29 ] .
0 2 6 7 15 16 28 29 31 0 1
S
S
S
S
0 3 7 8 16 17 29 30 31 0 1
Fig. 1. State Update during the Initialization of Enocoro-128v2. Indices of buffer (on
the left) refer to b-variables, indices of the state (on the right) refer to a-variables.
Several results [16, 20, 21, 24, 30] on differential and linear cryptanalysis have
already been published for different versions of Enocoro. In this paper, we con-
sider the most recent version Enocoro-128v2 [29, 30] as an example to illustrate
our technique. Watanabe et al. already showed that at least 2177.8 chosen IVs
are required for a differential attack on Enocoro-128v2 [30]. For a linear attack,
Konosu et al. [21] showed that 2216 known IVs are required for an attack on the
64-round variant Enocoro-128v1.1. Although these results are already sufficient
to prove the security of Enocoro-128v2 against linear and differential cryptanal-
ysis, we explain in this paper how to prove the security against these attacks in
a much easier way.
Our technique is now used to find the minimum number of active S-boxes
for the stream cipher Enocoro-128v2. We will consider an idealized variant of
Enocoro-128v2, for which the minimum number of active S-boxes is a lower
bound for the real Enocoro-128v2. In this idealized variant of Enocoro-128v2,
the S-boxes can map any non-zero input difference to any non-zero output dif-
ference. The same holds for the L-function, with the restriction that the branch
number is 3.
For this idealized variant of Enocoro-128v2, we have written a program to
calculate the minimum number of active S-boxes. We present our problem as
a mixed-integer linear programming (MILP) problem, and use CPLEX [17] to
solve it. The solution corresponds to the minimum number of differentially active
S-boxes for Enocoro-128v2. It is used to prove the security of the cipher against
differential cryptanalysis, using a similar proof as for the block cipher AES [14,
15]. Note that an actual characteristic with the given number of active S-boxes
may or may not exist, depending on the specific S-box and L-function that is
used. This is not a concern for us, as our goal is to prove a security bound against
differential cryptanalysis.
and (x39 , x40 ) respectively. All binary xi -variables obtained for the first round
are illustrated in Fig. 3. Therefore, using this technique we can represent the
differential update of Enocoro-128v2 for any round with a system of linear equa-
tions.
x31 x32 x33 x35 x36
? ? ? ? ?
h x32 x2 - h x7 - h L
? ? ? ? ?
x34 x35 x36 x37 x38
? ? ? ? ?
x16 - h x29 - h x6
h h
x15 h
x28
? ? ? ? ?
x39 x40 x41 x42 x43
0 1 2 6 7 15 16 28 29 31 32 33
S
S
35 36
34 L
37 38
S
S
34 0 1 41 3 6 42 8 15 43 17 28 29 30 39 40
Fig. 3. Differential State Update during the Initialization of Enocoro-128v2. The in-
dices refer to x-variables.
We now focus on the variables that represent the S-box inputs in every round.
Note that x2 , x7 , x16 , and x29 correspond to the input differences of the S-
boxes, and therefore determine if the S-box is active or not. Let Di include the
four indices of variables that represent the four S-box inputs in the i-th round
(1 ≤ i ≤ 96). The 96 sets include the indices for variables that represent the four
S-box inputs in each round. They can easily be obtained from Sect. 4.1, and are
as follows:
then X
kN = xi
i∈IN
We will use our technique to analyze an ideal variant of Enocoro-128v2 for linear
cryptanalysis. Similarly as for differential cryptanalysis, the real Enocoro-128v2
will have at least as many linearly active S-boxes as the idealized one, and
therefore can be used to prove a security bound.
We now illustrate our technique by presenting the equations for the first round of
the stream cipher Enocoro-128v2 for linear cryptanalysis. For the initial state,
let the linear mask vector for the buffer be (y0 , y1 , . . . , y31 ), and for the state
be (y32 , y33 ). Consider the three-forked branch, which has the state byte a0
as the input linear mask and buffer byte b31 as one output linear mask. We
obtain the first new binary variable y34 as the other output vector. The input
and output linear mask vector for this three-forked branch are then y32 and
(y31 , y34 ) respectively. By introducing the binary dummy variable l0 , the four
Table 1. Minimum Number of Differentially Active S-boxes min(kN ) for N rounds of
Enocoro-128v2
For the XOR operation, the two inputs and the output all have the same
linear mask. The bijectiveness of the S-box implies the linear mask at the output
will be non-zero if and only if the input mask is non-zero. Therefore, the linear
transformation L has an input linear mask vector of (y34 , y33 ), and an output
linear mask vector of (y35 , y36 ). Using a new binary dummy variable l1 , the
equations describing the L transformation are:
Fig. 4. Linear Mask Vectors for Nine Operations in the First Round
0 2 6 7 8 14 15 16 17 27 28 29 31 32 33
31
34
S
S
34 33
L
35 36
S
S
31 0 1 37 3 5 38 39 8 14 40 41 17 27 42 43 30 35 36
Fig. 5. Linear Masks Vectors Update during the Initialization of Enocoro-128v2. The
indices refer to y-variables.
(y31 , y0 , y1 , y37 , y3 , · · · , y5 , y38 , y39 , y8 , · · · , y14 , y40 , y41 , y17 , · · · , y27 , y42 , y43 , y30 )
then X
mN = yj
j∈JN
6 Future Work
N 1 2 3 4 5 6 7 8 9 10 11 12 13 14
min(kN ) 1 5 9 25 26 30 34 50 51 55 59 75 76 80
#include <stdio.h>
int i,j,r;
const int ROUNDS = 4; /* number of rounds */
int next = 0; /* next unused state variable index */
int dummy = 0; /* next unused dummy variable index */
int main() {
int a[4][4]; /* the bytes of the AES state */
References
1. Biham, E., Shamir, A.: Differential Cryptanalysis of DES-like Cryptosystems. J.
Cryptology 4(1), 3–72 (1991)
2. Biryukov, A., Gong, G., Stinson, D.R. (eds.): Selected Areas in Cryptography -
17th International Workshop, SAC 2010, Waterloo, Ontario, Canada, August 12-
13, 2010, Revised Selected Papers, LNCS, vol. 6544. Springer (2011)
3. Biryukov, A., Nikolić, I.: Search for Related-key Differential Characteristics in
DES-like ciphers. In: Joux, A. (ed.) FSE. LNCS, vol. 6733, pp. 342–358. Springer
(2011)
4. Bodganov, A.: Personal Communication (2011)
5. Bogdanov, A.: Analysis and Design of Block Cipher Constructions. Ph.D. thesis,
Ruhr University Bochum (2009)
6. Bogdanov, A.: On unbalanced Feistel networks with contracting MDS diffusion.
Des. Codes Cryptography 59(1-3), 35–58 (2011)
7. Borghoff, J., Knudsen, L.R., Stolpe, M.: Bivium as a Mixed-Integer Linear Pro-
gramming Problem. In: Parker, M.G. (ed.) IMA Int. Conf. LNCS, vol. 5921, pp.
133–152. Springer (2009)
8. Bouillaguet, C., Fouque, P.A., Leurent, G.: Security Analysis of SIMD. In: Biryukov
et al. [2], pp. 351–368
9. Cameron McDonald, Chris Charnes, J.P.: An Algebraic Analysis of Trivium Ci-
phers based on the Boolean Satisfiability Problem. Cryptology ePrint Archive,
Report 2007/129 (2007), http://eprint.iacr.org/
10. COIN-OR: SYMPHONY. http://projects.coin-or.org/SYMPHONY
11. Computational Algebra Group, School of Mathematics and Statistics, University
of Sydney: Magma Computational Algebra System. http://magma.maths.usyd.
edu.au
12. Daemen, J., Clapp, C.S.K.: Fast Hashing and Stream Encryption with PANAMA.
In: Vaudenay, S. (ed.) FSE. LNCS, vol. 1372, pp. 60–74. Springer (1998)
13. Daemen, J., Govaerts, R., Vandewalle, J.: Resynchronization Weaknesses in Syn-
chronous Stream Ciphers. In: EUROCRYPT. pp. 159–167 (1993)
14. Daemen, J., Rijmen, V.: The Wide Trail Design Strategy. In: Honary, B. (ed.) IMA
Int. Conf. LNCS, vol. 2260, pp. 222–238. Springer (2001)
15. Daemen, J., Rijmen, V.: The Design of Rijndael: AES - The Advanced Encryption
Standard. Springer (2002)
16. Hell, M., Johansson, T.: Security Evaluation of Stream Cipher Enocoro-128v2.
CRYPTREC Technical Report (2010)
17. IBM: IBM ILOG CPLEX Optimizer. http://www.ibm.com/software/
integration/optimization/cplex-optimizer/
18. K. Muto, D.W., Kaneko, T.: Strength evaluation of Enocoro-128 against LDA and
its Improvement. In: Symposium on Cryptography and Information Security. pp.
4A1–1 (2008), (in Japanese)
19. Kanda, M.: Practical Security Evaluation against Differential and Linear Crypt-
analyses for Feistel Ciphers with SPN Round Function. In: Stinson, D.R., Tavares,
S.E. (eds.) Selected Areas in Cryptography. LNCS, vol. 2012, pp. 324–338. Springer
(2000)
20. Kazuto Okamoto, K.M., Kaneko, T.: Security evaluation of Pseudorandom Number
Generator Enocoro-80 against Differential/Linear Cryptanalysis (II). In: Sympo-
sium on Cryptography and Information Security. pp. 20–23 (2009), (in Japanese)
21. Konosu, K., Muto, K., Furuichi, H., Watanabe, D., Kaneko, T.: Security evaluation
of Enocoro-128 ver.1.1 against resynchronization attack. IEICE Technical Report,
ISEC2007-147 (2008), (in Japanese)
22. Matsui, M.: Linear Cryptoanalysis Method for DES Cipher. In: EUROCRYPT.
pp. 386–397 (1993)
23. Matsui, M.: On Correlation Between the Order of S-boxes and the Strength of
DES. In: EUROCRYPT. pp. 366–375 (1994)
24. Muto, K., Watanabe, D., Kaneko, T.: Security evaluation of Enocoro-80 against
linear resynchronization attack. Symposium on Cryptography and Information Se-
curity (2008), (in Japanese)
25. Raddum, H.: Cryptanalytic Results on Trivium. eSTREAM report 2006/039
(2006), http://www.ecrypt.eu.org/stream/triviump3.html
26. Schrage, L.: Optimization Modeling with LINGO. Lindo Systems (1999), availabe
on-line: http://www.lindo.com
27. Shibutani, K.: On the Diffusion of Generalized Feistel Structures Regarding Dif-
ferential and Linear Cryptanalysis. In: Biryukov et al. [2], pp. 211–228
28. Watanabe, D., Kaneko, T.: A construction of light weight Panama-like keystream
generator. In: IEICE Technical Report, ISEC2007-78 (2007), (in Japanese)
29. Watanabe, D., Okamoto, K., Kaneko, T.: A Hardware-Oriented Light Weight
Pseudo-Random Number Generator Enocoro-128v2. In: The Symposium on Cryp-
tography and Information Security. pp. 3D1–3 (2010), (in Japanese)
30. Watanabe, D., Owada, T., Okamoto, K., Igarashi, Y., Kaneko, T.: Update on
Enocoro Stream Cipher. In: ISITA. pp. 778–783. IEEE (2010)