Follow
Subscribe via Email!

Enter your email address to subscribe to this platform and receive notifications of new posts by email.

TLS Handshake: How Browsers and Servers Negotiate Keys

The TLS handshake enables a client and server to verify identities, choose cipher suites, and derive symmetric keys for private network communication.
Abstract geometric diamonds with an overlaying zig-zag line graphic against a blue background

During a tls handshake, a web client and server set up a safe data path before sending application traffic by verifying mutual identities and deriving secret symmetric encryption keys. The two hosts verify identities with digital certs, pick mutually supported cipher modes, and calculate matching secret keys through mathematical algorithms without exposing the shared secret over the wire. Once finished, the channel stops network eavesdropping, packet tampering, and message forgery over public links [8]. Because symmetric ciphers need far less CPU power than public-key tools, the protocol limits asymmetric math strictly to setup steps.

What Happens During a TLS Handshake?

When a user navigates to an online address, the web browser initiates an underlying transmission control protocol stream before requesting encryption to safeguard subsequent data exchanges. How do two distant machines agree on private keys across an open wire without leaks? They talk over a set port. Plain HTTP moves over Port 80, but safe HTTPS uses Port 443 [5].

The core design of Transport Layer Security separates tasks between two key parts to keep network traffic safe. S. Turner reviewed this framework in IEEE Internet Computing, showing how the setup protocol works side by side with the record protocol to secure links against tampering. The setup flow checks host identity and builds matching keys. Once both sides share those keys, the record layer splits data into blocks, adds integrity tags, and locks each chunk with the negotiated symmetric ciphers [8]. Early network work began in 1986 with the Secure Data Network System (SDNS) project run by the National Security Agency and NBS. That project led to SP4 and the TLSP standard under ITU-T X.274, creating early foundations for modern Internet transport security [5].

Netscape Communications built SSL in the mid-1990s for Netscape Navigator, guided by chief scientist Taher Elgamal. In 1993, Simon Lam at UT-Austin created Secure Network Programming (SNP), earning the 2004 ACM Software System Award. Netscape revised SSL 2.0 and SSL 3.0 before the IETF standardized TLS 1.0 in 1999 [5]. In RFC 8446, E. Rescorla updated the standard to TLS 1.3, making sure that all handshake records following the initial server greeting remain completely encrypted against eavesdropping observers [2].

Title banner of RFC 8446 defining TLS version 1.3
RFC 8446 outlines the core specification and state machine for version 1.3 of the transport security protocol. (Credit: RFC Editor)

ClientHello and ServerHello Parameters

The exchange begins when the browser transmits a structured ClientHello record that presents its cryptographic capabilities alongside a list of supported protocol versions and cipher suites. The message carries a thirty-two-byte random string, supported protocol versions, and a list of cipher suites. In TLS 1.3, the client sends key share data inside the opening packet, guessing which curve the host prefers. This forward guess lets both sides skip an entire network round trip, cutting connection setup delay in half [2]. The client can also supply a Server Name Indication (SNI) tag to name the target virtual host, helping multi-tenant web servers pick the right identity certificate before presenting security parameters [5].

The server reads the client list and answers with a ServerHello record. It picks one cipher suite from the offered choices and returns its own thirty-two-byte random string. If the client did not send a matching key share, the server returns a HelloRetryRequest. That step prompts the client to resend a proper share [2].

Moving from TLS 1.2 under RFC 5246 to TLS 1.3 under RFC 8446 simplified cipher suites by stripping out legacy algorithms and separating key exchange mechanisms from record encryption [2]. Earlier setups combined key trade formulas, signature types, bulk ciphers, and hash modes into lengthy names like TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 [3]. In contrast, TLS 1.3 only supports Authenticated Encryption with Associated Data (AEAD) ciphers. The new cipher suite names specify only the bulk symmetric cipher and the HKDF hash function, leaving key agreement methods to distinct extension fields within the handshake [2].

Authentication and Digital Certificates

