Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

If I have a private key of (43, 341), what would be the steps I need to take to decrypt a small message using RSA. I have looked online and everything seems very confusing. Any tips or advice would be helpful.

I have gotten this far

  1. p=31 q=11
  2. p*q=341
  3. O(n)=(31-1)(11-1)=300
  4. e=7
  5. (43*e)%300=1 e=7
  6. public key (e,n) (7,341)
  7. Private Key (d,n)(43,341)
  8. encryption of m=2 c=2^7%341=128
  9. decryption of c=128 m=128^3%341=2

what would be the next step i take to decrypt a message

share|improve this question
Is (43,341) a 2-tuple or the number 43,341? –  pg1989 Apr 17 at 19:44
Its the numbers 43 & 341 –  user3542714 Apr 17 at 19:45
Ok, that's a good start. The next step is to review what you know about RSA encryption. Do you understand how you encrypt a message using an RSA public key? –  pg1989 Apr 17 at 19:48
I have the algorithm to generate the public key and private keys from 2 long prime numbers but after generating the keys Im lost –  user3542714 Apr 17 at 19:53
Well there's your first step :) You have to understand encryption before you understand decryption hehe. Where are you getting lost with understanding encryption? Do you understand the math behind why we can use the public key to encrypt? –  pg1989 Apr 17 at 20:01
show 5 more comments

put on hold as unclear what you're asking by D.W., e-sushi, AFS, DrLecter, rath Apr 20 at 20:45

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

In step 9, you decrypted the ciphertext, 128, to the original message, 2. That's it. You're done with the toy example of naive RSA encryption/decryption.

Using RSA in real life, you would apply padding, such as OAEP (also known as PKCS#1v2), to your message before raising it to the e power modulo n.

If the plaintext you're trying to encrypt is quite short, say less than half as long as the RSA modulus, you might agree with the recipient to apply RSA directly to the message.

Normally the plaintext isn't that short. What you do is encrypt and MAC the plaintext with a symmetric cipher and MAC algorithm that you agree on with the recipient, using a randomly selected key for the symmetric cipher and a randomly selected key for the MAC. Then you use RSA with a 'message' consisting of the key to the symmetric cipher and the MAC key. You send your recipient all of (A) the RSA ciphertext, (B) the ciphertext from the symmetric cipher, and (C) the MAC. The recipient decrypts the RSA ciphertext (A), unpads it and obtains the keys for the symmetric cipher and the MAC. With those in hand, verifies the MAC (C) of the ciphertext (B) and finally decrypts the symmetric ciphertext (B) to obtain the plaintext.

share|improve this answer
add comment

You can check the freely available book Handbook of Applied Cryptography. Chapter 8.2 has a full description and example.

share|improve this answer
Please avoid link-only answers. The question was asked to get an explaining answer, not a link. After all, this is a Q&A site and not a search engine. Check the help center: ”How do I write a good answer? –  e-sushi Apr 18 at 2:39
@e-sushi There is whole chapter in book provided on exactly this question.Person who ask also did not provide any other relevant information's on RSA like e, and this necessaries are well explained in this relatively short chapter (6 pages). I posted this link, because I was able to write such program with examples in this book long time ago. –  ralu Apr 18 at 7:51
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  Gilles Apr 19 at 20:25
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.