6

In RSA, the $p$ and $q$ should be randomly generated, and they are the same size. The difference between $p$ and $q$ should not be small.

Suppose that $u=|p-q|<20$ and $p \times q =2189284635403183$. Find the values of $p$ and $q$.

I have no idea how to compute $p$ and $q$. I use calculator to compute square root of thr product. But it is definitely not correct as I get something ends with $2$. Can anyone help me?

Idonknow
  • 491
  • 8
  • 21
  • 1
  • Compute the square root of the product. 2) Go to the next odd number. 3) Test if division works. 4) If not, add 2 and repeat from step 3.
  • – CodesInChaos Oct 21 '14 at 08:42
  • 1
    If it exists $l$ such that $N + l^2$ is a square, say $t^2$, over the integers, you can factorize $N = (t-l) (t+l) $. Try to find that $l$. Call $p=t-l$ and $q=t+l$, if you compute the difference: $|p-q| = 2l$, so that give you a upper bound for your tests. – ddddavidee Oct 21 '14 at 08:48
  • It is correct that "The difference between $p$ and $q$ should not be small"; however, under the assumption that $p$ and $q$ are randomly seeded and appropriately large for cryptographic use, odds are entirely negligible that the difference between $p$ and $q$ is dangerously small. So much that the (often mandated) check that$|p-q|$ is above some limit really is useful only as an additional check that said assumptions hold, and to reassure those who do not trust math. – fgrieu Oct 21 '14 at 16:30