Identity checks prevent attackers from posing as legitimate websites and intercepting private user communications. Web servers prove their identity by sending X.509 certificates issued by public Certificate Authorities. These digital credentials link the host domain name directly to a verified public key. The browser inspects the certificate chain, verifying digital signatures back to an installed root trust store. If a cert has expired, names the wrong domain, or lacks a valid signature from a trusted issuer, the browser halts setup and alerts the user [5]. In RFC 8446, certificate messages are encrypted using keys derived from early handshake secrets, hiding the server identity and certificate parameters from eavesdroppers monitoring the network link [2].

Next, the server must prove it holds the private key matching the public certificate. In the CertificateVerify message, the server signs a hash of all prior handshake packets using RSA or ECDSA. Because the hash contains client and server nonces, an eavesdropper cannot capture and replay this proof [2].

Repository card for PyDTLS datagram security library
PyDTLS provides Python implementations of datagram security standards over UDP sockets. (Credit: GitHub)

Digital certs play a central role in keeping online commerce safe. In International Journal of Scientific Research and Management, L. W. Wakoli pointed out that robust SSL/TLS certs protect customer data and payment records in online stores. Without strong mutual trust between browsers and retail servers, shoppers face fraud, data theft, and site spoofing. Validating credentials ensures that transactions reach real merchants rather than criminal proxies [12].

Key Exchange in TLS 1.3

Why did protocol architects remove static RSA key exchange from TLS 1.3? In older setups, clients encrypted a PreMasterSecret with the server public key. Anyone recording past traffic could decrypt the entire session if the server private key were compromised years later, exposing sensitive user records to retroactively decrypted inspection [5]. TLS 1.3 enforces forward secrecy by requiring ephemeral Diffie-Hellman keys [2].

Ephemeral key exchange relies on Elliptic Curve Diffie-Hellman (ECDH) math to create matching secrets without sending them across the wire. In draft-peck-suiteb-dtls-srtp-02, M. Peck from The MITRE Corporation and K. Igoe from the National Security Agency detailed Suite B profiles using NIST curves P-256 and P-384. Each side creates an ephemeral key pair and trades the public point. By multiplying its own private number by the peer’s public coordinate, each side derives an identical premaster secret. Under curve P-256, this secret is 32 bytes long, while curve P-384 creates a 48-byte secret. Both peers wipe their private ephemeral keys from RAM as soon as the shared secret is computed [3].

The shared secret feeds into the HKDF key schedule defined in RFC 8446. This process extracts and expands secrets, generating unique keys and IVs for client and server traffic. To seal the negotiation, both sides transmit a Finished message containing an HMAC authentication tag computed over the entire record transcript exchanged since the start of the handshake. Verifying the Finished tag ensures nobody altered messages in transit [2]. Once both sides verify Finished messages, the setup ends and encrypted app data flows freely.

Header card of the Python Package Index repository for tls handshake libraries
The Python Package Index hosts cryptographic modules that implement transport encryption. (Credit: PyPI)

How Session Resumption Speeds Up Reconnection

Setting up a fresh TLS connection takes time and CPU resources. To speed up repeat connections, TLS 1.3 replaced older RFC 5077 tickets with an updated Pre-Shared Key (PSK) flow that enables session resumption without repeating certificate checks. After a link is set up, the server can issue a NewSessionTicket packet containing a ticket value. When returning to that host, the client presents the ticket in its ClientHello message. If the host accepts it, both sides compute new session keys without exchanging certs again [2].

PSK resumption makes an optional mode called 0-RTT (zero round-trip time) possible. In this mode, the client sends encrypted early app data in its very first flight alongside the ClientHello packet. This skips connection setup delay entirely, letting web pages load much faster on repeat visits. However, early data introduces distinct security trade-offs because it does not provide forward secrecy and remains susceptible to replay attacks by adversaries who intercept the initial datagram. RFC 8446 warns that attackers who capture 0-RTT traffic can resend it to the server. Web servers defend against this by recording ClientHello nonces or enforcing single-use tickets [2].

