Back to Blog
NetworkingSecurityCryptographyTLSDevOpsInfrastructure

TLS 1.3 Mechanics: Handshake Optimization, Key Exchange, and Transport Security

Written by Dev Toolkit Editorial
•
July 15, 2026
•16 MIN READ

Explore the internal architecture of TLS 1.3 (RFC 8446). Learn how 1-RTT handshakes, 0-RTT PSK resumption, ECDHE key exchange, AEAD cipher suites, and Encrypted Client Hello (ECH) optimize speed and security.

In modern internet architecture, Transport Layer Security (TLS) serves as the foundational cryptographic protocol for securing web traffic, microservice gRPC calls, database connections, and API communication. Defined in RFC 8446, TLS 1.3 represents a ground-up redesign of the protocol, discarding decades of legacy cryptographic baggage accumulated since SSL 2.0.

While TLS 1.2 required complex multi-round-trip negotiations and permitted risky cryptographic options, TLS 1.3 delivers a streamlined protocol that reduces connection latency by 50 percent while enforcing mandatory Perfect Forward Secrecy (PFS).

In this deep dive, we examine the core internal mechanics of TLS 1.3: 1-RTT and 0-RTT handshake flows, ephemeral key exchange algorithms, authenticated encryption with associated data (AEAD), Encrypted Client Hello (ECH), and anti-replay mitigations.


1. Protocol Evolution: Why TLS 1.3 Redesigned the Handshake

Prior to RFC 8446, TLS 1.2 (RFC 5246) operated with significant architectural limitations:

  1. High Connection Latency: Establishing a new TLS 1.2 connection required two full TCP round trips (2-RTT) after the initial TCP three-way handshake before encrypted application data could be transmitted.
  2. Plaintext Handshake Exposure: Certificates, server identities, and handshake extensions were transmitted unencrypted, exposing target domains and client capabilities to passive network eavesdroppers.
  3. Cryptographic Complexity and Fragility: TLS 1.2 supported over 300 cipher suite combinations, many of which relied on vulnerable primitives like static RSA key exchange, RC4 stream ciphers, SHA-1 MACs, or CBC-mode ciphers susceptible to padding oracle attacks.

TLS 1.3 solves these issues by completely decoupling key exchange from authentication, requiring AEAD ciphers exclusively, and encrypting handshake messages immediately after ServerHello once handshake traffic keys are derived.

While TLS is conceptually mapped to Layer 6 (Presentation) in the OSI Reference Model, TLS is not an official OSI protocol classification. Architecturally, TLS operates as an intermediate security layer directly between application-layer protocols (such as HTTP/2, gRPC, or SMTP) and TCP (Layer 4). In contrast, modern transport protocols like QUIC embed the TLS 1.3 handshake directly into their framing structure rather than layering TLS above UDP.


2. Handshake Architecture: 1-RTT vs. 2-RTT Mechanics

The most noticeable performance enhancement in TLS 1.3 is the reduction of handshake latency from two round-trip times (2-RTT) to a single round-trip time (1-RTT).

TLS 1.3 Handshake Flow Comparison

The TLS 1.2 Handshake (2-RTT)

In TLS 1.2, the client and server engaged in a back-and-forth negotiation:

  1. RTT 1 (ClientHello / ServerHello): The client sent supported cipher suites and random nonces. The server selected a cipher suite, replied with its certificate, and optionally initiated key exchange via ServerKeyExchange.
  2. RTT 2 (Key Exchange / Finished): The client verified the certificate, computed client key parameters (ClientKeyExchange), and sent ChangeCipherSpec and Finished. The server responded with ChangeCipherSpec and Finished.
  3. Application Data: Only after two full round trips could encrypted HTTP payload bytes traverse the wire.

The TLS 1.3 Handshake (1-RTT)

TLS 1.3 eliminates the initial negotiation phase by introducing proactive key exchange. Because the vast majority of modern clients support standardized Elliptic-Curve Diffie-Hellman (ECDHE) groups, the client generates key shares for its preferred named curve(s) (such as X25519 or secp256r1) and transmits these public key shares directly inside the key_share extension of the initial ClientHello:

TLS 1.3 1-RTT Handshake Detailed Message Sequence

