Urgent.News

What's breaking now, across thousands of outlets.

Tech

What Happens During a TLS Handshake?

Two machines that have never spoken before need to agree on a secret. They're communicating over a network where anyone can read every packet. And they need to pull this off in a few milliseconds, before you notice the page loading slowly. That's the TLS handshake. Every HTTPS connection starts with one. It's the reason your connections have a latency floor, and it's where most TLS…

During a TLS handshake, two machines need to agree on a shared secret in order to securely communicate over a network where anyone can read the packets. This process takes place before any actual data is transmitted and is crucial for maintaining security. The handshake ensures several key objectives are met: establishing a shared symmetric key, confirming the server's identity, and selecting the appropriate cryptography.

The TLS 1.3 handshake has been optimized to reduce the number of round trips required to complete the handshake from two to one. When a client initiates a connection, it sends a ClientHello message containing supported TLS versions, a list of cipher suites, and a key_share extension. The client makes a guess about which elliptic curve group the server will select and pre-sends its ephemeral public key for that group. Usually, the client's guess is correct.

Upon receiving the ServerHello, the server responds with its own key_share. At this point, both sides have enough information to compute the shared secret. Following this, any messages sent by the server are already encrypted. The client checks the server's certificate, verifies it, and sends its own Finished message. Once both the client and server have completed this process, application data can start flowing.

The ClientHello message plays a crucial role in achieving the optimized handshake by enabling the client to make an optimistic guess about the server's key exchange group. However, if the guess is incorrect, a HelloRetryRequest is sent, necessitating a second round trip to resend the connection with the correct group. This can bring the handshake back to the previous two round trip latency.

The ECDHE (Elliptic Curve Diffie-Hellman Ephemeral) key exchange mechanism is employed to generate a shared secret without actually transmitting it. Each side creates a throwaway key pair, and they exchange public halves in clear within the Hello messages. By combining their private half with the other side's public half, both sides arrive at the same shared secret. The attacker observing the public halves cannot compute the shared secret due to the one-way nature of elliptic curve multiplication.

This approach provides forward secrecy, meaning even if an attacker records encrypted traffic and later obtains the server's long-term private key, they cannot decrypt past sessions. This stands in contrast to older TLS versions that used RSA key transport, where an attacker with the private key could decrypt all previously recorded sessions.

TLS 1.3 has also deprecated several outdated security measures, including static RSA key transport, renegotiation, TLS compression, CBC-mode ciphers, RC4, and 3DES. The naming of cipher suites in TLS 1.3 has been simplified, with suites like TLS_AES_128_GCM_SHA256 indicating only the AEAD cipher and the hash function. The protocol has streamlined the key derivation process using HKDF (HMAC-based Key Derivation Function) to derive separate keys per direction and per purpose.

Lastly, TLS 1.3 introduced the ChangeCipherSpec message, which remains as a dummy message to maintain compatibility with older systems.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Monday 10 August →