2

Does an SSL server randomly generate a temporary key pair for every client that connects?

I understand how public-key encryption works -- public encryption key, secret decryption key. That explains how a host with an SSL certificate can receive encrypted data from a client. But how does an SSL server send encrypted data back to the client?

Isaac Sutherland
  • 3,082
  • 4
  • 28
  • 37

1 Answers1

4

(There was a discussion on this topic in this question, although it was edited a number of times, so it may be confusing.)

The public key in the server certificate is only used during the handshake. During the handshake, the client and server negotiate a secret shared key (a new one for each session) that they use for the actual encryption.

How this secret is negotiated depends on the cipher suite: RSA or Diffie-Hellman key exchange. When using RSA key exchange, the client encrypts the pre-master-secret and sends it to the server (who is the only one able to decrypt it). When using DH, the client verifies the signature of the temporary parameters sent by the server during the DH exchange: the end result is also a shared pre-master-secret. This is then used with the exchanged random values by both parties to compute the master secret.

There are more details in the TLS specification section called "Handshake Protocol Overview".

Community
  • 1
  • 1
Bruno
  • 119,590
  • 31
  • 270
  • 376
  • Besides your correct answer that there is an SSL mode where the server even generates a new key pair for each client - it is called "SSL null auth" because it does not allow to authenticate the server. therefore it is by default disabled in all clients I know. – Robert Apr 13 '12 at 18:50
  • @Robert I guess you're talking about `DH_anon` cipher suites (the `TLS_NULL_WITH_NULL_NULL` is a different case). All TLS versions discourage their usage, but TLS 1.2 is more strongly worded ("*These cipher suites MUST NOT be used by TLS 1.2 implementations unless the application layer has specifically requested to allow anonymous key exchange.*"). Technically, the DHE cipher suites also generate new (DH) keys every time (even with RSA/DSS authentication). – Bruno Apr 13 '12 at 19:08