• Round Function
  • Diffusion Layer (permutation)
  • Confusion Layer (substitution)
  • Attacks
    • Linear Cryptanalysis
    • Differential Cryptanalysis
  • Exercises
flowchart LR

A[PLAINTEXT]
B[ADD ROUND KEY]
C[ADD CONFUSION]
D[ADD DIFFUSION]
E[ADD CONFUSION]
F[ADD ROUND KEY]
G[CIPHERTEXT]

A --> B --> C --> D --> E --> F --> G
D --> B

consider the example SPN cipher that takes 16 bit input block and has 4 rounds

Round Function

  • to incorporate secret key
  • key mixing

simple XOR between round key bits and data block input

let us assume round keys are independently generated and unrelated

Confusion

  • relation between key and ciphertext is obscured
  • eg. substitution

break into 4 bit s-boxes

inputoutput
0E
14
2D
31
42
5F
6B
78
83
9A
A6
BC
C5
D9
E0
F7

The attacks of linear and differntial cryptanalysis apply equally whether one s-box or multiple

Diffusion

  • is an encryption operation where the influence of one plaintext symbol is spread over many ciphertext symbols with the goal of hiding statistical properties of the plaintext.
  • eg. bit permutation, mix column
inputoutput
11
25
39
413
52
66
710
814
93
107
1111
1215
134
148
1512
1616

Attacks

attacks on symmetric key block ciphers1

Linear Cryptanalysis

known-plaintext-attack

  1. Create LATs for all S-boxes
  2. Create LAT for overall cipher by concatenating
  3. Extract Final subkey bits

Overview

  • seeks to approximate bits of the cipher through linear equations2
  • linearity refers to XOR opeations
  • the probability of the approximation should be bounded away from to be called a “good” approximation3
  • to get these good approximations we inspect the only non-linear component: the S-Box

Piling-Up Principle

notice

  • (linear relation)
  • (affine relation)

let

gives

can be extended to give

CAUTION

the random variables must be independent

Cipher Components

linear vulnerabilities of the s-box

consider

analysing our s-box above we can see that over all 16 possible inputs for X for exactly 12/16 cases the expression above holds true i.e.

we may use this to create a Linear Approximation Table

where each number represents a linear combination of input/output variables

Linear Approximation Table

we created the LAT for one S-box above, to continue with the entire cipher we concatenate appropriate linear approximations of S-boxes

Consider the concatenation along this path

we will be using the following approximations of the S-box

we cannot simply concatenate shit without acknowledging the key xors between rounds

consider input to s-box as and output as with the subkey as

  1. with bias
  2. with bias
  3. with bias
  4. with bias

we can now concatenate all of these as

CAUTION

we are proceeding under the impression that all s-box substitutions are independent (may not be true but close enough)

we can rephrase our concatenation as and so on to expand into

  1. All the ‘s from the first layer appear
  2. All the ‘s from the last layer appear
  3. All the intermediary ‘s appear

in our final expression

we can do some expansion to get rid of the ‘s using and so on to get

Where is a deterministic constant depending on the master key and can be ignored

Extracting Key Bits

The idea is

  1. You have known plaintext-ciphertext pairs
  2. Your last round sends the output only to certain last round S-Boxes.
  3. You can bruteforce the subkey bits after those boxes () and compare the final output with your known ciphertext
  4. For every tried subkey you keep track of how many plaintext/ciphertext pairs it gave a correct result of (final output matched ciphertext bits)
  5. ideally the subkey with the most matches is the correct guess

Complexity

  • Number of known pairs required:

Differential Cryptanalysis

  • Chosen Plaintext Attack (CPA)
  • stems from the analysis of the XOR of two plaintexts as they travel through the cipher4
  • XOR tells us where the two plaintexts differ

Overview

  • seeks to exploit scenario where particular occurs given a particular input difference with very high probability
  • is called a differential
  • subkey bits end up disappearing since they appear in both inputs
  • the initial goal is to find high probability differential pair

Cipher Components

  • to analyse a S-box you need to check over all possible pairs and that xor to give some . (only ends up being 16 since is determined based on which is constant)
  • for each pair derive the value of
  • You will notice many repeated values in the list of found

Sample difference pairs of S-box: for

000010110010
000110100010
001010010111
001110000010
010011110101
010111101111
011011010010
011111001101
100000110010
100100100111
101000010010
101100000010
110001111101
110101100010
111001011111
111101000101

notice how has probability

  • we tabularise this entire data in a difference distribution table, where the left column iterates over values of and the top row over
0123456789abcdef
000016
0001222442
0010262222
0011224224
010026242
0101422422
0110442222
01112222224
1000224422
10012242222
101022624
101182222
1100222226
1101442222
111024262
111126422
  1. Sum of all elements in a row/column is
  2. All element values are even (commutativity of )
  3. Due to these properties we can never have ideal S-box (all elements = 1)

REMEMBER

Key bits have no influence on a differential since they cancel out

Differential Characteristics

Notice for , has the high probability. Let us construct our path

will have many such possible pairs. We call those right pairs

Using

  1. with
  2. with
  3. with
  4. with

ALERT

we assume the differentials of each round is independent of the previous and next rounds, thus the joint probability is just the product

we get the probability of getting the input to the last round as

Extracting Key Bits

Once an round differential characteristic is discovered we can attack the cipher by recovering bits from the last subkey.

Now partially decrypt the ciphertexts by bruteforcing over the target partial subkey bits. The keys with the highest probability are your candidates

Complexity

Number of chosen plaintext pairs where is the differential characteristic probability for the rounds and is a small constant.

Exercises

Footnotes

  1. https://cs.bc.edu/straubin/crypto2017/heys.pdf

  2. https://kevinliu.me/posts/linear-cryptanalysis/

  3. https://cse.iitkgp.ac.in/~debdeep/courses_iitkgp/Crypto/slides/LC.pdf

  4. https://maticstric.github.io/differential-cryptanalysis-tutorial/