Handshake speed matters deeply in low-power wireless networks. In Sensors, T. Claeys, M. Vučinić, T. Watteyne, F. S. Rousseau, and B. Tourancheau tested handshake delays in 6TiSCH IoT mesh networks using OpenWSN on OpenMote hardware. Their tests showed that round-trip overhead heavily impacts device battery life, proving why streamlined handshakes help constrained hardware [11].

TLS Handshake: How Browsers and Servers Negotiate Keys — rfc-editor.org image
(Credit: rfc-editor.org)

TLS Handshake Defenses Against Splicing Attacks

Flaws in handshake logic can ruin transport security. In 2009, M. Ray exposed a severe gap in TLS renegotiation. An attacker could open a TLS link to a server, send preliminary HTTP commands, and then splice in an honest client connection before the target host noticed. The server mistook the client handshake for a renegotiation on the same session. As a result, the server executed the attacker’s injected commands under the client’s authenticated identity. This attack hit web servers that did not clear state between renegotiated handshakes, putting sensitive passwords and cookies at serious risk [1].

The IETF fixed this flaw by publishing RFC 5746, written by E. Rescorla, M. Ray, S. Dispensa of PhoneFactor, and N. Oskov of Microsoft in February 2010 (ISSN 2070-1721). Under Section 3.1 and Section 3.2, the document defines the renegotiation_info extension to tie new handshakes cryptographically to old sessions. Clients send a 12-byte client_verify_data value, while servers return a 24-byte concatenation of both verify blocks (or 36 and 72 bytes in SSLv3). For older hosts that reject new extension tags, RFC 5746 added the TLS_EMPTY_RENEGOTIATION_INFO_SCSV cipher value {0x00, 0xFF} [1].

To guard against cipher failures, A. Joaquim, M. L. Pardal, and M. P. Correia proposed vtTLS in 2018. Their design combines k cipher suites together, keeping sessions safe if one cipher breaks. Redundant ciphers protect user links during slow software patch rollouts [10].

Datagram Transport with DTLS Mechanics

Standard TLS assumes an underlying reliable TCP byte stream, but latency-sensitive applications like voice calls, video streaming, and online gaming rely on the User Datagram Protocol. Because UDP does not guarantee packet delivery or order, standard TLS fails over datagrams. A lost packet desynchronizes the sequence counter and breaks decryption. To fix this, RFC 9147 defines DTLS 1.3, written by E. Rescorla, H. Tschofenig of Arm Limited, and N. Modadugu of Google. DTLS 1.3 obsoletes RFC 6347 and is updated by RFC 9853 [4].

DTLS resolves packet loss and network reordering by assigning explicit sequence numbers to each handshake message and managing retransmission timers to re-send missing message flights. If a packet vanishes, the timer expires and the sender retransmits the flight. To prevent denial-of-service reflection attacks where attackers spoof source IP addresses, DTLS servers enforce a cookie exchange via HelloRetryRequest. The server stays stateless until the client returns the cookie, verifying its real IP address [4]. DTLS powers VPN tools like Cisco AnyConnect, OpenConnect, Cato Networks, ZScaler, F5 Networks Edge VPN, and Citrix Systems NetScaler [6]. In mobile wireless history, WAP used Wireless Transport Layer Security (WTLS) between WTP and WDP, but gateway decryption flaws pushed industry to end-to-end TLS [7].

Official logo banner of the Internet Engineering Task Force
The Internet Engineering Task Force oversees open networking standards and security specifications. (Credit: IETF Datatracker)

Developers use libraries like PyDTLS and python3-dtls to wrap UDP sockets using OpenSSL through ctypes [5, 6]. PyDTLS works on Ubuntu 12.04 LTS and Windows with msvcr90.dll. On Linux, the osnet demux routes traffic, while Windows uses a router socket to bypass OS binding limits [5].

TLS Handshake Evolution for Quantum Networks

