2

I'm learning about common modulus attack and learned that public modulus attacks can find out the private key. Assume there are 2 users with public and private keys $(e_1, d_1)$ and $(e_2, d_2)$. Scenario is attacker has his public and private keys $(e_2, d_2)$ and victim's public key $e_1$ Here are the steps to get the secret key:

  1. $t= e_2\cdot d_2-1$
  2. Attacker uses the extended Euclidean algorithm to find $f=\gcd(t,e_1)$ whose pairs of numbers $(r,s)$ satisfy the equation $r\cdot t + s\cdot e_1 = f$
  3. If $f=1$ set $d_1' = s$ and return private key $d_1'$
  4. If $f\neq 1$ set $t=\frac t s$ and return step 2

I have a example with $d_1=17, M = 25$ is two value we should find. n = 253 (common modulus) $e_1 = 13$ (victim's public key) $e_2 = 23$ (attacker's public key ) $d_2 = 67$ (attacker's private key) $C = 27$ (Ciphertext). Attacker will find $d_1'$ according there steps:

  1. $t= e_2\cdot d_2-1 = 23\cdot 67 = 1540$
  2. $\gcd(t,e_1) = 1 \implies r = -2, s = 237$
  3. So $d_1' = s = 237$
  4. Verify $M = C^{d_1} \bmod n = 27^{237} \bmod 253 = 25$

Problem is I don't understand why with such steps we will find the secret key. Can someone explain me pls ?

fgrieu
  • 140,762
  • 12
  • 307
  • 587
domiee13
  • 21
  • 1

1 Answers1

1

We'll heavilly use the following fact: for a fixed public modulus $n$ product of distinct primes, a pair of integers $(e,d)$ forms a matching pair of RSA exponents [that is, with $c\mapsto c^d\bmod n\,=\,m$ capable of reliably deciphering any plaintext $m$ in $[0,n)$ enciphered per $m\mapsto m^e\bmod n\,=\,c$ ] if and only if$$e\cdot d\equiv1\pmod{\lambda(n)}$$where $\lambda$ is the Carmichael function. That can be shown to follow from the definition of $\lambda(n)$ as the smallest strictly positive integer $y$ such that $m^y\equiv 1\pmod n$ for all $m\in\mathbb Z^*$. This holds regardless of the sign of $d$.

It follows that $t$ of step 1 of the question's algorithm is such that exists $k\in \mathbb Z$ with $t=k\cdot\lambda(n)$.

If the algorithm finds $f=1$ at the first execution of step 2, it thus holds $r\cdot k\cdot\lambda(n)+s\cdot e_1=1$, hence $s\cdot e_1=1+(-r\cdot k)\cdot \lambda(n)$, hence when the algorithm sets $d'_1=s$ in step 3 it holds $e_1\cdot d'_1\equiv1\pmod{\lambda(n)}$. Applying the first fact, $(e_1,d'_1)$ is a matching pair of RSA exponents for public modulus $n$. If we want $d'_1$ to be non-negative we can make $d'_1=s\bmod t$, which by definition is in range $[0,t)$ and also such that $e_1\cdot d'_1\equiv1\pmod{\lambda(n)}$.

Things get wrong when $f\ne1$ at the first execution of step 2. Often $s$ won't divides $t$ in step 4, preventing application of the algorithm as is. Example: $p=13$, $q=19$, $n=247$, $\varphi(n)=216$, $\lambda(n)=36$, $e_1=91$, $e_2=25$, $d_1=19$, $d_2=121$, $t=3024$, $r=-4$, $s=133$, $f=7$, $t/s=432/19\not\in\mathbb Z$.

Changing $t:=\frac t s$ to $t:=\frac t f$ in step 4 insures divisibility, and leaves the algorithm working. Argument: $f$ divides $e_1$, and $\gcd(e_1,\lambda(n))=1$, thus $f$ is coprime with $\lambda(n)$, thus we restart steps 2 with $t$ still a multiple of $\lambda(n)$.


Alternatively: given $(n,e_2,d_2)$ the adversary can factor $n$ (see this) and from that get $\hat{d_1}=e^{-1}\bmod\lambda(n)$ matching $(n,e_1)$, typically with $\hat{d_1}$ smaller/faster than $d'_1$; or get a working private key in the form allowing CRT operation thus even faster decryption or signature.

fgrieu
  • 140,762
  • 12
  • 307
  • 587