2

I am trying to do some homework to crack a small-RSA key. We are given the following:

Public Key: {e=49, n=10539750919}
Cipher Text: ITG!AAEXEX
Ascii Table: AEGIORTX!0
             1234567890

I am asked to crack the key and find the plain text.

I think I have a basic algorithm figured out. It looks like if I take p = Floor(Sqrt(n)) = 102663, then I can try to find a q using n = p*q by checking if (n mod p == 0). Once we find q, I can use the formula

d*e = 1 mod (p-1)(q-1)

to find d (private exponent). After this I have all I need to crack the key! (I think). The only thing I do not get is, how is the above equation to find d actually computed? Isn't 1 mod (p-1)(q-1) ALWAYS going to be 1? 1 mod anything is 1, so what am I doing wrong?

Matt Hintzke
  • 7,744
  • 16
  • 55
  • 113
  • 1
    I think you're misunderstanding the mathematical convention - `d*e = 1 mod (p-1)(q-1)` is equivalent to saying that `(d*e) % ((p-1)(q-1)) = 1`. And no, "1 mod anything" is not always 1. It could be -1 (if "anything" is negative, although there are conflicting conventions on this), or non-existent (if "anything" is 0). – twalberg Nov 26 '13 at 20:46
  • oh i forgot that the convention for modulus is weird like that.. Thanks a lot – Matt Hintzke Nov 26 '13 at 20:50
  • @twalberg Uh, the convention of modulus is not weird like that; but then `%` is the remainder, not the modulus. It's helpful to think about it as the remainder, as negative values are more compatible with the idea of a remainder. – Maarten Bodewes Nov 26 '13 at 21:18
  • @owlstead Yes, I should have perhaps said "conflicting conventions among programming languages", because that's what I was thinking of. The actual mathematical definition of modulus is somewhat more precise... – twalberg Nov 26 '13 at 21:38
  • @twalberg I kept making this mistake until I started to think of it as the remainder only. Now when I see this operator I think automatically of negative values. Mind you, as somebody that does applied crypto on a daily basis, I would really really really have liked it to be a modulus operator instead :) – Maarten Bodewes Nov 26 '13 at 21:43
  • I am having troubles factoring variables to solve for d using the equation `(d*e) % (p-1)(q-1) = 1`. How can the modulus be manipulated to get d on one side? – Matt Hintzke Nov 27 '13 at 00:37
  • 2
    Generally `d` is determined by applying the Extended Euclidian Algorithm (http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm), which allows you to find integers `x` and `y` such that `ax + by = gcd(a,b)`(Bézout's identity). Since `e` is chosen to be coprime to `(p-1)(q-1)`, we know that `gcd(e, (p-1)(q-1)) = 1`, so taking `a = e`, and `b = (p-1)(q-1)`, and running the algorithm gives us `x` which is the `d` we require. – Iridium Nov 27 '13 at 07:10
  • This question appears to be off-topic because it is about security or cryptography and doesn't include a programming problem. – Duncan Jones Nov 27 '13 at 08:22
  • Did you figure this out? I found p = 43,481 and q = 242,399 but got stuck after that....interesting problem :) – Joel Vroom Dec 03 '13 at 14:58
  • What is the Ascii table for and how is it to be used in decrypting this? – Joel Vroom Dec 03 '13 at 14:59

0 Answers0