Step-by-Step Handshake Execution:

  1. ClientHello: The client sends its random nonce, supported TLS versions (TLS 1.3), a reduced list of AEAD cipher suites, and a key_share extension containing public key parameters for one or more preferred key exchange groups.
  2. ServerHello: The server selects a matching key exchange group and AEAD cipher suite. It returns its own public key_share for that group.
  3. Deriving Handshake Keys: Immediately after ServerHello, both endpoints incorporate the ephemeral ECDHE/FFDHE shared secret into the TLS 1.3 key schedule to derive the Handshake Secret and generate Handshake Traffic Keys.
  4. Encrypted Handshake Messages: All subsequent server handshake messages (EncryptedExtensions, Certificate, CertificateVerify, and Finished) are encrypted using the derived Handshake Traffic Keys.
  5. CertificateVerify: The server proves ownership of its private key by signing the cryptographic hash of the handshake transcript up to that point.
  6. Finished: Both parties send cryptographically authenticated Finished messages to verify transcript integrity. Once complete, Application Traffic Keys are derived, and encrypted application payload transmission begins immediately.

Handling Group Mismatches: HelloRetryRequest

If the server does not support any of the key exchange groups offered in the client’s initial key_share extension, it cannot complete the 1-RTT handshake immediately. Rather than failing the connection, the server responds with a HelloRetryRequest—a specialized ServerHello message containing a fixed, standardized Random field value (CF 21 AD 74 E5 9A 61 11 BE 1D 8C 02 1E 65 B8 91 C2 A2 11 16 7A BB 8C 5E 07 9E 09 E2 C8 A8 33 9C).

The HelloRetryRequest informs the client of the server’s chosen named group (e.g., secp256r1). The client then sends an updated ClientHello with a key_share matching the requested group. While this fallback adds one round trip (resulting in a 2-RTT handshake), it allows key exchange group negotiation to succeed gracefully without falling back to legacy protocol versions.


3. 0-RTT Resumption (Pre-Shared Key) and Anti-Replay Security

For returning clients, TLS 1.3 introduces 0-RTT Early Data Resumption. This feature allows a client reconnecting to a previously visited server to send encrypted application data in the very first flight of TLS records.

How 0-RTT Works

During a previous TLS 1.3 session, the server issues a NewSessionTicket message containing a Pre-Shared Key (PSK) identity and encrypted ticket state.

When reconnecting:

  1. The client sends a ClientHello with a psk_key_exchange_modes extension and a pre_shared_key extension.
  2. The client encrypts early application data (e.g., an HTTP GET request) using the early traffic secret derived from the stored PSK and attaches it directly to the first flight of TLS records (0-RTT Early Data).

TLS 1.3 0-RTT Early Data Resumption Flow

The Replay Attack Threat Model

While 0-RTT drastically reduces connection latency, it introduces a specific security vulnerability: Replay Attacks.

Because 0-RTT early-data keys are derived from the Pre-Shared Key (PSK) and the TLS key schedule prior to receiving the server’s ServerHello and fresh ephemeral key material, an adversary eavesdropping on the network can record the raw 0-RTT flight and retransmit it to the server.

If the replayed flight contains non-idempotent or state-modifying operations (such as processing a financial transaction or updating a database record), the server could execute the request multiple times if anti-replay defenses are absent.

Anti-Replay Mitigations

To defend against 0-RTT replay attacks, TLS 1.3 infrastructure deployments implement multi-layered anti-replay controls:

  1. Single-Use PSK Tickets & Age Windows: The server enforces a narrow validity window for session tickets and rejects early data if the obfuscated ticket age deviates from expected bounds.
  2. Server-Side Replay Caches: Edge proxies and server clusters maintain distributed replay caches or single-use ticket databases to detect and reject duplicate early-data identifiers within the allowed ticket age window.
  3. Application-Layer Replay Safety Controls: Early data must only be enabled for operations explicitly designed to be replay-safe or idempotent at the application level. While HTTP GET or HEAD requests are conventionally considered idempotent, application gateways must strictly evaluate request context to ensure no state-modifying side-effects are executed via 0-RTT flights. For architecture guidelines on configuring edge ingress rules, read our article on Layer 4 vs Layer 7 Load Balancing.

4. Key Exchange Primitives & Ephemeral Forward Secrecy

