2
votes

I'm using Raw RSA encryption and decryption. tutorial and Raw RSA from the Crypto++ wiki to develop a simple code that encrypt/decrypt string using RSA using Crypto++.

I'm using Visual studio 2010. The code run without error. But, I don't understand what is the significant of n, e, d ? Why can't I change it?

I respected the algorithm of RSA and I chose this value:

    // La clé publique est la paire (e, n) et la clé secrète est d, donc aussi p et q.
    // p = 3, q = 11, n = 3 x 11, f = (11–1).(3–1) = 20. On choisit d=7 (7 et 20 sont bien premiers entre eux).
    // e = 3 car e.d= 20 * 1 + 1

But always I have debug error: enter image description hereenter image description here

Can someone help me ?

1
stackoverflow.com/a/20114154/179910 covers some of the basic idea of how RSA works and the uses of the numbers you need to give it. - Jerry Coffin
The tutorial from JacobHacker just rips Crypto++'s work without attribution. You should probably avoid JacobHacker's stuff and stick with the Crypto++ wiki. - jww
"The code run without error... But always I have debug error" - well, which is it? If there is an error, please post it with the question. - jww
without error: when I run the code as published with error: when I chage the value of n, e and d - xtensa1408
Raw, or "textbook" RSA is insecure. You should be padding your plaintext, unless this is an exercise and you are not worried about security. - Jim Flood

1 Answers

0
votes
 // p = 3, q = 11, n = 3 x 11, f = (11–1).(3–1) = 20. On choisit d=7
 //    (7 et 20 sont bien premiers entre eux).
 // e = 3 car e.d= 20 * 1 + 1

These parameters are artificially small. Probably too small.

One of the properties of RSA is the message size must be smaller than the modulus size. 3x11 = 33, and that's 25 (give or take). So your message must be smaller than 5 bits.

Crypto++ specifies messages sizes in bytes, not bits. So you will likely never be able to encrypt anything under the modulus of 33.

Unfortunately, the cited wiki page does not discuss that size_in_bits(message) < size_in_bits(modulus). And I can't change it at the moment because Crypto++ is broken for writes (reads are OK).

Also, here's from rsa.cpp:

if (modulusSize < 16)
  throw InvalidArgument("InvertibleRSAFunction: specified modulus size is too small");

So you should probably specify a modulus at least 216 in size. 216 is 65536.

Finally, until we see the relevant parts of your program and error message, this is just speculation.