A high level view of TLS/SSL

TLS and its meanwhile deprecated predecessor SSL are an evolving series of protocol versions that use various encryption algorithms to secure an individual connection between a client and a server. With regard to the OSI (Open Systems Interconnection) model, the TLS/SSL protocols are situated in the presentation layer. An important part of the protocol is the initial negotiation of encryption algorithms and methods that are to be used for the connection. This is also known as the SSL/TLS handshake. It allows a client and server with different capabilities to figure out, which protocol version, algorithms and methods to use in order to best comply with the given requirements.

The authentication of the communication partner during the TLS handshake is optional. Most commonly, only the client authenticates the server it connects to. With that, the client as connection initiator can rest assured to connect to the desired server and not to an imposter. Rarely, the server also authenticates the client as part of the TLS handshake. Often, client authentication is done by other means when the connection already is established and secured, for example, by requiring the user to provide some kind of user ID and password.

To encrypt the data transferred over a secure connection, the client and server must agree on an encryption key that they can use for the duration of the connection. As symmetric encryption is used, both communication partners must have the same encryption key and use it to encrypt data before sending it, as well as to decrypt received data. Obviously, this encryption key must remain a secret, shared only by the client and the server. Anybody else knowing this encryption key would be able to eavesdrop on the communication, decrypt the data and thus be able to read the clear text. Therefore, this agreement on a symmetric encryption key, only shared between client and server, must be done in a secure way - before the communication data can be encrypted.

This can be done by using asymmetric encryption for the transfer of the secret symmetric encryption key during the TLS handshake. Asymmetric encryption uses a pair of encryption keys. The public key is used to encrypt data. This data can be decrypted only with the corresponding private key of the pair. Usually, the server owns both keys and sends the public key to the client. As this key is not a secret,it can be sent without encrypting it. The client generates a random key as the symmetric key to be used for the connection. It encrypts this symmetric key using the public key received from the server and then sends this encrypted symmetric key to the server. The server decrypts the symmetric key using the private key. With that, both communication partners now are in possession of the same symmetric key and can subsequently use it to encrypt all the data sent over the connection. As only the server posses the private key, nobody apart from the server can decrypt the encrypted symmetric key sent from the client to the server. With that, the transfer of the symmetric key from the client to the server is secure.

The symmetric encryption is computationally much more efficient than asymmetric encryption. Therefore, the asymmetric encryption is only used for the secure transfer of the relatively small symmetric key itself during the TLS handshake. Then symmetric encryption can be used for the bulk of the data transferred between client and server for the duration of the connection