0

I'm trying to get a message out of an RSA code, but cant seem to understand how. The formula i'm trying to use to find the message is: c^d mod n. In the text file i received (which is the RSA code), i have 3 parameters:

The c parameter:

c=62094327354293714871337806608043143339672711375275261525243238242322194473023610842261452370807533140129255594935713596899492336925573500404508972313463258470764117200138784924348362580128423518572743446058119722861164424364186271770831857887818550880280385895469933434901508250872871673722739401583613920865

the N parameter:

N=102518413348128616948064302091615267327586561544914497024946023154172320251650248158262401038211060025769143033483116931749752882566368072181993447378932810603880706573407783516535716219705301632360773290434984792276962906314924125193872533986871367036809927042370179209563059349511562287725586162360516841779

and the d parameter:

d=90575112832191634931822012293951618304193311969935139031973154594700485026947413962490036848108653090804963912366135718482295366073482828257042351498160831683665400283336482471506944874247073018050011183570224881323949477869741822928092177900190031155493051065073868895195339892585741809998466654281718606993

Now the problem is that the numbers are WAY too long (308 digits long, and the N parameter is 309 digits long). I couldn't find any calculator that can calculate c^d so far.

any help?

afterm3
  • 69
  • 1
  • 5
  • 1
    many languages have easy-to-use support for arbitrary sized integers. For example with python you can solve your problem in about 5 lines of code. – President James K. Polk Feb 06 '19 at 16:06
  • Although you can't simply exponentiate then mod (even in python); you need to reduce _while_ exponentiating, called modexp or modpow in some langs or libs, but python uses 3-arg pow; see https://stackoverflow.com/questions/5246856/how-did-python-implement-the-built-in-function-pow . Also 'textbook' (unpadded) RSA like you have here is not secure and should never be used except as a throwaway toy or homework, but security issues don't belong in SO. – dave_thompson_085 Feb 06 '19 at 16:51

1 Answers1

0

You can do that with java using math.BigInteger

          BigInteger c = new BigInteger("62094327354293714871337806608043143339672711375275261525243238242322194473023610842261452370807533140129255594935713596899492336925573500404508972313463258470764117200138784924348362580128423518572743446058119722861164424364186271770831857887818550880280385895469933434901508250872871673722739401583613920865");
          BigInteger N = new BigInteger("102518413348128616948064302091615267327586561544914497024946023154172320251650248158262401038211060025769143033483116931749752882566368072181993447378932810603880706573407783516535716219705301632360773290434984792276962906314924125193872533986871367036809927042370179209563059349511562287725586162360516841779");
          BigInteger d = new BigInteger("90575112832191634931822012293951618304193311969935139031973154594700485026947413962490036848108653090804963912366135718482295366073482828257042351498160831683665400283336482471506944874247073018050011183570224881323949477869741822928092177900190031155493051065073868895195339892585741809998466654281718606993");
          BigInteger m = new BigInteger("1");
          m = c.modPow(d, N);
          System.out.println(m);

And the result would be

12095051301478169748702315942951183566712581822646196016924926165965065297342257