16 March 2025
TLS is a protocol that handles all practical aspects required for establishing a secure communication between two entities. TLS deprecates the older SSL (Secure Socket Layer) protocol . However the term SSL is still used by laymen to refer to TLS
TLS Versions : TLS 1.0, TLS 1.1, TLS 1.2 , TLS 1.3
TLS provides encryption, authentication and integrity (detect tampered messages with message authentication code)
TLS can be used with many application protocols to provide encryption and authentication using certificates . A common use case is with HTTPS.
HTTPS includes multiple protocols that works in tandem:
The process starts with TCP 3 way handshake (SYN, SYNC+ACK, ACK) to establish a TCP connection. This is often quick and happens within 60 to 70ms. Once the TCP connection between client and server is established , then TLS 1.2 protocol kicks in which could take some 140 to 150ms:
From this point onwards the session key (symmetric key) is used to encrypt all communication between server and client. So the server and client can now move on to use HTTP encrypted with session key (ie HTTPS)
TLS 1.2 message exchanges are inefficient at scale. TLS 1.3 protocol brings in several enhancements to TLS 1.2 . One important improvement in TLS 1.3 is the number of roundtrips required for handshake is reduced from two in to one.
TLS 1.3 operates in 1 RTT mode most of the time where the handshake is complete in 1 round trip. This is different from TLS 1.2 which needed 2 round trip.
TLS 1.3 has a simpler cipher negotiation model and a reduced set of key agreement options. As there is limited set of choices, the client can simply choose to send DH key shares in the first message instead of waiting until the server has confirmed which key shares it is willing to support. That way, the server can learn the shared secret and send encrypted data one round trip earlier.
TLS 1.3 supports both 1 RTT and a new Zero Round Trip Resumption (0 RTT) mechanism added in. 0 RTT helps clients to transfer data to servers without having to wait for the handshake to be finished. Overall RTT time is reduced by storing some of the session parameters in server avoiding the need of a round trip when the client connect to server second time onwards. On the negative side it reduces forward secrecy by allowing to decrypt older messages using same session key used in a later sesson. This is not easy to achieve though.
TLS 1.2 is an improvement over TLS 1.1 in 2008.
TLS uses two sub protocols:
Handshake protocol is responsible for authentication, key exchange, and negotiation of security parameters.
RSA Handshake- client generates a symmetric key and then the client encrypts it with the server’s public key and shares across. RSA is getting obsolete since if the private key is leaked out, all older messages can be decrypted.
Diffie-Hellman handshake - Client and Server derives the key without sending it through communication channel. So leaking private key cannot be used to retrieve previous communication and thus maintains forward secrecy.
Record protocol is responsible for encryption application data using symmetric key generated with Handshake protocol. Message Integrity Checks are performed on each record to make sure that data is not tampered.
Record size:
Application data is transmitted in record protocol and the maximum allowed size is 16 KB. Record header may take between 20 to 40 bytes on top of TCP header requirements. Framing overhead reduces as the record size grows. But if the lager record is split into multiple TCP packets, there will be more wait time for packets to arrive contributing to larger latency. It is possible to configure the maximum record size to use
TLS session has a session identifier which is sent as part of Server Hello message. Using session ID, the client can re-use the session parameters. This helps to reduce the handshake messages next time, by reusing previous session parameters.
A key exchange algorithm allows two parties to securely establish a shared secret, even over an untrusted network. This shared secret is later used for symmetric encryption (like AES).
The certificate contains a public key, which is used as part of the key exchange process.The type of public key (RSA, ECDSA, etc.) determines what kind of key exchange is possible
Key exchange algorithm is part of the TLS protocol, not directly a field in the X.509 certificate. The certificate only defines what kind of keys (RSA, EC) are available, which constrains which key exchange algorithms can be used
Choosing key exchange algorithm: During a TLS handshake, the client and server negotiate:
This shows it's an Elliptic Curve key, which would support ECDHE key exchange. But it does not explicitly say "ECDHE" — that's determined at protocol level (TLS), not in the certificate.
Common Key Exchange Algorithms (Used in TLS with Certificates)
Let us take an example of a cipher suite TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256. Below given is the breakup:
Datagram Transport Layer Security is often used for VoIP, video streaming, and gaming scenarios where unreliable delivery is acceptable. It is built on top of UDP. TLS cannot be implemented on top of UDP since datagrams may be lost, and reordered. TLS does not allow packets to be decrypted independently, but you can do it for DTLS. A key feature of DTLS is prevention of the denial of service using cookies. This allows to communicate without showing real IP address. During DTLS 1.3 session resumption, a server can send a "cookie" to a client . Client sends this cookie during the resumption attempt. It prevents flooding the server from fake IP address. DTLS handshake is made reliable at protocol level modification measures like retransmission. DTLS packet include data structures for detecting record packet ordering and duplicate packets. This ensures that data arrives in the correct order even if packets are lost or arrive out of sequence.
DTLS is derived from TLS, so many of the security mechanisms and algorithms are the same for DTLS
EAP-TLS is an authentication method that uses the TLS protocol within the EAP framework. It is used to securely authenticate users/devices before granting access to a network.