Interpolation attack

From HandWiki
Short description: Type of cryptanalytic attack

In cryptography, an interpolation attack is a type of cryptanalytic attack against block ciphers.

After the two attacks, differential cryptanalysis and linear cryptanalysis, were presented on block ciphers, some new block ciphers were introduced, which were proven secure against differential and linear attacks. Among these there were some iterated block ciphers such as the KN-Cipher and the SHARK cipher. However, Thomas Jakobsen and Lars Knudsen showed in the late 1990s that these ciphers were easy to break by introducing a new attack called the interpolation attack.

In the attack, an algebraic function is used to represent an S-box. This may be a simple quadratic, or a polynomial or rational function over a Galois field. Its coefficients can be determined by standard Lagrange interpolation techniques, using known plaintexts as data points. Alternatively, chosen plaintexts can be used to simplify the equations and optimize the attack.

In its simplest version an interpolation attack expresses the ciphertext as a polynomial of the plaintext. If the polynomial has a relative low number of unknown coefficients, then with a collection of plaintext/ciphertext (p/c) pairs, the polynomial can be reconstructed. With the polynomial reconstructed the attacker then has a representation of the encryption, without exact knowledge of the secret key.

The interpolation attack can also be used to recover the secret key.

It is easiest to describe the method with an example.

Example

Let an iterated cipher be given by

[math]\displaystyle{ c_i=(c_{i-1}\oplus k_i)^3, }[/math]

where [math]\displaystyle{ c_0 }[/math] is the plaintext, [math]\displaystyle{ c_i }[/math] the output of the [math]\displaystyle{ i^{th} }[/math] round, [math]\displaystyle{ k_i }[/math] the secret [math]\displaystyle{ i^{th} }[/math] round key (derived from the secret key [math]\displaystyle{ K }[/math] by some key schedule), and for a [math]\displaystyle{ r }[/math]-round iterated cipher, [math]\displaystyle{ c_r }[/math] is the ciphertext.

Consider the 2-round cipher. Let [math]\displaystyle{ x }[/math] denote the message, and [math]\displaystyle{ c }[/math] denote the ciphertext.

Then the output of round 1 becomes

[math]\displaystyle{ c_1=(x+ k_1)^3=(x^2+ k_1^2)(x + k_1)=x^3+ k_1^2x+ x^2k_1+ k_1^3, }[/math]

and the output of round 2 becomes

[math]\displaystyle{ c_2=c=(c_1+ k_2)^3=(x^3+ k_1^2x+ x^2k_1+ k_1^3+ k_2)^3 }[/math]
[math]\displaystyle{ =x^9+ x^8k_1+ x^6k_2+ x^4k_1^2k_2+ x^3k_2^2+ x^2(k_1k_2^2+k_1^4k_2) + x(k_1^2k_2^2+k_1^8)+ k_1^3k_2^2+ k_1^9+ k_2^3, }[/math]

Expressing the ciphertext as a polynomial of the plaintext yields

[math]\displaystyle{ p(x)=a_1x^9+ a_2x^8+ a_3x^6+ a_4x^4+ a_5x^3+ a_6x^2+ a_7x+ a_8, }[/math]

where the [math]\displaystyle{ a_i }[/math]'s are key dependent constants.

Using as many plaintext/ciphertext pairs as the number of unknown coefficients in the polynomial [math]\displaystyle{ p(x) }[/math], then we can construct the polynomial. This can for example be done by Lagrange Interpolation (see Lagrange polynomial). When the unknown coefficients have been determined, then we have a representation [math]\displaystyle{ p(x) }[/math] of the encryption, without knowledge of the secret key [math]\displaystyle{ K }[/math].

Existence

Considering an [math]\displaystyle{ m }[/math]-bit block cipher, then there are [math]\displaystyle{ 2^m }[/math] possible plaintexts, and therefore [math]\displaystyle{ 2^m }[/math] distinct [math]\displaystyle{ p/c }[/math] pairs. Let there be [math]\displaystyle{ n }[/math] unknown coefficients in [math]\displaystyle{ p(x) }[/math]. Since we require as many [math]\displaystyle{ p/c }[/math] pairs as the number of unknown coefficients in the polynomial, then an interpolation attack exist only if [math]\displaystyle{ n\leq 2^m }[/math].

