# RSA Attack with some known values

There is an RSA implementation which I need to attack to get the encrypted messages. Some of the values are known.

Plain text value for input. So if I enter a message, say it "A", the plain text is 4263178
if I enter a message, say it "B", the plain text is 4328714

N value and public exponent. I need to get the private exponent to decrypt the messages. I tried many things to get the private exponent but seems like I cannot get that.

Well, what I tried is that, I tried to figure out how the plain text value is calculated. When the input message is a single character, the following equation works.

plain text = 3338 + Ascii Code * 65536 ( I compared the plain texts to get this)

So for "A" plain text = 3338 + 65 * 65536

but when the number of characters more than 1, that doesnt work and I cannot find how it is calculated when there are 2 characters.

I read this article to understand how plain text is calculated. The article is clear but it does not fit the way my plain text is calculated.

Then, I wrote a small java program to attack the encryption by comparing the input plain text (because it is known) and the plain text equation where P = C^PK mode N (PK is the private exponent which I am trying to find). I put this formula in a loop and executed that from 0 - 10,000, but it didn't find the private exponent (my small java program works because I tested it with a known encryption scheme and extracted the private exponent).

Now, I cannot figure out a way about how to approach an attack for this encryption.

So again, the known values are

1. Plain text value for any input
2. N (modulus)
3. Public exponent
4. Cipher Text
5. Encrypted message

Now, how to get private exponent..?

Based on the example, my best guess is that the plaintext is expressed in ASCII and terminated with CR LF (the separator between lines on quite a few computer files); then converted to a number by considering the resulting bytestring a big-endian number. Notice CR LF is 0x0D 0x0A, 3338 == 0x0D0A, and 65536 == 0x10000 –  fgrieu Aug 30 '13 at 16:51