Coppersmith's attack

From HandWiki

Coppersmith's attack describes a class of cryptographic attacks on the public-key cryptosystem RSA based on the Coppersmith method. Particular applications of the Coppersmith method for attacking RSA include cases when the public exponent e is small or when partial knowledge of a prime factor of the secret key is available.

RSA basics

The public key in the RSA system is a tuple of integers [math]\displaystyle{ (N, e) }[/math], where N is the product of two primes p and q. The secret key is given by an integer d satisfying [math]\displaystyle{ ed \equiv 1 \pmod{(p - 1)(q - 1)} }[/math]; equivalently, the secret key may be given by [math]\displaystyle{ d_p \equiv d \pmod{p - 1} }[/math] and [math]\displaystyle{ d_q \equiv d \pmod{q - 1} }[/math] if the Chinese remainder theorem is used to improve the speed of decryption, see CRT-RSA. Encryption of a message M produces the ciphertext [math]\displaystyle{ C \equiv M^e \pmod{N} }[/math], which can be decrypted using [math]\displaystyle{ d }[/math] by computing [math]\displaystyle{ C^d \equiv M \pmod{N} }[/math].

Low public exponent attack

In order to reduce encryption or signature verification time, it is useful to use a small public exponent ([math]\displaystyle{ e }[/math]). In practice, common choices for [math]\displaystyle{ e }[/math] are 3, 17 and 65537 [math]\displaystyle{ (2^{16} + 1) }[/math]. These values for e are Fermat primes, sometimes referred to as [math]\displaystyle{ F_0, F_2 }[/math] and [math]\displaystyle{ F_4 }[/math] respectively [math]\displaystyle{ (F_x = 2^{2^x} + 1) }[/math]. They are chosen because they make the modular exponentiation operation faster. Also, having chosen such [math]\displaystyle{ e }[/math], it is simpler to test whether [math]\displaystyle{ \gcd(e, p - 1) = 1 }[/math] and [math]\displaystyle{ \gcd(e, q - 1) = 1 }[/math] while generating and testing the primes in step 1 of the key generation. Values of [math]\displaystyle{ p }[/math] or [math]\displaystyle{ q }[/math] that fail this test can be rejected there and then. (Even better: if e is prime and greater than 2, then the test [math]\displaystyle{ p \bmod e \ne 1 }[/math] can replace the more expensive test [math]\displaystyle{ \gcd(p - 1, e) = 1 }[/math].)