Time complexity

Assume that the time to construct the polynomial [math]\displaystyle{ p(x) }[/math] using [math]\displaystyle{ p/c }[/math] pairs are small, in comparison to the time to encrypt the required plaintexts. Let there be [math]\displaystyle{ n }[/math] unknown coefficients in [math]\displaystyle{ p(x) }[/math]. Then the time complexity for this attack is [math]\displaystyle{ n }[/math], requiring [math]\displaystyle{ n }[/math] known distinct [math]\displaystyle{ p/c }[/math] pairs.

Interpolation attack by Meet-In-The-Middle

Often this method is more efficient. Here is how it is done.

Given an [math]\displaystyle{ r }[/math] round iterated cipher with block length [math]\displaystyle{ m }[/math], let [math]\displaystyle{ z }[/math] be the output of the cipher after [math]\displaystyle{ s }[/math] rounds with [math]\displaystyle{ s\lt r }[/math]. We will express the value of [math]\displaystyle{ z }[/math] as a polynomial of the plaintext [math]\displaystyle{ x }[/math], and as a polynomial of the ciphertext [math]\displaystyle{ c }[/math]. Let [math]\displaystyle{ g(x)\in GF(2^m)[x] }[/math] be the expression of [math]\displaystyle{ z }[/math] via [math]\displaystyle{ x }[/math], and let [math]\displaystyle{ h(c)\in GF(2^m)[c] }[/math] be the expression of [math]\displaystyle{ z }[/math] via [math]\displaystyle{ c }[/math]. The polynomial [math]\displaystyle{ g(x) }[/math] is obtain by computing forward using the iterated formula of the cipher until round [math]\displaystyle{ s }[/math], and the polynomial [math]\displaystyle{ h(c) }[/math] is obtain by computing backwards from the iterated formula of the cipher starting from round [math]\displaystyle{ r }[/math] until round [math]\displaystyle{ s+1 }[/math].

So it should hold that

[math]\displaystyle{ g(x)=h(c), }[/math]

and if both [math]\displaystyle{ g }[/math] and [math]\displaystyle{ h }[/math] are polynomials with a low number of coefficients, then we can solve the equation for the unknown coefficients.

Time complexity

Assume that [math]\displaystyle{ g(x) }[/math] can be expressed by [math]\displaystyle{ p }[/math] coefficients, and [math]\displaystyle{ h(c) }[/math] can be expressed by [math]\displaystyle{ q }[/math] coefficients. Then we would need [math]\displaystyle{ p+q }[/math] known distinct [math]\displaystyle{ p/c }[/math] pairs to solve the equation by setting it up as a matrix equation. However, this matrix equation is solvable up to a multiplication and an addition. So to make sure that we get a unique and non-zero solution, we set the coefficient corresponding to the highest degree to one, and the constant term to zero. Therefore, [math]\displaystyle{ p+q-2 }[/math] known distinct [math]\displaystyle{ p/c }[/math] pairs are required. So the time complexity for this attack is [math]\displaystyle{ p+q-2 }[/math], requiring [math]\displaystyle{ p+q-2 }[/math] known distinct [math]\displaystyle{ p/c }[/math] pairs.

By the Meet-In-The-Middle approach the total number of coefficients is usually smaller than using the normal method. This makes the method more efficient, since less [math]\displaystyle{ p/c }[/math] pairs are required.

Key-recovery

We can also use the interpolation attack to recover the secret key [math]\displaystyle{ K }[/math].

If we remove the last round of an [math]\displaystyle{ r }[/math]-round iterated cipher with block length [math]\displaystyle{ m }[/math], the output of the cipher becomes [math]\displaystyle{ \tilde{y}=c_{r-1} }[/math]. Call the cipher the reduced cipher. The idea is to make a guess on the last round key [math]\displaystyle{ k_r }[/math], such that we can decrypt one round to obtain the output [math]\displaystyle{ \tilde{y} }[/math] of the reduced cipher. Then to verify the guess we use the interpolation attack on the reduced cipher either by the normal method or by the Meet-In-The-Middle method. Here is how it is done.