A central design goal of TLS 1.3 was eliminating non-forward-secret key exchange modes.

Why Static RSA Was Removed

In TLS 1.2, static RSA key exchange allowed the client to encrypt a Pre-Master Secret using the server’s public RSA key. If an adversary recorded encrypted network traffic and later compromised or subpoenaed the server’s private RSA key, they could decrypt all past historical traffic. Static RSA was also vulnerable to adaptive chosen-ciphertext attacks such as the Bleichenbacher attack.

Ephemeral Key Exchange: ECDHE and FFDHE

TLS 1.3 mandates ephemeral key exchange using either Ephemeral Elliptic-Curve Diffie-Hellman (ECDHE) or Ephemeral Finite-Field Diffie-Hellman (FFDHE). While FFDHE is supported by RFC 8446 for compatibility, ECDHE (using curves such as X25519 or secp256r1) is the predominant key exchange mechanism in modern production systems.

Under ephemeral key exchange, both endpoints generate fresh, single-use key pairs for every individual handshake. Once the session terminates and ephemeral key parameters are purged from memory, recorded historical traffic cannot be decrypted—even if the server’s long-term identity certificate key is later compromised.

Mathematical Foundation of ECDHE Key Agreement

Consider an elliptic curve defined over a finite field with base point (G).

  1. The client selects a random private scalar (a) and calculates public point (A): $$A = a \cdot G$$
  2. The server selects a random private scalar (b) and calculates public point (B): $$B = b \cdot G$$
  3. Both endpoints exchange public points (A) and (B) in the key_share extension.
  4. The client computes the shared secret point (S): $$S = a \cdot B = a \cdot (b \cdot G)$$
  5. The server computes the identical shared secret point (S): $$S = b \cdot A = b \cdot (a \cdot G)$$

Because calculating private scalar (a) from public point (A) requires solving the Elliptic Curve Discrete Logarithm Problem (ECDLP), an eavesdropper observing (A) and (B) on the wire cannot compute shared secret point (S).

HKDF Key Derivation Pipeline

Once the ephemeral Diffie-Hellman shared secret is computed, TLS 1.3 uses HKDF (HMAC-based Extract-and-Expand Key Derivation Function) defined in RFC 5869 to derive protocol keys. Rather than using the raw Diffie-Hellman secret directly, the shared secret is incorporated into the RFC 8446 key schedule, transitioning through three sequential secret stages using HKDF-Extract and HKDF-Expand-Label:

  1. Early Secret: Derived from HKDF-Extract using a zero-value salt (or PSK if resuming). Generates client_early_traffic_secret for 0-RTT data.
  2. Handshake Secret: Derived by feeding the ephemeral ECDHE/FFDHE shared secret into HKDF-Extract along with the derived Early Secret. Produces client_handshake_traffic_secret and server_handshake_traffic_secret to encrypt handshake messages.
  3. Master Secret: Derived by feeding a zero-value salt and the Handshake Secret into HKDF-Extract. Produces client_application_traffic_secret_0, server_application_traffic_secret_0 for application payloads, and resumption_master_secret for issuing new session tickets.

TLS 1.3 HKDF Key Schedule Derivation Pipeline

Each derived traffic secret (e.g., client_application_traffic_secret_0) is expanded via HKDF-Expand-Label into the symmetric encryption keys and initialization vectors (IVs) used by AEAD ciphers for record protection.

This phased key hierarchy guarantees strict cryptographic isolation: compromising a handshake key reveals nothing about early data or subsequent application traffic keys.


5. Pruned Cipher Suites & AEAD Enforcement

TLS 1.2 permitted hundreds of cipher suite combinations formatted as complex descriptive strings, such as:

TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384

In TLS 1.2, this string specified key exchange (ECDHE), authentication (RSA), bulk encryption (AES_256_GCM), and PRF hash (SHA384).

Decoupled Cipher Negotiation in TLS 1.3

TLS 1.3 decouples key exchange and authentication from the cipher suite. The cipher suite now defines only the bulk symmetric encryption algorithm and the HKDF hash function.

Furthermore, TLS 1.3 strictly limits symmetric encryption to Authenticated Encryption with Associated Data (AEAD) algorithms. AEAD ciphers simultaneously provide confidentiality and built-in message authentication/integrity verification, eliminating the complex and error-prone MAC-then-Encrypt constructions of CBC mode.

