Docsity

Linear and Differential Cryptanalysis-Computer Security-Lecture Handout, Exercises of Computer Security

Toggle sidebar
bg1
Contents
1 Introduction 3
2 Linear Cryptanalysis 3
2.1 Substitution permutation network . . . . . . . . . . . . . . . . . . . . 3
2.2 Overview of the attack . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 Finding a linear approximation . . . . . . . . . . . . . . . . . . . . . . 5
2.3.1 Linear Approximation for a single S-box . . . . . . . . . . . . 6
2.3.2 Linear Approximation for the complete cipher . . . . . . . . . 6
2.4 The actual attack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 Conclusion on Linear Cryptanalysis . . . . . . . . . . . . . . . . . . . 9
3 Differential Cryptanalysis 10
3.1 Difference Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2 Differential Characteristic . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 Key Bit Extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4 Linear Attack against DES 15
4.1 The Data Encryption Standard . . . . . . . . . . . . . . . . . . . . . . 15
4.2 Linear Approximations for DES . . . . . . . . . . . . . . . . . . . . . . 15
4.3 The attack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.3.1 The full 16 rounds DES . . . . . . . . . . . . . . . . . . . . . . . 16
5 Block cipher design to prevent these attacks 17
5.1 Good Diffusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.2 High Nonlinearity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.3 Linear Transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.4 Conclusions On SPN Design Principles . . . . . . . . . . . . . . . . . 20
6 Conclusion 21
2
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Linear and Differential Cryptanalysis-Computer Security-Lecture Handout and more Exercises Computer Security in PDF only on Docsity!

Contents

  • 1 Introduction
  • 2 Linear Cryptanalysis
    • 2.1 Substitution permutation network
    • 2.2 Overview of the attack
    • 2.3 Finding a linear approximation
      • 2.3.1 Linear Approximation for a single S-box
      • 2.3.2 Linear Approximation for the complete cipher
    • 2.4 The actual attack
    • 2.5 Conclusion on Linear Cryptanalysis
  • 3 Differential Cryptanalysis
    • 3.1 Difference Distributions
    • 3.2 Differential Characteristic
    • 3.3 Key Bit Extraction
  • 4 Linear Attack against DES
    • 4.1 The Data Encryption Standard
    • 4.2 Linear Approximations for DES
    • 4.3 The attack
      • 4.3.1 The full 16 rounds DES
  • 5 Block cipher design to prevent these attacks
    • 5.1 Good Diffusion
    • 5.2 High Nonlinearity
    • 5.3 Linear Transformation
    • 5.4 Conclusions On SPN Design Principles
  • 6 Conclusion

1 Introduction

The process of studying methods of encryption to obtain information from en- crypted data without knowing the secret key is called cryptanalysis. It is usually a deep analysis and attacking of an encryption method to find the secret key. In this report we are going to introduce two cryptanalysis techniques, namely Linear and Differential cryptanalysis. In the first section we describe linear crypt- analysis, with a small example Substitution Permutation Network (SPN), in section 3 we explain the differential cryptanalysis and the idea of extracting key bits of a SPN by looking at the differences between input and output pairs. In section 4 we explain how the linear cryptanalysis can be applied to the Data Encryption Standard (DES). First by a small 3 rounds DES and then the full 16 rounds DES. In section 5 we describe what can be done to prevent linear and differential crypt- analysis attacks and make the SPN resistant.

2 Linear Cryptanalysis

A linear cryptanalysis is a known plain text attack, against a block cipher. The attack was first described by Matsui in 1994 as an attack against DES [M93]. But linear cryptanalysis can be used against many other block ciphers, and must there- fore be considered when designing new block ciphers. In this section, we will describe the steps of the general linear cryptanalysis attack. But first we will introduce an SPN cipher which will be used as an example cipher.

2.1 Substitution permutation network