If the public exponent is small and the plaintext [math]\displaystyle{ m }[/math] is very short, then the RSA function may be easy to invert, which makes certain attacks possible. Padding schemes ensure that messages have full lengths, but additionally choosing the public exponent [math]\displaystyle{ e = 2^{16} + 1 }[/math] is recommended. When this value is used, signature verification requires 17 multiplications, as opposed to about 25 when a random [math]\displaystyle{ e }[/math] of similar size is used. Unlike low private exponent (see Wiener's attack), attacks that apply when a small [math]\displaystyle{ e }[/math] is used are far from a total break, which would recover the secret key d. The most powerful attacks on low public exponent RSA are based on the following theorem, which is due to Don Coppersmith.

Coppersmith method

Main page: Coppersmith method
Theorem 1 (Coppersmith)[1]
Let N be an integer and [math]\displaystyle{ f \in {\mathbb Z}[x] }[/math] be a monic polynomial of degree [math]\displaystyle{ d }[/math] over the integers. Set [math]\displaystyle{ X = N^{\frac{1}{d} - \epsilon} }[/math] for [math]\displaystyle{ \frac{1}{d} \gt \epsilon \gt 0 }[/math]. Then, given [math]\displaystyle{ \left \langle N, f \right \rangle }[/math], attacker (Eve) can efficiently find all integers [math]\displaystyle{ x_0 \lt X }[/math] satisfying [math]\displaystyle{ f(x_0) \equiv 0 \pmod{N} }[/math]. The running time is dominated by the time it takes to run the LLL algorithm on a lattice of dimension O[math]\displaystyle{ (w) }[/math] with [math]\displaystyle{ w = \min\left\{ \frac{1}{\epsilon}, \log_2N\right\} }[/math].

This theorem states the existence of an algorithm that can efficiently find all roots of [math]\displaystyle{ f }[/math] modulo [math]\displaystyle{ N }[/math] that are smaller than [math]\displaystyle{ X = N^{\frac{1}{d}} }[/math]. As [math]\displaystyle{ X }[/math] gets smaller, the algorithm's runtime decreases. This theorem's strength is the ability to find all small roots of polynomials modulo a composite [math]\displaystyle{ N }[/math].

Håstad's broadcast attack

The simplest form of Håstad's attack[2] is presented to ease understanding. The general case uses the Coppersmith method.

Suppose one sender sends the same message [math]\displaystyle{ M }[/math] in encrypted form to a number of people [math]\displaystyle{ P_1;P_2;\dots ;P_k }[/math], each using the same small public exponent [math]\displaystyle{ e }[/math], say [math]\displaystyle{ e=3 }[/math], and different moduli [math]\displaystyle{ \left\langle N_i, e \right\rangle }[/math]. A simple argument shows that as soon as [math]\displaystyle{ k \ge 3 }[/math] ciphertexts are known, the message [math]\displaystyle{ M }[/math] is no longer secure: Suppose Eve intercepts [math]\displaystyle{ C_1, C_2 }[/math], and [math]\displaystyle{ C_3 }[/math], where [math]\displaystyle{ C_i \equiv M^3 \pmod{N_i} }[/math]. We may assume [math]\displaystyle{ \gcd(N_i, N_j) = 1 }[/math] for all [math]\displaystyle{ i, j }[/math] (otherwise, it is possible to compute a factor of one of the numbers [math]\displaystyle{ N_i }[/math] by computing [math]\displaystyle{ \gcd(N_i, N_j) }[/math].) By the Chinese remainder theorem, she may compute [math]\displaystyle{ C \in \mathbb{Z}^*_{N_1N_2N_3} }[/math] such that [math]\displaystyle{ C \equiv C_i \pmod{N_i} }[/math]. Then [math]\displaystyle{ C \equiv M^3\pmod{N_1 N_2 N_3} }[/math]; however, since [math]\displaystyle{ M \lt N_i }[/math] for all [math]\displaystyle{ i }[/math], we have [math]\displaystyle{ M^3 \lt N_1N_2N_3 }[/math]. Thus [math]\displaystyle{ C = M^3 }[/math] holds over the integers, and Eve can compute the cube root of [math]\displaystyle{ C }[/math] to obtain [math]\displaystyle{ M }[/math].

For larger values of [math]\displaystyle{ e }[/math], more ciphertexts are needed, particularly, [math]\displaystyle{ e }[/math] ciphertexts are sufficient.

Generalizations

Håstad also showed that applying a linear padding to [math]\displaystyle{ M }[/math] prior to encryption does not protect against this attack. Assume the attacker learns that [math]\displaystyle{ C_i = f_i(M)^e }[/math] for [math]\displaystyle{ 1 \leq i \leq k }[/math] and some linear function [math]\displaystyle{ f_i }[/math], i.e., Bob applies a pad to the message [math]\displaystyle{ M }[/math] prior to encrypting it so that the recipients receive slightly different messages. For instance, if [math]\displaystyle{ M }[/math] is [math]\displaystyle{ m }[/math] bits long, Bob might encrypt [math]\displaystyle{ M_i = i2^m + M }[/math] and send this to the [math]\displaystyle{ i }[/math]-th recipient.

If a large enough group of people is involved, the attacker can recover the plaintext [math]\displaystyle{ M_i }[/math] from all the ciphertext with similar methods. In more generality, Håstad proved that a system of univariate equations modulo relatively prime composites, such as applying any fixed polynomial [math]\displaystyle{ g_i(M) \equiv 0 \pmod{N_i} }[/math], could be solved if sufficiently many equations are provided. This attack suggests that randomized padding should be used in RSA encryption.

Theorem 2 (Håstad)
Suppose [math]\displaystyle{ N_1, \dots, N_k }[/math] are relatively prime integers and set [math]\displaystyle{ N_\text{min} = \min_i\{N_i\} }[/math]. Let [math]\displaystyle{ g_i (x) \in \mathbb{Z}/N_i[x] }[/math] be [math]\displaystyle{ k }[/math] polynomials of maximum degree [math]\displaystyle{ q }[/math]. Suppose there exists a unique [math]\displaystyle{ M \lt N_\text{min} }[/math] satisfying [math]\displaystyle{ g_i(M) \equiv 0 \pmod{N_i} }[/math] for all [math]\displaystyle{ i \in \left\{ 1, \dots, k \right\} }[/math]. Furthermore, suppose [math]\displaystyle{ k \gt q }[/math]. There is an efficient algorithm that, given [math]\displaystyle{ \left\langle N_i, g_i (x) \right\rangle }[/math] for all [math]\displaystyle{ i }[/math], computes [math]\displaystyle{ M }[/math].
Proof

Since the [math]\displaystyle{ N_i }[/math] are relatively prime the Chinese remainder theorem might be used to compute coefficients [math]\displaystyle{ T_i }[/math] satisfying [math]\displaystyle{ T_i \equiv 1 \pmod{N_i} }[/math] and [math]\displaystyle{ T_i \equiv 0 \pmod{N_j} }[/math] for all [math]\displaystyle{ i \ne j }[/math]. Setting [math]\displaystyle{ g(x) = \sum T_i \cdot g_i(x) }[/math], we know that [math]\displaystyle{ g(M) \equiv 0 \pmod{\prod N_i} }[/math]. Since the [math]\displaystyle{ T_i }[/math] are nonzero, we have that [math]\displaystyle{ g(x) }[/math] is also nonzero. The degree of [math]\displaystyle{ g(x) }[/math] is at most [math]\displaystyle{ q }[/math]. By Coppersmith’s theorem, we may compute all integer roots [math]\displaystyle{ x_0 }[/math] satisfying [math]\displaystyle{ g(x_0) \equiv 0 \pmod{\prod N_i} }[/math] and [math]\displaystyle{ \left| x_0 \right| \lt \left(\prod N_i\right)^{\frac{1}{q}} }[/math]. However, we know that [math]\displaystyle{ M \lt N_\text{min} \lt \left(\prod N_i\right)^{\frac{1}{k}} \lt \left(\prod N_i\right)^{\frac{1}{q}} }[/math], so [math]\displaystyle{ M }[/math] is among the roots found by Coppersmith's theorem.

This theorem can be applied to the problem of broadcast RSA in the following manner: Suppose the [math]\displaystyle{ i }[/math]-th plaintext is padded with a polynomial [math]\displaystyle{ f_i(x) }[/math], so that [math]\displaystyle{ g_i = \big(f_i(x)\big)^{e_i} - C_i \bmod N_i }[/math]. Then [math]\displaystyle{ g_i(M) \equiv 0 \bmod N_i }[/math] is true, and Coppersmith’s method can be used. The attack succeeds once [math]\displaystyle{ k \gt \max_i (e_i \cdot \deg f_i) }[/math], where [math]\displaystyle{ k }[/math] is the number of messages. The original result used Håstad’s variant instead of the full Coppersmith method. As a result, it required [math]\displaystyle{ k = O(q^2) }[/math] messages, where [math]\displaystyle{ q = \max_i(e_i \cdot \deg f_i) }[/math].[2]

Franklin–Reiter related-message attack

Franklin and Reiter identified an attack against RSA when multiple related messages are encrypted: If two messages differ only by a known fixed difference between the two messages and are RSA-encrypted under the same RSA modulus [math]\displaystyle{ N }[/math], then it is possible to recover both of them. The attack was originally described with public exponent [math]\displaystyle{ e = 3 }[/math], but it works more generally (with increasing cost as [math]\displaystyle{ e }[/math] grows).

Let [math]\displaystyle{ \left\langle N; e_i \right\rangle }[/math] be Alice's public key. Suppose [math]\displaystyle{ M_1; M_2 \in \mathbb{Z}_N }[/math] are two distinct messages satisfying [math]\displaystyle{ M_1 \equiv f(M_2) \pmod{N} }[/math] for some publicly known polynomial [math]\displaystyle{ f \in \mathbb{Z}_N[x] }[/math]. To send [math]\displaystyle{ M_1 }[/math] and [math]\displaystyle{ M_2 }[/math] to Alice, Bob may naively encrypt the messages and transmit the resulting ciphertexts [math]\displaystyle{ C_1; C_2 }[/math]. Eve can easily recover [math]\displaystyle{ M_1; M_2 }[/math], given [math]\displaystyle{ C_1; C_2 }[/math], by using the following theorem:

Theorem 3 (Franklin–Reiter)[1]
Let [math]\displaystyle{ \left\langle N, e \right\rangle }[/math] be an RSA public key. Let [math]\displaystyle{ M_1 \ne M_2 \in \mathbb{Z}^*_N }[/math] satisfy [math]\displaystyle{ M_1 \equiv f(M_2) \pmod{N} }[/math] for some linear polynomial [math]\displaystyle{ f = ax + b \in \mathbb{Z}_N[x] }[/math] with [math]\displaystyle{ b \ne 0 }[/math]. Then, given [math]\displaystyle{ \left\langle N, e, C_1, C_2, f \right\rangle }[/math], attacker (Eve) can recover [math]\displaystyle{ M_1, M_2 }[/math] in time quadratic in [math]\displaystyle{ e \cdot \log N }[/math].
Proof

Since [math]\displaystyle{ C_1 \equiv M_1^e \pmod{N} }[/math], we know that [math]\displaystyle{ M_2 }[/math] is a root of the polynomial [math]\displaystyle{ g_1(x) = f(x)^e - C_1 \in \mathbb{Z}_N[x] }[/math]. Similarly, [math]\displaystyle{ M_2 }[/math] is a root of [math]\displaystyle{ g_2(x) = x^e - C_2 \in \mathbb{Z}_N[x] }[/math]. Hence, the linear factor [math]\displaystyle{ x - M_2 }[/math] divides both polynomials. Therefore, Eve may calculate the greatest common divisor [math]\displaystyle{ \gcd(g_1, g_2) }[/math] of [math]\displaystyle{ g_1 }[/math] and [math]\displaystyle{ g_2 }[/math], and if the [math]\displaystyle{ \gcd }[/math] turns out to be linear, [math]\displaystyle{ M_2 }[/math] is found. The [math]\displaystyle{ \gcd }[/math] can be computed in quadratic time in [math]\displaystyle{ e }[/math] and [math]\displaystyle{ \log N }[/math] using the Euclidean algorithm.

Coppersmith’s short-pad attack

Like Håstad’s and Franklin–Reiter’s attacks, this attack exploits a weakness of RSA with public exponent [math]\displaystyle{ e = 3 }[/math]. Coppersmith showed that if randomized padding suggested by Håstad is used improperly, then RSA encryption is not secure.

Suppose Bob sends a message [math]\displaystyle{ M }[/math] to Alice using a small random padding before encrypting it. An attacker, Eve, intercepts the ciphertext and prevents it from reaching its destination. Bob decides to resend [math]\displaystyle{ M }[/math] to Alice because Alice did not respond to his message. He randomly pads [math]\displaystyle{ M }[/math] again and transmits the resulting ciphertext. Eve now has two ciphertexts corresponding to two encryptions of the same message using two different random pads.

Even though Eve does not know the random pad being used, she still can recover the message [math]\displaystyle{ M }[/math] by using the following theorem, if the random padding is too short.

Theorem 4 (Coppersmith)
Let [math]\displaystyle{ \left\langle N, e\right\rangle }[/math] be a public RSA key, where [math]\displaystyle{ N }[/math] is [math]\displaystyle{ n }[/math] bits long. Set [math]\displaystyle{ m = \left\lfloor \frac{n}{e^2} \right\rfloor }[/math]. Let [math]\displaystyle{ M \in \mathbb {Z}^*_N }[/math] be a message of length at most [math]\displaystyle{ n - m }[/math] bits. Define [math]\displaystyle{ M_1 = 2^m M + r_1 }[/math] and [math]\displaystyle{ M_2 = 2^m M + r_2 }[/math], where [math]\displaystyle{ r_1 }[/math] and [math]\displaystyle{ r_2 }[/math] are distinct integers with [math]\displaystyle{ 0 \le r_1, r_2 \lt 2^m }[/math]. If Eve is given [math]\displaystyle{ \left\langle N, e\right\rangle }[/math] and the encryptions [math]\displaystyle{ C_1, C_2 }[/math] of [math]\displaystyle{ M_1, M_2 }[/math] (but is not given [math]\displaystyle{ r_1 }[/math] or [math]\displaystyle{ r_2 }[/math]), she can efficiently recover [math]\displaystyle{ M }[/math].
Proof[1]

Define [math]\displaystyle{ g_1(x, y) = x^e - C_1 }[/math] and [math]\displaystyle{ g_2(x, y) = (x + y)^e - C_2 }[/math]. We know that when [math]\displaystyle{ y = r_2 - r_1 }[/math], these polynomials have [math]\displaystyle{ x = M_1 }[/math] as a common root. In other words, [math]\displaystyle{ \Delta = r_2 - r_1 }[/math] is a root of the resultant [math]\displaystyle{ h(y) = \operatorname{res}_x(g_1,g_2) \in \mathbb {Z}_N[y] }[/math]. Furthermore, [math]\displaystyle{ |\Delta| \lt 2^m \lt N^{\frac{1}{e^2}} }[/math]. Hence, [math]\displaystyle{ \Delta }[/math] is a small root of [math]\displaystyle{ h }[/math] modulo [math]\displaystyle{ N }[/math], and Eve can efficiently find it using the Coppersmith method. Once [math]\displaystyle{ \Delta }[/math] is known, the Franklin–Reiter attack can be used to recover [math]\displaystyle{ M_2 }[/math] and consequently [math]\displaystyle{ M }[/math].

See also

  • ROCA attack

References