Samiksha Jaiswal (Editor)

Wiener's attack

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

The Wiener's attack, named after cryptologist Michael J. Wiener, is a type of cryptographic attack against RSA. The attack uses the continued fraction method to expose the private key d when d is small.

Contents

Background on RSA

Before we discuss how Wiener's attack works, we will first briefly explain how RSA works. For more details see the main entry on the RSA cryptosystem.
Let Alice and Bob be two people who want to communicate securely. More specifically, Alice wants to send a message to Bob which only Bob can read. First Bob chooses two primes p and q. Then he calculates the RSA modulus N = pq. This RSA modulus is made public together with the encryption exponent e. N and e form the public key pair (e,N). By making this information public, anyone can encrypt messages to Bob. The decryption exponent d satisfies e d = 1 mod φ ( N ) , where φ ( N ) = ( p 1 ) ( q 1 ) , is Euler’s phi function (note: this is the order of the multiplicative group Z N ). The encryption exponent e and φ ( N ) also must be relatively prime so that there is a modular inverse. The factorization of N and the private key d are kept secret, so that only Bob can decrypt the message. We denote the private key pair as (d, N). The encryption of the message M is given by C M e mod N and the decryption of cipher text C is given by C d ( M e ) d M ( e d ) M mod N (using Fermat's little theorem).

Using the Euclidean algorithm, one can efficiently recover the secret key d if one knows the factorization of N. By having the secret key d, one can efficiently factor the modulus of N.

Small Private Key

In the RSA Cryptosystem, Bob might tend to use a small value of d, rather than a large random number to improve the RSA decryption performance. However, Wiener’s attack shows that choosing a small value for d will result in an insecure system in which an attacker can recover all secret information, i.e., break the RSA system. This break is based on Wiener’s Theorem, which holds for small values of d. Wiener has proved that the attacker may efficiently find d when d < 1 3 N 1 4 .

Wiener's paper also presented some countermeasures against his attack that allow fast decryption. Two techniques are described as follows.

Choosing large public key: Replace e by e , where e = e + k . φ ( N ) for some large of k . When e is large enough, i.e. e > N 3 2 , then Wiener’s attack can not be applied regardless of how small d is.

Using the Chinese Remainder Theorem: Suppose one chooses d such that both d p = d mod   ( p 1 ) and d q = d mod   ( q 1 ) are small but d itself is not, then a fast decryption of C can be done as follows:

1. First compute M p C d p mod   p and M q C d q mod   q .
2. Use the Chinese Remainder Theorem to compute the unique value of M Z N which satisfies M M p mod   p and M M q mod   q . The result of M satisfies M C d mod   N as needed. The point is that Wiener’s attack does not apply here because the value of d mod   φ ( N ) can be large.

How Wiener's attack works

Since

e d 1 ( mod   lcm ( p 1 , q 1 ) ) ,

there exists an integer K such that

e d = K × lcm ( p 1 , q 1 ) + 1

Define G = gcd ( p 1 , q 1 ) to be substituted in the equation above which gives:

e d = K G ( p 1 ) ( q 1 ) + 1

Defining k = K gcd ( K , G ) and g = G gcd ( K , G ) , and substituting into the above gives:

e d = k g ( p 1 ) ( q 1 ) + 1 .

Divided by d p q :

e p q = k d g ( 1 δ ) , where δ = p + q 1 g k p q .

So, e p q is slightly smaller than k d g , and the former is composed entirely of public information. However, a method of checking a guess is still required. Assuming that e d > p q (a reasonable assumption unless G is large) the last equation above may be written as:

e d g = k . ( p 1 ) ( q 1 ) + g

By using simple algebraic manipulations and identities, a guess can be checked for accuracy.

Wiener's theorem

Let   N = p q with   q < p < 2 q . Let d < 1 3 N 1 4 .
Given N , e with e d = 1 ( mod   φ ( N ) ) , the attacker can efficiently recover d .

Example

Suppose that the public keys are N , e = 90581 , 17993
The attack shall determine d .
By using Wiener's Theorem and continued fractions to approximate d , first we try to find the continued fractions expansion of e N . Note that this algorithm finds fractions in their lowest terms. We know that

e N = 17993 90581 = 1 5 + 1 29 + + 1 3 = [ 0 , 5 , 29 , 4 , 1 , 3 , 2 , 4 , 3 ]

According to the continued fractions expansion of e N , all convergents k d are:

k d = 0 , 1 5 , 29 146 , 117 589 , 146 735 , 555 2794 , 1256 6323 , 5579 28086 , 17993 90581

We can verify that the first convergent does not produce a factorization of N . However, the convergent 1 5 yields

φ ( N ) = e d 1 k = 17993 × 5 1 1 = 89964

Now, if we solve the equation

x 2 ( ( N φ ( N ) ) + 1 ) x + N = 0 x 2 ( ( 90581 89964 ) + 1 ) x + 90581 = 0 x 2 ( 618 ) x + 90581 = 0

then we find the roots which are x = 379 ; 239 . Therefore we have found the factorization

N = 90581 = 379 × 239 = p × q .

Notice that, for the modulus N = 90581 , Wiener's Theorem will work if

d < N 1 4 3 5.7828 .

Proof of Wiener's theorem

The proof is based on approximations using continued fractions.
Since e d = 1 mod φ ( N ) , there exists a k such that e d k φ ( N ) = 1 . Therefore

| e φ ( N ) k d | = 1 d φ ( N ) .

Hence, k d is an approximation of e φ ( N ) . Although the attacker does not know φ ( N ) , he may use N to approximate it. Indeed, since

φ ( N ) = N p q + 1 and p + q 1 < 3 N , we have:

| p + q 1 | < 3 N | N + 1 φ ( N ) 1 | < 3 N

Using N in place of φ ( N ) we obtain:

| e N k d | = | e d k N N d |

Now, k φ ( N ) = e d 1 < e d , so k φ ( N ) < e d . Since e < φ ( N ) , so k φ ( N ) < e d < φ ( N ) d , then we obtain:

k φ ( N ) < φ ( N ) d

Since k < d and d < 1 3 N 1 4 . Hence we obtain:

(1) | e N k d | 1 d N 1 4

Since d < 1 3 N 1 4 , 2 d < 3 d , then 2 d < 3 d < N 1 4 , we obtain:

2 d < N 1 4 , , so (2) 1 2 d > 1 N 1 4

From (1) and (2), we can conclude that

| e N k d | 3 k d N < 1 d 2 d = 1 2 d 2

It is a theorem that if the condition above is satisfied, then k d appears among the convergents of e N . Therefore the algorithm will indeed eventually find k d .

References

Wiener's attack Wikipedia