Reputation: 31
So, I am pretty new to encryption in general but I need it for my Client-Server application, I've chosen RSA for this task. For the encryption of the packet data I use the client's public key and send the ciphertext to the server, now the server decrypts it with his private key and can read the message. My actual problem is: How do I encrypt data on the server side and send it back to the client? I've heard about a "secret key" which is somehow created from the clients and servers keys but I didn't really get the process. Seen it here. Do I just create another pair of keys and send the private key to the client this time or is there another way?
Upvotes: 0
Views: 147
Reputation: 61892
You have to understand the difference between symmetric and asymmetric encryption. In case of RSA, there are public and private keys. A symmetric block cipher such as AES takes only one key which both communicating parties need to have.
So the simplest way of communicating back would be to
This is of course only the most basic setup. In order to get Perfect Forward Secrecy, you need to use a Diffie-Hellman Key Exchange. AES encryption is also best done with an authenticated mode of operation such as GCM.
If you don't want to get a headache, use TLS.
Upvotes: 2