We will now describe the general substitution permutation network (SPN), and introduce an example SPN that will be used in this section and in section 3. A SPN is a block cipher that consist of a number of rounds, each containing a substitution and a permutation. The key will normally be expanded into round keys, that will be XOR’ed at the beginning of each round. Our small example SPN^1 takes as input 16 bits, and outputs 16 bits. The key is also 16 bits, but they are expanded into 5 round keys of 16 bits. In each round the 16 bits are XOR’ed with the round key, then they are split into four blocks of four bit and each block goes through a substitution box (S-box). At the end of each round, the 16 bits are permuted. In our case we use the same S-box for all blocks and all rounds. The permutation can be seen in figure 1, which shows all of the example cipher. Our concrete S-box can bee seen in figure 2.

2.2 Overview of the attack

A linear cryptanalysis can be split into two steps. First you have to find a linear approximation for the SPN you want to break. The idea is to find an approximation that only contains plaintext bits and input bits to the last round. After we have found an approximation, we are ready to make the actual attack. Notice that you don’t need any ciphertext or plaintext to do the first step. It is only an analysis of the SPN, and therefore independent of the key you want to find. This means that you only have to make the analysis once for a certain SPN. In the actual attack we try to find some of the bits of the last round key. The idea is to calculate the input bits to the last round, that are in our approximation. We

(^1) Borrowed from [H02]

X 1 X 2 X 3 X 4 Y 1 Y 2 Y 3 Y 4

Figure 2: Our example S-box. The Xi’s are input to the S-box and the Yi’s are output.

linear equation, that always is true, then the block cipher is not good, since non linearity is very important for an SPN. It is also clear that if the bits in the equation were all uniformly random then the probability that the equation would come true is 0.5. So what we are looking for, is an equation where the probability that it will be true is as far from 0.5 as possible.

2.3 Finding a linear approximation

In this subsection we will try to explain how to find a good linear approximation. To do so we have to introduce some notation.

Definition 2.1. If L is a random variable of the form X 1 ⊕ X 2 ⊕ ... ⊕ Xn with probability PL of being 0, then we define the bias of the random variable to be

εL = PL −

Where εL is the bias of L.

This means that if X is a uniformly random variable, then the bias of X is 0. The Piling-Up Lemma [M93], tell us that the bias of a random variable X 1 ⊕X 2 ⊕...⊕Xn, where the X i′ s are independent, is equal

2 n−^1

∏^ n

i=

εi

where εi is the bias of Xi. We will use this lemma, even though the Xi’s are not independent. This however turns out to be a good approximation in practice. Now we are ready to describe how to find a linear approximation. The only nonlinear part of our example block cipher is the S-box. This is also the case in most other SPN’s like DES. So the first thing to do, is to analyze the S-boxes of the cipher. In our example cipher we only have one S-box, while an analysis of DES would require an analysis of each of the eight different S-boxes.

2.3.1 Linear Approximation for a single S-box

We want to find a linear equations in the input and output bits of the S-box. In our case there are 8 variables, namely X 1 , ..., X 4 , Y 1 , ..., Y 4. We can then construct a Linear Approximation Table with the bias of all possible combinations of the variables. In our case there will be 28 = 256 entries in the table. We will write this table as a 16 × 16 table with the 16 combinations of input as rows and the 16 combinations of output as columns. We will represent the input combination X 1 ⊕X 3 as the binary number 1010 , and write it as a decimal: 10. We will represent the outputs in the same way. The table can be seen in figure 3. The bias values are represented as integers that should be divided by 16 to get the actual bias.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 -2 -2 0 0 -2 6 2 2 0 0 2 2 0 0 2 0 0 -2 -2 0 0 -2 -2 0 0 2 2 0 0 -6 2 3 0 0 0 0 0 0 0 0 2 -6 -2 -2 2 2 -2 - 4 0 2 0 -2 -2 -4 -2 0 0 -2 0 2 2 -4 2 0 5 0 -2 -2 0 -2 0 4 2 -2 0 -4 2 0 -2 -2 0 6 0 2 -2 4 2 0 0 2 0 -2 2 4 -2 0 0 - 7 0 -2 0 2 2 -4 2 0 -2 0 2 0 4 2 0 2 8 0 0 0 0 0 0 0 0 -2 2 2 -2 2 -2 -2 - 9 0 0 -2 -2 0 0 -2 -2 -4 0 -2 2 0 4 2 - 10 0 4 -2 2 -4 0 2 -2 2 2 0 0 2 2 0 0 11 0 4 0 -4 4 0 4 0 0 0 0 0 0 0 0 0 12 0 -2 4 -2 -2 0 2 0 2 0 2 4 0 2 0 - 13 0 2 2 0 -2 4 0 2 -4 -2 2 0 2 0 0 2 14 0 2 2 0 -2 -4 0 2 -2 0 0 -2 -4 2 -2 0 15 0 -2 -4 -2 -2 0 2 0 0 -2 4 -2 -2 0 2 0

