/EUCLID-ATTACK

An application of Euclidean algorithm in cryptanalysis of RSA

Primary LanguageJavaMIT LicenseMIT

EUCLID-ATTACK

An implementation of EuclidAttack. Which is An application of Euclidean algorithm in cryptanalysis of RSA.

It computes the factorization of n in deterministic time O((log n)2) bit operations. In the case where the public exponent (e) has the same order of magnitude as (n) and one of the integers k = (ed − 1)/ϕ(n) and (e − k) is < n0.25.

Theorem

  1. Let p and q be two odd primes of the same bit-size L and n = pq.

  2. Consider positive integers e, d with 1 < e, d < ϕ(n) such that ed ≡ 1 (mod ϕ(n)). Then (n, e) is the public key and d the private key for an RSA cryptosystem.

  3. Set a = (n + 1) mod e and Δ = gcd(e, a).

  4. The extended Euclidean algorithm for e and a gives integers qi > 0 (i = 1, . . . , m) and ri (i = 0, . . . , m + 1) such that

    1. r0 = e
    2. r1 = a
    3. rm = Δ
    4. rm+1 = 0
    5. and ri - 1 = ri*qi + ri + 1, 0 < ri + 1 < ri.
  5. Further, there are integers si, ti with |ti| < e/ri - 1 and |si| < a/ri - 1 satisfying sie + ati = ri , (i = 2, . . . , m + 1).

  6. Set μi = gcd(ti, ri) and t'i = tii (i = 0, . . . , m + 1).

  7. Let e > n/c, where c is an integer ≥ 1, and k = (ed−1)/ϕ(n).

  8. Suppose that k or e−k is ≤ e0.25/6c0.5. Then, we have

    1. Δ < e3/4.
    2. k = |t'j| and p+q = (a +|t'j|-1) mod e, where j is such that rj is the largest remainder < e3/4.
    3. Or k = e − |t'j| and p + q = (a + (e − |t'j|) −1 ) mod e, where j is such that rj is the largest remainder < e3/4.

Algorithm

Input: An RSA public key (n, e) with e > n/c (Read the paper for more info about c). Output: The primes p and q.

  1. Compute a = (n + 1) mod e.
  2. Using the extended Euclidean algorithm for e and a, compute the biggest remainder rj among them which are < e3/4 and the associated integers sj , tj such that sje + atj = rj.
  3. Compute μj = gcd(tj , rj) and next t'j = tjj.
  4. Compute B1 = (a + |t'j|-1) mod e and next the solutions u1 and v1 of equation [X2 + B1X + n = 0]. If u1 and v1 are positive integers, then output (u1 , v1). Otherwise, go to the next step.
  5. Compute B2 = (a + (e − |t'j|)-1) mod e and next the solutions u2 and v2 of equation [X2 + B2X + n = 0]. If u2 and v2 are positive integers, then output (u2 , v2). Otherwise, output FAIL.

Paper

Poulakis, Dimitrios. (2020). An application of Euclidean algorithm in cryptanalysis of RSA. Elemente der Mathematik. 75. 114-120. 10.4171/EM/411.