The 5 Standard TLS 1.3 Cipher Suites

RFC 8446 defines five standardized cipher suites:

  1. TLS_AES_128_GCM_SHA256 (Mandatory-to-implement baseline cipher suite in RFC 8446)
  2. TLS_AES_256_GCM_SHA384 (Common choice for deployments preferring AES-256)
  3. TLS_CHACHA20_POLY1305_SHA256 (Optimized for mobile/ARM hardware without AES-NI)
  4. TLS_AES_128_CCM_SHA256 (IoT / constrained environments)
  5. TLS_AES_128_CCM_8_SHA256 (Shortened MAC tag for IoT)

To explore symmetric encryption primitives, hashing mechanisms, and encoding conversions, see our comprehensive guide on Base64 Encoding, Hashing, and Encryption.

Deprecated Features Pruned in TLS 1.3

To harden the attack surface, the following legacy capabilities were permanently removed from TLS 1.3:

  • Static RSA Key Exchange
  • Static Diffie-Hellman (DH)
  • Stream Ciphers (RC4)
  • Cipher Block Chaining (CBC) Ciphers
  • MD5 and SHA-1 in Handshake Operations: SHA-1 and MD5 are completely forbidden for handshake digital signatures (CertificateVerify) and MAC/PRF algorithms in TLS 1.3. While legacy public key infrastructure (PKI) trust chains may still contain intermediate certificates signed with SHA-1, TLS 1.3 prohibits SHA-1 signature algorithms during the active handshake.
  • Session Renegotiation: TLS 1.3 removes legacy session renegotiation entirely, replacing it with the post-handshake KeyUpdate message to update symmetric traffic keys mid-connection without executing a full handshake.
  • Custom Explicit Curves (only vetted named curves like X25519, P-256, P-384, P-521 are permitted)
  • Compression (eliminating CRIME/TIME side-channel attacks)

6. Encrypted Handshake Extensions & Encrypted Client Hello (ECH)

In TLS 1.2, handshake metadata—including server certificates and client capabilities—was transmitted in plain text.

Handshake Message Encryption

In TLS 1.3, immediately following the ServerHello message, the server enables encryption using keys derived from the Handshake Secret. As a result, the server’s X.509 certificate, certificate chain, extensions, and CertificateVerify signature are fully encrypted on the wire, preventing passive network observers from inspecting certificate Subject Alternative Names (SANs) to identify target applications.

Encrypted Client Hello (ECH)

While standard TLS 1.3 encrypts handshake messages after ServerHello, the initial ClientHello remains unencrypted. Consequently, the Server Name Indication (SNI) extension—which indicates the requested domain name (e.g., api.internal.example.com)—is visible in cleartext to network monitoring systems and ISPs.

To address this privacy gap, the IETF developed Encrypted Client Hello (ECH) (formerly ESNI) as a separate extension specification built on top of TLS 1.3. ECH is defined separately from core RFC 8446, operating as an optional protocol extension requiring server and DNS infrastructure support.

Encrypted Client Hello (ECH) Architecture and Decryption Flow

How ECH Operates:

  1. DNS HTTPS / SVCB Record Discovery: Before initiating a connection, the client queries DNS for the target host’s HTTPS or SVCB resource records to retrieve the server’s published ECHConfig (containing HPKE public key parameters).
  2. Inner & Outer ClientHello: The client constructs two nested ClientHello structures:
    • Inner ClientHello: Contains sensitive parameters, including the actual requested domain name in the SNI field (private-api.example), ALPN protocols, and extensions.
    • Outer ClientHello: A public outer wrapper containing a generic, non-sensitive SNI (public-gateway.example) and an ech extension carrying the inner ClientHello encrypted via Hybrid Public Key Encryption (HPKE).
  3. Edge Decryption: Upon receiving the connection, an ECH-aware edge load balancer or CDN reverse proxy uses its private key to decrypt the inner ClientHello, restoring full metadata privacy. If ECH is not supported by the client or server, standard TLS 1.3 transmits the SNI in cleartext. For architecture guidelines on configuring edge ingress rules, read our article on Zero-Trust Network Perimeter Architecture.