Figure 3: Linear Approximation table. The rows are S-box input and the columns are output.

When we have made the Linear Approximation tables for all S-boxes used in the cipher, we are ready to find the linear approximation for the whole cipher.

2.3.2 Linear Approximation for the complete cipher

I will start this subsection by introducing some notation^2 : Xi The i’th input bit to the S-box. Yi The i’th output of the S-box. Pi The i’th bit of the plaintext. Ci The i’th bit of the ciphertext. U (^) ij The i’th bit of the input to the S-boxes in the j’th round. V (^) ij The i’th bit of the output of the S-boxes in the j’th round. Kij The i’th bit of key in the j’th round. A[a 1 , a 2 , ..., an] The XOR between bit a 1 − an, like U 3 [1, 5 , 8] = U 13 ⊕ U 53 ⊕ U 83.

To get an overview of how we construct the linear approximation, see figure 4. The first thing to do is to find a good linear approximation for an S-box in the first round. We choose S-box S 12 (see Figure 1), and the equation X[1, 3 , 4] ⊕ Y 2 = 0, since the corresponding entry (11,4) in the Linear Approximation table has a high

(^2) The notation is borrowed from [M93]

Figure 4: A path through our example SPN.

We don not know the key bits, but we know they are fixed, meaning that the XOR ΣK is equal to 0 or 1. Therefore the bias of the random variable

P [5, 7 , 8] ⊕ U 4 [6, 8 , 14 , 16]

will be either − 321 or 321. In other words we could say that the equation

P [5, 7 , 8] ⊕ U 4 [6, 8 , 14 , 16] = 0

will be true with probability 1532 or 1732. So now we have found a linear approxima- tion, and we shall see how to use that in the next subsection.

2.4 The actual attack

Now that we have found a Linear Approximation, we are ready to do the actual attack. We have to invert the last round to check if the equation is true or false. In our case we have to XOR the cipher text bits with the last round key, and then send the bits through the inverted S-box. Then we can check if the equation

P [5, 7 , 8] ⊕ U 4 [6, 8 , 14 , 16] = 0

holds true or not. Notice that to check the equation we only need the bits U 64 , U 84 , U 144 , U 164 , but to get them we need all the bits V 54 , ... , V 84 and V 134 , ... , V 164 because of the S-box. But that is also fine, since we only needs 8 keys bits from the last round key to find those. This means that we should only test 28 = 256 possible keys instead of 216 = 65536, which is a huge difference. This also means that we can just do exhaustive search. Let K< 1 > and K< 2 > be two 4 bit key blocks, and let C< 5 − 8 > and C< 13 − 16 > be the cipher text bits from 5 to 8 and from 13 to 16 of the ciphertext C. Let S−^1 be the inverted S-box and let Γ be the set of all ciphertext/plaintext pairs we have. The algorithm for the attack will then be:

T[16][16] ← 0 for all K< 1 >, K< 2 > do for all plain text / cipher text pairs (P, C) ∈ Γ do V< 5 − 8 > ← C< 5 − 8 > ⊕ K< 1 > V< 13 − 16 > ← C< 13 − 16 > ⊕ K< 2 > U< 5 − 8 > ← S−^1 (V< 5 − 8 >) U< 13 − 16 > ← S−^1 (V< 13 − 16 >) if U 4 , 6 ⊕ U 4 , 8 ⊕ U 4 , 14 ⊕ U 4 , 16 ⊕ P 5 ⊕ P 7 ⊕ P 8 = 0 then T[K< 1 >][K< 2 >] ← T[K< 1 >][K< 2 >] + 1 end if end for end for max ← 0 for all K< 1 >, K< 2 > do if |size of(Γ)/2 - T[K< 1 >][K< 2 >]| > max then max ← |size of(Γ)/2 - T[K< 1 >][K< 2 >]| result ← K< 1 > || K< 2 > end if end for return result

