I want to know if encryption with RSA public key provides confidentiality and integrity. I'm quite sure that it provides confidentiality but I have concerns about integrity. If an attacker would scramble ciphertext what would be the result I get? Do I need to put some kind of MAC at the end of messages before encryption?

If I have to be more specific about my problem, I want to use RSA for sending tiny requests to a server. I am thinking of encrypting requests with server's public key. Server will also know my public key and send back responses encrypted with my public key. I'm not sure if I'm using these correctly since I'm a beginner in these topics.

Any help would be appreciated.

  • $\begingroup$ I want to use RSA for sending tiny requests to a server and normal TLS/SSL is not enough? And integrity of RSA can be achieved with checking the padding (I hope someone will write something more specific) $\endgroup$
    – gusto2
    Dec 13, 2017 at 11:13
  • $\begingroup$ I did not analyze this problem by time efficiency but I'm using non-persistent connections to send and receive request and responses. I'm guessing establishing SSL connections would not be more efficient than RSA. $\endgroup$ Dec 13, 2017 at 11:21
  • $\begingroup$ TSL is not an encryption scheme. It is a standardized protocol, for which a lot of proper implementations exist. RSA is an option in a cipher suite. Maybe you should state in which context you are planning to use this and what kind of software this is. $\endgroup$
    – tylo
    Dec 13, 2017 at 12:28
  • $\begingroup$ I'm developing a simple software for chatting in local area network. There will be a server which keeps public keys and addresses of users. I will use TLS protocol between users. But I'm unsure about what to use between users and server. $\endgroup$ Dec 13, 2017 at 12:50
  • $\begingroup$ Is this a product you are planning on selling or just for fun? $\endgroup$
    – mikeazo
    Dec 13, 2017 at 13:23

1 Answer 1


Properly done encryption with the RSA public key of the server provides confidentiality of the request, but not integrity or proof of origin (anyone can forge a request with any desired content).

There must be some secret on the sender's side to prove integrity. That can be an RSA private key used for RSA signature (with sender public keys known to the server either by transmission over a channel with integrity, or by way of a digital certificate). Other signature schemes also work (DSA, ECDSA..).

Symmetric crypto also works for integrity, if it is acceptable that the server holds the client's secrets (or a master key allowing the server to re-compute the secrets of all clients).

Symmetric crypto can provide both integrity and confidentiality (e.g. Salsa20-Poly1305 per RFC 7539), but asymmetric encryption has a superiority: the confidentiality that it offers does not depend on the client's ability to keep a key secret on the long run; only integrity does.

  • 2
    $\begingroup$ ... the confidentiality of asymmetric encryption does however rely on the public key being trusted; in a typical web context this confidentiality can only be offered by a TLS connection, possibly combined with local storage. Oh, and don't forget "little" things like the Bleichenbacher style attacks on PKCS#1 v1.5 encryption. $\endgroup$
    – Maarten Bodewes
    Dec 13, 2017 at 13:43
  • $\begingroup$ @MaartenBodewes: Yes. More generally, confidentiality relies heavilly on integrity of the code and data on the client. A sub-$1 ROM-masked CPU is a good way to get that, and it can do RSA encryption. $\endgroup$
    – fgrieu
    Dec 13, 2017 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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