Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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..?

any suggestions please?

share|improve this question
RSA, in any of its variants, is such that random or even chosen plaintext/ciphertext pairs are of no help to get a private exponent, as far as we know. Your best option to get one private exponent (out of several possible) is to factor the public modulus N. Likely your assignment is to find the plaintext by another mean. If there is no random padding, that at least allows you to verify a guess of the plaintext. Primitive paddings may enable other attacks. See in particular this – fgrieu Aug 30 '13 at 10:37
You have several questions mixed in here ... first is the processing of plain text (in the form of a characer stream) into a number (which is the plain text input of the RSA encryption scheme), the second one is "How can I break RSA?". – PaĆ­lo Ebermann Aug 30 '13 at 16:11
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.