In other words, check for what key bits, the number of times the equation holds, is most far from half the times. Those key bits should be the right ones. So now we have hopefully found 8 bits of the last round key.

2.5 Conclusion on Linear Cryptanalysis

One might say that 8 bits of the last round key is not very useful. But if we got half of the bits, we can easily find the rest by exhaustive key search. If we got all of the last round key, we might have all of the key, depending on how the key expanding is done. In all cases there will be only few keys with the same last round key, and therefore we would be able to find it. Another question is how many plaintext/ciphertext pairs do we need to make this attack? In [S06] the author claims that we would need about 8000 pairs to make the attack on our example cipher. For a full 16-rounds DES one would need

X′^ = 0000 then Y ′^ = 1110, thus

X′′^ = ∆X ⊕ X′^ = 1011 ⊕ 0000 = 1011

then Y ′′^ = 1100 and ∆Y = 0010 comes from figure 6.

X’ Y’ ∆Y when ∆X = 1011 ∆Y when ∆X = 1000 ∆Y when ∆X = 0100 0000 1110 0010 1101 1100 0001 0100 0010 1110 1011 0010 1101 0111 0101 0110 0011 0001 0010 1011 1001 0100 0010 0101 0111 1100 0101 1111 1111 0110 1011 0110 1011 0010 1011 0110 0111 1000 1101 1111 1001 1000 0011 0010 1101 0110 1001 1010 0111 1110 0011 1010 0110 0010 0101 0110 1011 1100 0010 1011 1011 1100 0101 1101 0111 0110 1101 1001 0010 0110 0011 1110 0000 1111 1011 0110 1111 0111 0101 1111 1011

Figure 6: Sample difference pairs of the S-box.

From figure 6 we can see that the number of occurrence of ∆Y = 0010 given ∆X = 1011 is 8 out of 16. In the same way we can compute the probability of the other differentials, that is the number of occurrence of a differential pair (∆X, ∆Y ) divided by 16, see figure 7. Each element in the table of figure 7 presents the num- ber of occurrence of an output difference ∆Y given an input difference ∆X^4. Before we can describe the attack we have to discuss the influence of the key on the S-box differential (considering figure 5). The input to a S-box is represented by X, the output by Y , and let W = [W 1 W 2 W 3 W 4 ] denote the input to round keys, where by input the round key Wi we mean the output from the previous round before being XOR ’ed with the round key, Wi see figure 2. So the input difference to a round key is

∆W = [W 1 ′ ⊕ W 1 ′′ W 2 ′ ⊕ W 2 ′′ W 3 ′ ⊕ W 3 ′′ W 4 ′ ⊕ W 4 ′′ ]

where W ′^ = [W 1 ′W 2 ′W 3 ′W 4 ′] and W ′′^ = [W 1 ′′ W 2 ′′ W 3 ′′ W 4 ′′ ]. Lets now take a look at input difference to the round keys, since the key is the same for both inputs we have

∆Wi = W (^) i′ ⊕ W (^) i′′ = (X i′ ⊕ Ki) ⊕ (X i′′ ⊕ Ki) = X i′ ⊕ X i′′ = ∆Xi

since Ki ⊕ Ki = 0. Thus the input difference of the input to the round key is the same as input difference to the S-box, this is to say that the key bits do not have any influence on the input difference.

(^4) It is worth to mention that the S-box could be ideal if the probability distribution for occurring a particular ∆Y given ∆X was 161 , however it can be proved that this is not possible [H02].

Figure 7: Difference distribution.

3.2 Differential Characteristic

After handling the differential data for S-boxes in an SPN, we have enough infor- mation to find useful differential characteristic of the overall cipher. The idea is to attack the cipher by finding a subset key bits following the last round. This is done by constructing a differential characteristic of certain S-box difference pairs in each round, such that a differential involves plaintext bits and input data to the last round of S-boxes.

Consider the SPN illustrated in figure 8. In this diagram the active S-boxes S 12 , S 23 , S 32 , and S 33 have non-zero differentials. This forms a characteristic for the first three rounds of the cipher. The difference pairs of the active S-boxes are

S 12 : ∆X = 11 ≡ 1011 → ∆Y = 2 ≡ 0010 with probability

S 23 : ∆X = 4 ≡ 0100 → ∆Y = 6 ≡ 0110 with probability

S 32 : ∆X = 2 ≡ 0010 → ∆Y = 5 ≡ 0101 with probability

S 33 : ∆X = 2 ≡ 0010 → ∆Y = 5 ≡ 0101 with probability

which can be verified from the table of figure 7. The other S-boxes have input difference zero. In the following we use Ui to denote the input to the i’th round S-box and Vi to denote the output of the i’th round S-box. The input difference to the first round is given by ∆U 1 = [0000 1011 0000 0000]

and the corresponding output difference is

∆V 1 = [0000 0010 0000 0000]

with probability 166. In the same way the output of the third round is

∆V 3 = [0000 0101 0101 0000]

and the corresponding input to round four is

∆U 4 = [0000 0110 0000 0110]

In other words

∆U 1 = [0000 1011 0000 0000] −→ ∆V 3 = [0000 0101 0101 0000]

and ∆V 3 = [0000 0101 0101 0000] −→ ∆U 4 = [0000 0110 0000 0110]

Hence it follow that

∆U 1 = [0000 1011 0000 0000] −→ ∆U 4 = [0000 0110 0000 0110]

The distribution of differentials illustrated in figure 7 can interpret as independent conditional probabilities (which mathematically is not true, but we assume that even so because practically it works)

P r[∆Y |∆X] = (∆X, ∆Y )

considering this and the computation above, differentials can be combined. For example in this case we have

which means that with probability 102427 the differential characteristic will occur. Now we are ready to give the idea of how to extract the key bits.

3.3 Key Bit Extraction

Now after having discussed the differential characteristic of rounds it is time to attack the cipher and obtain key bits. In a cipher of N rounds the idea is to attack the N − 1 ’th round cipher. In the example of SPN network it is possible to extract bits from subkey K 5 by attacking the fourth round key. The attack involves pair vise decryption of the last round cipher and testing the corresponding input to find out that the right/good pair is occurred, where meaning by good/right pairs is the pairs that result in none zero input differential to the expected S-boxes i.e. the pairs for which the differential characteristics holds. Lets look at the decryption of the last round, it involves the XOR of the cipher with the subkey, which is influenced by the non-zero differentials, and running data backward through the S-boxes, where all possible values of the subkey should be tried. Put in a different way we XOR the output cipher with every possible candidate subkey and apply the inverse S-boxes. The exhaustive search for finding key bits can be limited by just taking the good pairs. For example in the example of SPN a good pair has

U 41 = U 43 = 0000

and feeds U 42 and U 44 by non zero input differential, where Uij is input to the j’th S-box in the i’th round. A decryption is done for all pairs of ciphertexts corresponding to the pairs of palintexts used to generate the input difference (∆P in the example of figure 8).

Moreover a counter is maintained for every subkey (which are those key bits that are influenced by a non-zero differences in the differentials), the counters are incre- mented when the input to the last round corresponds to the expected value from differential characteristic. At the end of the procedure the subkey which has the greatest value is considered to be the correct subkey, then we do an exhaustive search to find the rest of the key bits. In example of figure 8 the differential char- acteristic has influence on S-boxes S 42 and S 44 of the last round, therefor for each pair of ciphertexts we try all 256 possibilities for [K 5 , 5 ...K 5 , 8 , K 5 , 13 ...K 5 , 16 ], and whenever the input difference to the final round determined by the decryption is ∆U 4 = [0000 0110 0000 0110] then the counter is incremented.

4 Linear Attack against DES

In this section we will present an Linear attack on DES as described in [M94]. Be- fore we do that we will give a brief description of DES.

4.1 The Data Encryption Standard

DES has been one of the most used block ciphers since 1976, but is now considered insecure, because of the small key size (56 bits). DES is a so called Feistel cipher, and consist of 16 rounds with a round 48 bits key for each round. The F function of is the same in all rounds and contains eight different S-boxes. Each S-box has six input bits and four output bits, which implies that the S-boxes are not invert- ible. But because of the structure of the Feistel cipher, invertible S-boxes are not necessary as we shall see.

4.2 Linear Approximations for DES

The best Linear Approximation for any DES S-box, is X 2 ⊕ Y 1 ⊕ Y 2 ⊕ Y 3 ⊕ Y 4 = 0 for S-box number five. This equation has probability 1264. If one analyzes the linear parts of the F function, one finds that the equation implies that

X 15 ⊕ F (X, K) 7 ⊕ F (X, K) 18 ⊕ F (X, K) 24 ⊕ F (X, K) 29 ⊕ K 22 = 0 (6)

have the same probability. We will use this equation to describe an attack against a 3 rounds DES cipher. To attack the full 16 rounds DES cipher, one should use all of the following Linear Approximations:

X 15 ⊕ F (X, K) 7 ⊕ F (X, K) 18 ⊕ F (X, K) 24 ⊕ F (X, K) 29 ⊕ K 22 = 0

X 27 ⊕ X 28 ⊕ X 30 ⊕ X 31 ⊕ F (X, K) 15 ⊕ K 42 ⊕ K 43 ⊕ K 45 ⊕ K 46 = 0 X 29 ⊕ F (X, K) 15 ⊕ K 44 = 0 X 15 ⊕ F (X, K) 7 ⊕ F (X, K) 18 ⊕ F (X, K) 24 ⊕ K 22 = 0 X 12 ⊕ X 16 ⊕ F (X, K) 7 ⊕ F (X, K) 18 ⊕ F (X, K) 24 ⊕ K 19 ⊕ K 23 = 0

4.3 The attack

First we will describe an attack on the 3 rounds DES cipher (see figure 9). We will use equation (6) to do so. The equation and the figure tells us that

P.L 15 ⊕(P.H 7 ⊕X 27 )⊕(P.H 18 ⊕X 218 )⊕(P.H 24 ⊕X 224 )⊕(P.H 29 ⊕X 229 )⊕K 221 = 0

reduced to 15 rounds we get the following linear approximation:

P.H[7, 18 , 24] ⊕ P.L[12, 16] ⊕ C.H^15 [7, 18 , 24 , 29] ⊕ C.L^1515 ⊕ Σkey = 0 (7)

Where C.L^15 and C.H^15 are the right and left sides of the ciphertext achieved from this reduced DES respectively. Σkey is the XOR of several round key bits from dif- ferent rounds, but as explained above we will however not care very much about these bits since they are fixed and thus their XOR is also fixed. [? ] states that this is the best approximation of 15 rounds of DES and that it has bias 1. 19 −^22. We can then extend the reduced DES to a full 16 DES cipher by adding one more round. Now since the 15’th round will no longer be the last round this will swap the positions of C.L^15 and C.H^15. Let us write C.H^15 = X.L^15 and C.L^15 = X.H^15. We then get the following approximation from (7):

P.H[7, 18 , 24] ⊕ P.L[12, 16] ⊕ X.L^15 [7, 18 , 24 , 29] ⊕ X.H 1515 = 0 (8)

Notice that we have now omitted Σkey as argued above. (8) is then the approx- imation we would like to check by inverting the last round of the 16 DES cipher. Now let C.L and C.H be the right and left part of the ciphertext obtained from 16 round DES. We can then decipher the ciphertext of 16 round DES by one round to get the input to the 16’th round X.L^15 and X.H^15. By simple definition of DES we have that: X.L^15 = C.L

and X.H^15 = C.H ⊕ F (X.L^15 , K^16 ) = C.H ⊕ F (C.L, K^16 )

So applying this to (8), we can check if the approximation holds for a given key K^16 by checking if the following holds:

P.H[7, 18 , 24] ⊕ P.L[12, 16] ⊕ C.L[7, 18 , 24 , 29] ⊕ C.H 1515 ⊕ F (C.L, K^16 ) 15 = 0