The emergence of quantum computers threatens classical public-key cryptography because Shor’s algorithm can efficiently solve discrete logarithms and factor large integers used in modern encryption. While symmetric ciphers like AES-256 remain solid, asymmetric key exchange using Diffie-Hellman or RSA will become easy to break [9]. Attackers can record encrypted sessions today and decrypt them once quantum computers arrive, an attack called harvest-now, decrypt-later [5]. In Computer Communications, C. R. García, S. Rommel, S. Takarabt, J. J. V. Olmos, S. Guilley, P. E. Nguyen, and I. T. Monroy studied hybrid defenses combining Quantum Key Distribution (QKD) and post-quantum cryptography (PQC). Their tests showed that combining classical and quantum-safe algorithms inside TLS stops quantum snooping without heavy processing penalties [9].

C. R. García and team implemented Concatenation and XOR methods to merge QKD and PQC keys into TLS session secrets. These hybrid methods combine multiple keys into one traffic secret. Even if an attacker cracks one key method, the session stays secure [9].

Standards bodies turned post-quantum theory into real code. In August 2024, NIST published FIPS 203, standardizing the ML-KEM lattice mechanism. The IETF defined hybrid groups including X25519MLKEM768, SecP256r1MLKEM768, and SecP384r1MLKEM1024. Google Chrome turned on X25519MLKEM768 by default in version 131 in November 2024, and Firefox added it in version 132. With support in OpenSSL 3.5, BoringSSL, and Cloudflare, these hybrid groups prove that transport security continues to evolve to protect open communications against future quantum computing attacks [5].

Sources
  1. REPORT Rescorla, E., Ray, M., Dispensa, S., & Oskov, N. (2010). Transport Layer Security (TLS) Renegotiation Indication Extension (RFC 5746). [Article Link]
  2. REPORT Rescorla, E. (2018). The Transport Layer Security (TLS) Protocol Version 1.3 (RFC 8446). [Article Link]
  3. REPORT Peck, M., & Igoe, K. (2012). Suite B Profile for Datagram Transport Layer Security / Secure Real-time Transport Protocol (DTLS-SRTP) (draft-peck-suiteb-dtls-srtp-02). [Article Link]
  4. REPORT Rescorla, E., Tschofenig, H., & Modadugu, N. (2022). The Datagram Transport Layer Security (DTLS) Protocol Version 1.3 (RFC 9147). [Article Link]
  5. WEBSITE Transport Layer Security. (n.d.). In Wikipedia. [Article Link]
  6. WEBSITE Datagram Transport Layer Security. (n.d.). In Wikipedia. [Article Link]
  7. WEBSITE Wireless Transport Layer Security. (n.d.). In Wikipedia. [Article Link]
  8. ACADEMIC JOURNAL Turner, S. (2014). Transport Layer Security. IEEE Internet Computing, 18(6), 60-63. [Article Link]
  9. ACADEMIC JOURNAL García, C. R., Rommel, S., Takarabt, S., Olmos, J. J. V., Guilley, S., Nguyen, P. E., & Monroy, I. T. (2023). Quantum-resistant Transport Layer Security. Computer Communications, 213, 345-358. [Article Link]
  10. ACADEMIC JOURNAL Joaquim, A., Pardal, M. L., & Correia, M. P. (2018). Vulnerability-Tolerant Transport Layer Security. DROPS (Schloss Dagstuhl – Leibniz Center for Informatics). [Article Link]
  11. ACADEMIC JOURNAL Claeys, T., Vučinić, M., Watteyne, T., Rousseau, F. S., & Tourancheau, B. (2021). Performance of the Transport Layer Security Handshake Over 6TiSCH. Sensors, 21(6), 2192. [Article Link]
  12. ACADEMIC JOURNAL Wakoli, L. W. (2024). Secure Sockets Layer/Transport Layer Security for E-Commerce. International Journal of Scientific Research and Management (IJSRM), 12(12), 8047-8052. [Article Link]
Leave a Comment

Related Posts
Total
0
Share