I'm working on a CTF. The challenge is to get the contents of an encrypted message given the ciphertext and the 2048-bit RSA public key. I did finally get the flag after a few hours, but I'm still not sure why the first step worked.

The first step -- factor n into its two prime factors is from what I can tell, not supposed to be feasible, but it was done in about 1 second on this website. Why was it so easy?



That number was so quick to factor because its factors are extremely close together, i.e., it factors as $\left(\lfloor\sqrt{n}\rfloor + 70\right)\left(\lfloor\sqrt{n}\rfloor - 68\right)$.

Some algorithms, like Fermat's, which work best the closer together the factors are, will find this factorization instantly.

  • $\begingroup$ ohh, I see thank you. I thought maybe it was something like n was 2^2048-1, or maybe there was some type of factoring rainbow table, but that makes more sense $\endgroup$ Jun 5 at 2:06
  • 11
    $\begingroup$ @rainbowkitty227 Rainbow tables aren't relevant to integer factorization. $\endgroup$
    – forest
    Jun 5 at 2:07
  • 8
    $\begingroup$ Ryan Sheasby wrote two good articles describing what rainbow tables actually are (and why they're usually useless these days): rsheasby.medium.com/… and rsheasby.medium.com/… $\endgroup$ Jun 5 at 2:25
  • 7
    $\begingroup$ In particular, the site uses a quadratic sieve which is like an extension to Fermat's method. $\endgroup$
    – qwr
    Jun 5 at 8:54
  • 10
    $\begingroup$ IOW, the puzzle designers picked this specific number, just like textbook authors pick nice round numbers. $\endgroup$
    – RonJohn
    Jun 5 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.