The only part of this equation that is not given in the plaintext/ciphertext pair is then the bit F (C.L, K^16 ) 15. This bit however is only affected by a single S-box of F so only 6 bits of K^16 is needed to check if the equation holds (since S-boxes take 6bit inputs). We can now obtain the correct 6 key bits as described above. The remaining key bits can then be obtained by exhaustive search. In [M94] Matsui uses the round symmetry of DES to create an other linear ap- proximation corresponding to (7) with the same bias. By also using this approx- imation, we can obtain further 6 key bits. So a total of 12 key bits can be found in this way. Matsui uses a slightly different algorithm from the one we have pre- sented. This also obtains the bit Σkey for each approximation, and this way one could obtain as much as 14 key bits. In [? ] Matsui improved this algorithm by instead using a approximation of 14 round approximation of DES. This way he obtained 26 key bits. Matsui estimates that the original attack needs 247 plaintext/chipertext pairs in order to be successful with high probability and the improved attack needs only 243 pairs. However [J01] shows experimental results that suggest that only 241 pairs are really needed for the improved version of the attack.

5 Block cipher design to prevent these attacks

The obvious question is now; what can we do to make our SPN resistant against linear and differential cryptanalysis. [HT94] describes three design principles to make an SPN stronger against linear and differential attacks. Two of the points focus on S-box design, the last point adds a linear transformation between S-boxes besides the permutation.

5.1 Good Diffusion

Let pR− 1 be the probability of a high probability differential characteristic, as de- fined in section 3.2, for round R − 1 in a SP N. The number of plaintexts needed for a differential analysis attack to be successful with high probability can then be approximated to be at least ND = (^) pR^1 − 1. In this subsection we describe a principle to decrease the probability of all characteristics for an SPN, and thus increasing ND. In order to be resistant to differential analysis, S-boxes of the SPN should have good diffusion properties. That is given inputs that has small differences the cor- responding outputs of an S-box should have large differences. For example if two inputs to an S-box only differ on one bit, say 1000 and 1001 for our example SPN in the above sections, we want the corresponding outputs to be different on at least two bits. This motivates the following definition of the diffusion order of an S-box, which is a lower bound on the output difference for small difference input. Here hw is the hamming weight, which is the number of 1’s in a bit string. Notice that hw(∆X) is exactly the number of bits that are different from X′^ in X′′^ when X′^ ⊕ X′′^ = ∆X.

Definition 5.1 (Diffusion Order). An S-box satisfies diffusion order λ > 0 if, for hw(∆X > 0 ),

hw(∆Y) >

λ + 1 − hw(∆X), hw(X) < λ + 1 0 , otherwise

DES S-boxes satisfies a diffusion order of one. That is for inputs to a DES S-box that are only different on one bit the outputs will be different on at least two bits. Active S-boxes are the S-boxes that are involved in a characteristic. Having many active S-boxes in a characteristic decreases the probability of the characteris- tic occurring. Combining S-boxes that satisfy high diffusion orders, with a permu- tation so that no two outputs of a round r S-box are connected to the same round r + 1 S-box, we get an SPN where characteristics have relatively large amounts of active S-boxes. Intutively this is because the high diffusion order garranties that either the inputs to an active S-box, Sa, are different on many bits or the output is. The permutation then tells us that if in the former case, there were many active S-boxes in the round before Sa, and in the latter case that there will be many active S-boxes in the round after Sa. From [HT94] we have the following upper bound, on the probability of charac- teristics in such an SPN:

Theorem 5.1. Given an SPN with R rounds such that R is a multiple of 4, using a permutation as described above, and S-boxes satisfying diffusion order λ. The probability pR− 1 of a ( R − 1 )-round characteristic is bounded in the following way:

pR− 1 6 p

λ+ 2 R−(λ+1)

Where p is the best probability of input/output XOR’s over an S-box.

This means that the higher diffusion order S-boxes of the SPN satisfy the lower is the probability that any characteristic holds. So to make an SPN resistant to differential analysis we just need to make sure the S-boxes have high diffusion order. However such S-boxes are very rare. As- sume that one XOR pair, (∆X, ∆Y), for an S-box violating diffusion order 1 is independent of other XOR pairs violating the same diffusion order. [HT94] shows that under this assumption, the probability of randomly choosing an n×n bijective

5.3 Linear Transformation