By the normal method we express the output [math]\displaystyle{ \tilde{y} }[/math] of the reduced cipher as a polynomial of the plaintext [math]\displaystyle{ x }[/math]. Call the polynomial [math]\displaystyle{ p(x)\in GF(2^m)[x] }[/math]. Then if we can express [math]\displaystyle{ p(x) }[/math] with [math]\displaystyle{ n }[/math] coefficients, then using [math]\displaystyle{ n }[/math] known distinct [math]\displaystyle{ p/c }[/math] pairs, we can construct the polynomial. To verify the guess of the last round key, then check with one extra [math]\displaystyle{ p/c }[/math] pair if it holds that

[math]\displaystyle{ p(x)=\tilde{y}. }[/math]

If yes, then with high probability the guess of the last round key was correct. If no, then make another guess of the key.

By the Meet-In-The-Middle method we express the output [math]\displaystyle{ z }[/math] from round [math]\displaystyle{ s\lt r }[/math] as a polynomial of the plaintext [math]\displaystyle{ x }[/math] and as a polynomial of the output of the reduced cipher [math]\displaystyle{ \tilde{y} }[/math]. Call the polynomials [math]\displaystyle{ g(x) }[/math] and [math]\displaystyle{ h(\tilde{y}) }[/math], and let them be expressed by [math]\displaystyle{ p }[/math] and [math]\displaystyle{ q }[/math] coefficients, respectively. Then with [math]\displaystyle{ q+p-2 }[/math] known distinct [math]\displaystyle{ p/c }[/math] pairs we can find the coefficients. To verify the guess of the last round key, then check with one extra [math]\displaystyle{ p/c }[/math] pair if it holds that

[math]\displaystyle{ g(x)=h(\tilde{y}). }[/math]

If yes, then with high probability the guess of the last round key was correct. If no, then make another guess of the key.

Once we have found the correct last round key, then we can continue in a similar fashion on the remaining round keys.

Time complexity

With a secret round key of length [math]\displaystyle{ m }[/math], then there are [math]\displaystyle{ 2^m }[/math] different keys. Each with probability [math]\displaystyle{ 1/2^m }[/math] to be correct if chosen at random. Therefore, we will on average have to make [math]\displaystyle{ 1/2\cdot 2^m }[/math] guesses before finding the correct key.

Hence, the normal method have average time complexity [math]\displaystyle{ 2^{m-1}(n+1) }[/math], requiring [math]\displaystyle{ n+1 }[/math] known distinct [math]\displaystyle{ c/p }[/math] pairs, and the Meet-In-The-Middle method have average time complexity [math]\displaystyle{ 2^{m-1}(p+q-1) }[/math], requiring [math]\displaystyle{ p+q-1 }[/math] known distinct [math]\displaystyle{ c/p }[/math] pairs.

Real world application

The Meet-in-the-middle attack can be used in a variant to attack S-boxes, which uses the inverse function, because with an [math]\displaystyle{ m }[/math]-bit S-box then [math]\displaystyle{ S: f(x)=x^{-1}=x^{2^m-2} }[/math] in [math]\displaystyle{ GF(2^m) }[/math].

The block cipher SHARK uses SP-network with S-box [math]\displaystyle{ S:f(x)=x^{-1} }[/math]. The cipher is resistant against differential and linear cryptanalysis after a small number of rounds. However it was broken in 1996 by Thomas Jakobsen and Lars Knudsen, using interpolation attack. Denote by SHARK[math]\displaystyle{ (n,m,r) }[/math] a version of SHARK with block size [math]\displaystyle{ nm }[/math] bits using [math]\displaystyle{ n }[/math] parallel [math]\displaystyle{ m }[/math]-bit S-boxes in [math]\displaystyle{ r }[/math] rounds. Jakobsen and Knudsen found that there exist an interpolation attack on SHARK[math]\displaystyle{ (8,8,4) }[/math] (64-bit block cipher) using about [math]\displaystyle{ 2^{21} }[/math] chosen plaintexts, and an interpolation attack on SHARK[math]\displaystyle{ (8,16,7) }[/math] (128-bit block cipher) using about [math]\displaystyle{ 2^{61} }[/math] chosen plaintexts.

Also Thomas Jakobsen introduced a probabilistic version of the interpolation attack using Madhu Sudan's algorithm for improved decoding of Reed-Solomon codes. This attack can work even when an algebraic relationship between plaintexts and ciphertexts holds for only a fraction of values.

References