Differential and Linear Cryptanalysis
Differential Cryptanalysis
Differential cryptanalysis is a type of chosen-plaintext attack, where the attacker studies how differences in the input to a cryptographic algorithm affect the differences in the output. The goal is to find patterns that reveal information about the key used in the encryption process.
Steps in Differential Cryptanalysis- Select input pairs: Choose two inputs with a specific difference.
- Compute the output difference: After encryption, compare the two ciphertexts to analyze the differences.
- Track differences through the rounds: Study how the input difference affects the difference after each round of the cipher.
- Guess the key: Based on the differential characteristics and patterns observed, make educated guesses about the subkeys used in different rounds.
$$E(K, m) \oplus E(K, m') = (\Delta{m}_{17} || \Delta{m}_{16})$$
Let’s walk through a simplified example of differential cryptanalysis on a hypothetical, small block cipher to illustrate how it works.
Cipher Setup:Suppose we have a toy cipher with the following structure:
- Block size: 4 bits (for simplicity).
- Rounds: 2 rounds of encryption.
- S-box: A substitution box used for non-linear transformation, mapping 2 bits to 2 bits.
Let’s assume the S-box for this cipher is as follows:
Input | Output |
---|---|
00 | 11 |
01 | 00 |
10 | 01 |
11 | 10 |
The encryption process consists of two rounds:
- Substitution using the S-box.
- XOR with the round key.
We choose two plaintexts that differ by a known amount, typically a specific bitwise difference (often XOR). Let’s choose the two plaintexts as:
- Plaintext P₁ =
0101
- Plaintext P₂ =
0001
The difference between P₁ and P₂ is 0101 XOR 0001 = 0100
. This is the input difference we’ll track through the cipher.
For P₁ =
0101
, we apply the S-box to each pair of 2 bits.- First 2 bits:
01
→00
(according to the S-box). - Last 2 bits:
01
→00
. - Result after substitution:
0000
.
- First 2 bits:
For P₂ =
0001
, we apply the S-box:- First 2 bits:
00
→11
. - Last 2 bits:
01
→00
. - Result after substitution:
1100
.
- First 2 bits:
Now, calculate the difference after this round of substitution.
- S(P₁) XOR S(P₂) =
0000 XOR 1100 = 1100
.
This shows that the difference propagates through the S-box and affects certain bits.
4. Key Addition:Next, we assume both plaintexts are XORed with the same round key (say, K₁ = 1010
).
- For P₁, we XOR with K₁:
0000 XOR 1010 = 1010
. - For P₂, we XOR with K₁:
1100 XOR 1010 = 0110
.
Now, both results go through another round of S-box substitution.
For P₁ =
1010
:- First 2 bits:
10
→01
. - Last 2 bits:
10
→01
. - Result after substitution:
0101
.
- First 2 bits:
For P₂ =
0110
:- First 2 bits:
01
→00
. - Last 2 bits:
10
→01
. - Result after substitution:
0001
.
- First 2 bits:
Finally, calculate the difference between the two ciphertexts:
- C₁ XOR C₂ =
0101 XOR 0001 = 0100
.
So, the output difference between the two ciphertexts is 0100
.
Through this process, the differential cryptanalyst:
- Tracks how the differences propagate through the S-box and key addition stages.
- Builds a differential characteristic: in this case, an input difference of
0100
leads to an output difference of0100
with some probability. - Repeats this process for many different pairs of plaintexts to gather information about how the cipher behaves under certain differences.
Using this knowledge, the cryptanalyst can begin to infer parts of the secret key by observing which pairs of differences are more likely than others and backtrack to the key used in the encryption process.
In a perfectly random cipher, all differences should propagate randomly. However, most practical ciphers, like DES, exhibit small biases in how differences propagate, especially in the S-boxes. These biases can be exploited to reduce the number of possible keys that need to be checked.
CountermeasuresTo defend against differential cryptanalysis, modern ciphers are designed with the following in mind:
- Complex S-boxes: Non-linear substitution boxes (S-boxes) are designed to reduce the probability of exploitable differential patterns.
- Increased Key Sizes: Larger keys make brute-force attacks harder, even when partial information is gained through differential cryptanalysis.
- Multiple Rounds: By increasing the number of rounds in the cipher, the chances of successfully tracking the differences through the entire encryption process decrease.
- DES: Differential cryptanalysis was initially developed to break DES. Although DES was not designed with differential cryptanalysis in mind, it was found to be resistant to this attack due to the number of rounds (16 rounds).
- AES: The Advanced Encryption Standard (AES) is designed with protection against differential cryptanalysis, utilizing robust S-boxes and a high number of rounds.
Linear cryptanalysis involves the following steps:
Linear Approximation:
- The attacker tries to find a linear equation that relates the bits of the plaintext, the bits of the ciphertext, and the bits of the key.
- The goal is to find an approximation where the XOR of selected plaintext bits and the XOR of corresponding ciphertext bits equals the XOR of some key bits with a probability significantly different from 0.5.
Data Collection:
- The attacker collects a large number of plaintext-ciphertext pairs (i.e., input-output pairs of the cipher) using known plaintext.
- These pairs are used to build statistical evidence for the guessed key bits by applying the chosen linear approximation.
Key Guessing:
- The attacker then guesses certain bits of the key.
- Using the linear approximation, the attacker checks how often the approximation holds for different guesses of the key bits. A correct key guess should produce results that match the biased probability more closely.
Statistical Analysis:
- For each possible key guess, the attacker calculates the number of times the linear approximation holds true. If a key guess is correct, the approximation will be biased toward its predicted probability.
- By comparing how well the approximations fit for different key guesses, the attacker can determine the most likely correct key bits.
Linear cryptanalysis works by exploiting statistical biases introduced by the non-linear operations (like S-boxes) in block ciphers. Although these operations are designed to make it hard to find simple relationships between plaintext and ciphertext, they are not perfect.
The cipher’s security relies on these biases being small and difficult to detect. However, with enough data, an attacker can statistically identify the biases and use them to extract key information.
Countermeasures Against Linear CryptanalysisDesigning Better S-boxes:
- Block cipher designers can improve resistance to linear cryptanalysis by designing S-boxes with minimal linear biases. A good S-box has no easily exploitable linear approximations.
Increasing Key Size:
- Increasing the key size (like in Triple DES or AES) helps make linear cryptanalysis less practical by increasing the computational power needed for the attack.
More Rounds:
- Increasing the number of rounds in a block cipher makes it harder for linear approximations to hold over the entire encryption process. For instance, adding more rounds increases the complexity of finding effective linear approximations.
Linear Cryptanalysis is a powerful method used to break symmetric-key block ciphers by finding linear approximations between the plaintext, ciphertext, and key bits. It works by analyzing the statistical bias in these approximations, and with enough data, it allows attackers to recover parts of the encryption key. While effective against older ciphers like DES, modern ciphers like AES are designed with mechanisms to resist linear cryptanalysis.
This attack emphasizes the importance of non-linearity and randomness in cryptographic algorithms, and it has significantly influenced the design of secure encryption methods in modern cryptography.
Example of Linear Cryptanalysis
Let’s go through a simplified example of linear cryptanalysis using a toy block cipher, designed to illustrate how this attack works.
Toy Cipher Setup
For this example, we’ll consider a simple cipher with:
- 4-bit blocks of plaintext and ciphertext.
- A 4-bit key.
- One round of encryption with a basic XOR-based function and an S-box for non-linearity.
Steps of the Toy Cipher
S-box:
- We use a basic 4-bit S-box that performs substitution. Assume the S-box table is as follows:
Input (X) Output (S(X)) 0000 1110 0001 0100 0010 1101 0011 0001 0100 0011 0101 1111 0110 1000 0111 1010 1000 0010 1001 1001 1010 0110 1011 1011 1100 0000 1101 0101 1110 0111 1111 1001 Key Addition (XOR):
- The plaintext is XORed with the key, then passed through the S-box. The ciphertext is simply the output of the S-box.
Encryption Process
Let’s see an example encryption with this toy cipher:
Plaintext:
P = 1010
Key:
K = 1101
Step 1: XOR the plaintext and the key:
Step 2: Pass the result through the S-box:
Ciphertext:
C = 1010
Linear Cryptanalysis Attack
Now, let’s see how linear cryptanalysis works against this toy cipher.
Step 1: Linear Approximation
We aim to find a linear relationship between the plaintext (P
), ciphertext (C
), and key (K
) that holds with some bias (i.e., a probability significantly different from 0.5).
We will try the following linear approximation:
- P[0] ⊕ P[2] = C[1]
This approximation means that the XOR of the first and third bits of the plaintext is equal to the second bit of the ciphertext. We want to see if this approximation holds with a probability significantly different from 50%.
Step 2: Collect Data
We collect some plaintext-ciphertext pairs. For simplicity, let's use the following pairs (we encrypted these earlier using the toy cipher):
Plaintext (P) | Ciphertext (C) |
---|---|
0000 | 1110 |
0001 | 0100 |
0010 | 1101 |
0011 | 0001 |
0100 | 0011 |
1010 | 1010 |
0110 | 1000 |
1111 | 1001 |
Step 3: Analyze Data
For each pair, we evaluate the linear approximation P[0] ⊕ P[2] = C[1]:
P[0] ⊕ P[2] | C[1] | Approximation Holds? |
---|---|---|
0 ⊕ 0 = 0 | 1 | No |
0 ⊕ 0 = 0 | 1 | No |
0 ⊕ 1 = 1 | 1 | Yes |
0 ⊕ 1 = 1 | 0 | No |
0 ⊕ 1 = 1 | 0 | No |
1 ⊕ 1 = 0 | 0 | Yes |
0 ⊕ 1 = 1 | 0 | No |
1 ⊕ 1 = 0 | 0 | Yes |
In this case, out of 8 pairs, the approximation holds for 3 out of 8. That’s a probability of 3/8 = 0.375, which is somewhat lower than 0.5, showing a bias.
Step 4: Guess Key Bits
If we had more data, we could use this approximation to guess key bits. In real-world linear cryptanalysis, the attacker uses thousands or millions of plaintext-ciphertext pairs to reduce uncertainty in key bit guesses.
Comments
Post a Comment