In order to achieve diffusion properties we already use a linear transformation between rounds of S-boxes, namely the permutations of each round. In this sub- section we describe a new kind of linear transformation that can be used between rounds to achieve better resistance against both differential and linear cryptanaly- sis. We consider a SPN with an even number N of S-boxes in each round. Let U = (U< 1 >, U< 2 >,... , U) be the output of some round of S-boxes, where U is the output of the i’th S-box. We then define L to be the linear transformation so that L(U ) = (L 1 (U ), L 2 (U ),... , LN (U ))

where

Li(U ) = (⊕Nj=1U) ⊕ U = U< 1 > ⊕ U< 2 > ⊕.. .⊕ U<i− 1 > ⊕ U<i+1> ⊕.. .⊕ U

That is Li(U ) is the XOR of all U’s so that j 6 = i. Since we assume N to be even L(U ) can be inverted by, for each Li(U ), XOR’ing all Lj (U )’s so that j 6 i, that is L is its own inverse. If we assume P is the permutation function of the SPN, we can now modify the SPN using L, by making the input to the next round P (L(U )), instead of just P (U ). Using an SPN modified with such a linear transformation gives us the following bounds on the effectiveness of differential and linear cryptanalysis respectively:

Theorem 5.2. Let an SPN be given as in theorem 5.1, modified with the linear transfor- mation, L , as described above. If each n × n S-box of the SPN has n > 3 , and satisfies diffusion order λ 6 n− 2 1 , the bound of theorem 5.1, still holds and for λ = 0 we have that:

pR− 1 6 p

(^32) R− 2

This means that although we do not have any improvements over the result in subsection 5.1 for λ > 0 , for λ = 0 we have as good a bound as we had for λ = 1 in subsection 5.1.

Theorem 5.3. Let an SPN be given of an even number of rounds, R , and M n×n S-boxes, in each round, such that M > n_. For such an SPN, modified by a linear transformation as described above, we have that the bias of the best possible_ R− 1 round linear approximation, γ , satisfies: |γ| 6 2 (^32) (R−1) |ε| (^32) R

Where ε is the bias of the best linear approximation of any single S-box in the SPN.

In 5.2, we said that it could be shown that |γ| 6 2 R−^1 |ε|R, that however was based on the assumption that the best linear approximation could be one that in- volved only one S-box in each round. This tighter bound is due to the fact that modifying the SPN with the linear transformation, makes sure that at least three S-boxes must be involved for any two consecutive rounds in a linear approxima- tion.

5.4 Conclusions On SPN Design Principles

Using these principles we can get very good bounds on the expected effectiveness of attacks based on differential and linear cryptanalysis. One should notice that the principles are not exclusive, and all of them could and should be used to give an SPN resistance against both forms of attack.

The table 10 borrowed from [HT94] shows estimates on the number of known and chosen plain texts that is expected to be needed for successful attacks using linear or differential cryptanalysis respectively, for different variations and com- binations of the principles. The estimates are for an eight round SPN with 64bit blocks and a 64bit key. The SPN uses 8 × 8 bijective S-boxes with a minimum nonlinearity 96, and the probability of the best differential over any S-box is 2 −^4. N (^) Dmin is the estimated expected minimum of chosen plaintexts needed for a dif- ferential cryptanalysis attack, and N (^) Lmin is the estimated expected minimum of plaintext/chipertext pairs needed for a linear cryptanalysis attack.

TYPE λ N (^) Dmin N (^) Lmin 0 228 Permutation π(·) 1 240 234 2 252 0 240 Linear Transform π(L(·)) 1 240 250 2 252

Figure 10: Resitance of different SPN’s

6 Conclusion

In this report we have presented and discussed two famous cryptanalysis meth- ods, namely Linear and Differential cryptanalysis. Due to the extensive theory, we have decided to concentrate on the Linear Cryptanalysis, describing some details of the theory and explaining how it can be applied to the DES cipher. The theory of Differential Cryptanalysis has been described briefly for more information about how to determine better differential characteristics we refer to [M95]. The two attacks both have some very hard preconditions, in form of big amounts of chosen or known plaintext data. Yet one must consider these attacks when de- signing new block ciphers. Therefore one should always keep principles, such as the ones described in our last section, in mind when designing ciphers.