Is it possible to encrypt the data by sender's private key and again encrypt it with receiver's public key by using RSA algorithm at sender end.How decryption is done at receiver's end?

  • $\begingroup$ It's not clear what you ask for. What key do you want to encrypt? Who should be able to decrypt it? What are other constraints there? What is your overall goal here? $\endgroup$ – Przemko Robakowski Jan 18 '18 at 10:02
  • $\begingroup$ I have to encrypt data to ensure confidentiality as well as authentication.My question is that can we encrypt data by sender's private key first and again encrypt it with receiver's public key? $\endgroup$ – Jaya Jan 18 '18 at 10:18
  • $\begingroup$ @Jaya: encryption (especially asymmetric) does not ensure authentication. Do you want to sign then encrypt? Are you aware that RSA requires appropriate padding, and a different one for encryption and signature? $\endgroup$ – fgrieu Jan 18 '18 at 11:51

It doesn't make much sense to "encrypt" with your private key, I suspect what you want to do is sign with a private key, which for RSA is essentially the same operation. You definitely can sign a message with your private RSA key and then encrypt it with the recipients RSA public key. This is even common. Obviously you want to use proper padding (e.g OAEP)

Note you can do this in either order, sign and encrypt or encrypt and sign. Note public key operations are cheaper computationally compared to private key operations. If you encrypt and sign we can verify cheaply and not waste time decrypting unverified messages. If you sign and encrypt you can hide you identity If this is relevant.

| improve this answer | |
  • 1
    $\begingroup$ Note: RSA(ES)-OAEP won't let one encrypt a sizable message in one go, much less one that includes an RSA signature (as necessary to hide one'd ID from all but the intended recipient, as considered in the answer), assuming the modulus size for signature and encryption are comparable. Use of hybrid encryption or splitting the data for encryption is necessary. Addition: for the security proofs to hold, one should have separate key pairs for signature and encryption. $\endgroup$ – fgrieu Jan 18 '18 at 11:47
  • $\begingroup$ In the past it was recommended to not use the same key for signing and decryption but with proper randomized padding this isn't really necessary. Regardless the question had two key pairs, one for the sender used for signing and one for the receiver used for decryption. I didn't go in to the details of proper use of RSA for signing or encrypting sizeable messages. $\endgroup$ – Meir Maor Jan 18 '18 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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