7. Production Verification & OpenSSL CLI Diagnostics

Systems engineers and DevOps teams can diagnose and verify TLS 1.3 handshake behavior using standard CLI utilities.

1. Inspecting a Live TLS 1.3 Handshake

Use openssl s_client to force TLS 1.3 and inspect negotiated cipher suites, key shares, and server certificate chains:

openssl s_client -connect example.com:443 -tls1_3 -state

Expected Diagnostic Output:

CONNECTED(00000003)
SSL_connect:SSLv3/TLS write client hello
SSL_connect:SSLv3/TLS read server hello
depth=2 C = US, O = Internet Security Research Group, CN = ISRG Root X1
verify return:1
SSL_connect:SSLv3/TLS read encrypted extensions
SSL_connect:SSLv3/TLS read server certificate
SSL_connect:SSLv3/TLS read server cert verify
SSL_connect:SSLv3/TLS read finished
SSL_connect:SSLv3/TLS write finished
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 256 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
---

Note: Exact diagnostic output lines from openssl s_client may vary slightly depending on the OpenSSL release version (e.g., OpenSSL 1.1.1 vs 3.x, LibreSSL, or BoringSSL), but core state indicators remain identical.

In addition, the line Secure Renegotiation IS NOT supported in OpenSSL output is expected and correct behavior for a TLS 1.3 connection. TLS 1.3 completely removed session renegotiation—replacing it with the KeyUpdate post-handshake message for updating symmetric encryption keys mid-session—rendering legacy RFC 5746 secure renegotiation obsolete.

2. Testing 0-RTT PSK Session Resumption

To test session ticket issuance and 0-RTT resumption using OpenSSL:

Step A: Establish Initial Session and Save Session Ticket

openssl s_client -connect example.com:443 -tls1_3 -sess_out tls_session.pem

Step B: Reconnect Using Saved Session Ticket with Early Data

Create a sample early data request payload:

echo -e "GET /api/v1/health HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n" > early_data.txt

Initiate resumption with 0-RTT:

openssl s_client -connect example.com:443 -tls1_3 -sess_in tls_session.pem -early_data early_data.txt

3. Verifying TLS 1.3 Protocol & Cipher Negotiation via cURL

You can inspect the negotiated TLS version and cipher suite using verbose curl output:

curl -I -v --tlsv1.3 --tls-max 1.3 https://example.com/

Verbose Logging Excerpt:

* ALPN: offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / X25519 / RSASSA-PSS

8. Comparative Architectural Summary

The table below contrasts the fundamental protocol differences between TLS 1.2 and TLS 1.3:

Architectural Feature TLS 1.2 (RFC 5246) TLS 1.3 (RFC 8446)
Standard Handshake Latency 2-RTT (2 full round trips) 1-RTT (1 round trip)
Resumption Latency 1-RTT or Session ID lookup 0-RTT (Early Data via PSK)
Key Exchange Mechanics Static RSA, DH, ECDH, DHE, ECDHE Ephemeral ECDHE / FFDHE only
Perfect Forward Secrecy Optional (Dependent on cipher suite) Mandatory across all connections
Symmetric Cipher Types CBC Mode, Stream (RC4), AEAD AEAD exclusively
Handshake Encryption Plaintext (Certificates visible) Encrypted after ServerHello
SNI Privacy Plaintext (Exposed in ClientHello) Plaintext by default (Encrypted only if ECH extension is deployed)
Combinatorial Cipher Suites 300+ legacy combinations 5 streamlined AEAD suites
Insecure Cryptographic Primitives Permitted (MD5, SHA-1, RC4, 3DES) Completely purged

Conclusion

TLS 1.3 represents a milestone in network protocol optimization. By shortening the initial handshake to 1-RTT, providing zero-latency reconnects with 0-RTT PSK resumption, mandating ephemeral Diffie-Hellman key exchange (ECDHE/FFDHE), and encrypting post-ServerHello handshake messages (certificates, extensions, and signatures)—with optional Encrypted Client Hello (ECH) extending protection to initial ClientHello metadata—TLS 1.3 delivers unmatched performance and cryptographic resilience across modern cloud applications.

To continue building your foundational network knowledge, explore our companion architectural guides: