- 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
input | output | |
---|---|---|
0 | E | |
1 | 4 | |
2 | D | |
3 | 1 | |
4 | 2 | |
5 | F | |
6 | B | |
7 | 8 | |
8 | 3 | |
9 | A | |
A | 6 | |
B | C | |
C | 5 | |
D | 9 | |
E | 0 | |
F | 7 |
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
input | output |
---|---|
1 | 1 |
2 | 5 |
3 | 9 |
4 | 13 |
5 | 2 |
6 | 6 |
7 | 10 |
8 | 14 |
9 | 3 |
10 | 7 |
11 | 11 |
12 | 15 |
13 | 4 |
14 | 8 |
15 | 12 |
16 | 16 |
Attacks
attacks on symmetric key block ciphers1
Linear Cryptanalysis
known-plaintext-attack
- Create LATs for all S-boxes
- Create LAT for overall cipher by concatenating
- 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
- with bias
- with bias
- with bias
- 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
- All the ‘s from the first layer appear
- All the ‘s from the last layer appear
- 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
- You have known plaintext-ciphertext pairs
- Your last round sends the output only to certain last round S-Boxes.
- You can bruteforce the subkey bits after those boxes () and compare the final output with your known ciphertext
- For every tried subkey you keep track of how many plaintext/ciphertext pairs it gave a correct result of (final output matched ciphertext bits)
- 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
0000 | 1011 | 0010 |
0001 | 1010 | 0010 |
0010 | 1001 | 0111 |
0011 | 1000 | 0010 |
0100 | 1111 | 0101 |
0101 | 1110 | 1111 |
0110 | 1101 | 0010 |
0111 | 1100 | 1101 |
1000 | 0011 | 0010 |
1001 | 0010 | 0111 |
1010 | 0001 | 0010 |
1011 | 0000 | 0010 |
1100 | 0111 | 1101 |
1101 | 0110 | 0010 |
1110 | 0101 | 1111 |
1111 | 0100 | 0101 |
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
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | f | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0000 | 16 | |||||||||||||||
0001 | 2 | 2 | 2 | 4 | 4 | 2 | ||||||||||
0010 | 2 | 6 | 2 | 2 | 2 | 2 | ||||||||||
0011 | 2 | 2 | 4 | 2 | 2 | 4 | ||||||||||
0100 | 2 | 6 | 2 | 4 | 2 | |||||||||||
0101 | 4 | 2 | 2 | 4 | 2 | 2 | ||||||||||
0110 | 4 | 4 | 2 | 2 | 2 | 2 | ||||||||||
0111 | 2 | 2 | 2 | 2 | 2 | 2 | 4 | |||||||||
1000 | 2 | 2 | 4 | 4 | 2 | 2 | ||||||||||
1001 | 2 | 2 | 4 | 2 | 2 | 2 | 2 | |||||||||
1010 | 2 | 2 | 6 | 2 | 4 | |||||||||||
1011 | 8 | 2 | 2 | 2 | 2 | |||||||||||
1100 | 2 | 2 | 2 | 2 | 2 | 6 | ||||||||||
1101 | 4 | 4 | 2 | 2 | 2 | 2 | ||||||||||
1110 | 2 | 4 | 2 | 6 | 2 | |||||||||||
1111 | 2 | 6 | 4 | 2 | 2 |
- Sum of all elements in a row/column is
- All element values are even (commutativity of )
- 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
- with
- with
- with
- 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.