Web and networkingDive 02 of 12
HTTPS, before the first GET
One round trip to agree on keys, prove a server’s identity and hide an HTTP request. Follow TLS 1.3 from the first visible byte to the silicon doing the encryption.
- Levels
- 11
- Reading
- 42 min
- Depth
- Idea to Silicon
- Published
A server’s first reply, under a microscope
Here is where the conversation becomes private.
You ask for HTTPS. The server replies with public key material, then switches to encryption within the same flight. Each square below is one real byte.
Byte 100: both endpoints can derive handshake keys. The certificate, proof of key ownership and Finished message are encrypted from here.
RFC 8448 §3’s actual server flight. Nothing has been sent to example.com.
A private request on a public network
You type https://example.com/ and press Enter. Before the browser sends GET /, it has a problem: every router between you and the server can read and replace ordinary network bytes. A hotel Wi-Fi operator can redirect the connection. A compromised router can inject a script into the response. Encrypting a request helps only if you know who receives the decryption key.
Transport Layer Security: the protocol that authenticates peers and protects application bytes with negotiated cryptographic keys. solves three linked problems. Confidentiality keeps an observer from reading the HTTP bytes. Integrity makes undetected changes to those bytes infeasible. Server authentication binds the connection to the name you intended to visit. The browser normally stays anonymous at the TLS layer; login cookies and passwords operate later, inside the protected HTTP conversation.
The order matters. Two computers can agree on a secret across a public network without already sharing one. But an attacker can perform a separate agreement with each computer and relay the traffic. So TLS must connect its key agreement to an authenticated identity and to the exact handshake that established the keys. A certificate, a signature and a transcript hash will each do a different part of that work.
We will keep returning to that one request for example.com. For the byte experiments, we also use the published RFC 8448 §3 trace: fixed test keys, a host named server and a deliberately small test certificate. Those fixture bytes let you reproduce cryptographic results exactly. The example.com request uses a separate locally generated record, so changing the HTTP example never changes the published trace.
The current TLS 1.3 specification is RFC 9846, published in July 2026, which supersedes RFC 8446. RFC 8448 remains our published source of reproducible handshake bytes; these bytes and the key schedule encodings are unchanged.
What the extra round trip buys
Assume DNS has resolved the address and a TCP connection already exists. A full TLS 1.3 handshake needs one network round trip before the browser can send ordinary application data: ClientHello travels out, the server’s flight comes back, and the browser sends its Finished message followed by the request. The browser need not wait for another acknowledgment of its Finished.
A conventional full TLS 1.2 handshake needs two TLS round trips before that request. TLS 1.3 gets the client’s key agreement contribution into the very first message, so the server can derive keys and send its authentication proof immediately. This is a protocol dependency removed, not just a faster cipher. On a long-distance mobile link, removing that wait can matter much more than shaving microseconds off encryption.
Linear scale: 0–400 ms. Full certificate handshakes after TCP is established; propagation only, no loss, retry or processing delay.
TLS 1.3 saves 80 ms before the browser can send its first HTTP request.
The outline still shows through
TLS protects content between its endpoints. An observer still sees the destination IP address, TCP port, connection duration, packet sizes and timing. Without Encrypted Client Hello, the initial server-name extension exposes example.com too. DNS may reveal the same name independently. Record padding can obscure some lengths, but it does not turn a connection into an anonymous tunnel.
The server itself sees the request after decryption. If a CDN terminates TLS, that CDN is an endpoint and sees it too; an additional connection to the origin has its own handshake and security properties. A trusted corporate inspection root can make an interception proxy an authenticated endpoint from a managed browser’s perspective. A successful handshake says the browser’s trust rules were satisfied, not that the site is honest or that every later hop uses the same keys.
Here we follow TLS over TCP, the path for HTTP/1.1 and HTTP/2. HTTP/3 uses QUIC: it reuses the TLS 1.3 handshake but carries its messages in QUIC frames and protects QUIC packets instead of TLS records. Keep that boundary in mind when comparing a browser capture with the record diagrams below.
| Connection mode | Wait before request | Fresh certificate proof | Replay property |
|---|---|---|---|
| Conventional full TLS 1.2 | 2 TLS round trips | Yes | Protected within the connection |
| Full TLS 1.3 | 1 TLS round trip | Yes | Protected within the connection |
| TLS 1.3 PSK + DHE | 1 TLS round trip | PSK replaces certificate proof | Protected within the connection |
| TLS 1.3 early data | No server reply required | PSK from prior authentication | Early data can be replayed across connections |
HTTPS must both hide the request and prove who gets to open it. Key agreement without authentication is not enough.
Who is allowed to be example.com?
The browser starts with a name from the URL, example.com. It does not let the network choose that name after connecting. The certificate offered by the server must authorize that reference identity, and the server must demonstrate possession of the corresponding private key during this handshake. These are separate checks: a certificate can be copied by anyone.
A certificate is a signed statement binding names and a public key, with a validity interval and restrictions. In the usual web chain, an intermediate certificate authority signs the leaf certificate, and a root or another intermediate signs that intermediate. A browser builds a valid path to a locally trusted anchor. The server generally sends the leaf and intermediate certificates; sending a self-signed root does not make that root trusted.
The path must obey certificate constraints: issuer signatures, basic constraints and path length, name constraints where present, acceptable algorithms, and applicable key usage and extended key usage, such as server authentication. Validation is more than checking that adjacent issuer and subject strings look alike. RFC 5280 §6 defines the path-validation machinery; browser root programs add policy requirements.
Trust begins here, outside this connection.
CA constraints and permitted names apply.
DNS SAN, dates, usages and policy checks.
A fresh signature over this handshake.
For the name check, modern service-identity rules use subjectAltName, not a fallback to the certificate’s Common Name. A DNS identifier is matched according to RFC 9525, which replaced RFC 6125. A wildcard such as *.example.com can cover www.example.com under the wildcard rules; it does not cover example.com or a.b.example.com. A URL with an IP literal requires the corresponding IP-address identity.
Time is part of the proof. A browser checks validity against its clock, as well as policy limits on certificate lifetime. The CA/Browser Forum’s SC081v3 schedule reduces the maximum public TLS subscriber-certificate validity to 200 days for certificates issued on or after March 15, 2026, then 100 days from March 15, 2027 and 47 days from March 15, 2029. These are issuance-date rules; they do not retroactively rewrite every older certificate’s expiry.
Revocation and public accountability
An unexpired certificate can still be revoked. OCSP stapling lets the server attach a CA-signed status response to its certificate entry, avoiding a per-connection query to the CA. It is not a universal extra network round trip. Client behavior varies: Mozilla’s 2025 CRLite deployment report documents local revocation checks in desktop Firefox starting with version 137 and disabling OCSP queries for domain-validated certificates in version 142. That is a versioned behavior, not a rule for all browsers.
Shorter certificate lifetimes bound how long a stolen certificate can remain usable without renewal, but do not instantly revoke it. Revocation information still has to reach clients. Different browsers combine their own distributed revocation data, platform services and policy; a missing OCSP request in a packet capture does not establish that no revocation check happened.
Certificate Transparency adds another test. A Signed Certificate Timestamp, or SCT, is a log’s signed promise to incorporate a certificate or precertificate. It helps expose misissuance to monitors. It is not a second certificate authority and does not prove the site is safe. Chrome’s CT policy evaluates log eligibility, SCT count and operator diversity for publicly trusted certificates. RFC 9162 specifies CT version 2; deployed browser policy and supported log formats are separate questions.
How many SCTs actually count?
For the embedded-SCT route, Chrome’s published policy requires two distinct logs for a certificate lasting at most 180 days, and three above 180 days. At least two contributing SCTs must come from different operators. At check time, at least one embedded SCT must belong to a Qualified, Usable or ReadOnly log; the remaining count can also use Retired logs, subject to retirement timing. The alternative TLS-delivered route needs two SCTs from Qualified, Usable or ReadOnly logs and two operators. Chrome versions before 148 also count OCSP-delivered SCTs under that route. These are Chrome’s published policy rules, not a universal RFC quota.
Apple’s embedded route requires two distinct logs up to 180 days; from 181 to 398 days it requires three. For the two-SCT tier, at most one per operator counts; for the three-SCT tier, at most two. At least one embedded SCT must come from a currently approved log; others may be from once-approved logs. Its alternative route needs two currently approved logs with at least one SCT delivered by TLS extension or OCSP stapling. Apple also requires at least one SCT from an RFC 6962-compatible log: a deployment-format requirement even though RFC 9162 defines CT v2. See Apple’s policy, published April 21, 2025.
| Embedded SCTs | ≤180 days | 181–398 days | Example: 200-day leaf |
|---|---|---|---|
| Chrome | 2 distinct logs | 3 distinct logs | 3 logs, ≥2 operators |
| Apple | 2 logs, ≤1 per operator | 3 logs, ≤2 per operator | 3 logs, ≥2 operators |
A 200-day example.com certificate therefore needs three qualifying embedded SCTs under both policies; a 100-day leaf needs two. Counts alone are insufficient: log approval, status and timing still matter. These are the published policies checked in November 2026. Browser version, enterprise configuration and updated log lists can change the result, so production issuance must check the target platform’s current rules.
A chain authorizes a public key for a name. CertificateVerify connects that authorization to the keys negotiated in this particular connection.
One round trip, several kinds of proof
Now put those checks on the wire. A One sender’s consecutive handshake messages before it needs to hear from its peer again. can contain several messages and several records. It is a dependency boundary, not a promise about the number of packets. In the full handshake below, each side can prepare its next flight from what it has already received.
The browser’s ClientHello offers supported TLS versions, symmetric cipher suites, key agreement groups, signature schemes and application protocols. It also includes a freshly generated public key share. The server chooses compatible parameters and responds with ServerHello, including its own share. Each endpoint now combines its private key with the other endpoint’s public share and derives the same handshake secret.
Everything after ServerHello in the server’s normal certificate flight is encrypted: EncryptedExtensions, Certificate, CertificateVerify and Finished. The certificate cannot be used to decrypt that record. The client already has the required shared secret from the two key shares. Authentication catches up before the browser treats the server as trusted or releases ordinary HTTP data.
EncryptedExtensions carries negotiated features that do not have to be available to derive handshake keys. For example, ALPN’s selected application protocol belongs here, while the selected TLS version and key share belong in ServerHello. A server cannot simply echo every client extension into every response: each extension has specific allowed messages, and unsolicited responses are generally errors, subject to explicit exceptions in the specification.
CertificateVerify signs a structured context string and a hash of the handshake so far. The certificate’s long-lived private key authenticates the ephemeral exchange; it does not become the traffic encryption key. TLS 1.3 removed RSA key transport. Even with an RSA certificate, this connection can use X25519 for agreement and AES-GCM for records. Those are three different algorithm choices.
Finished is a keyed MAC over the transcript before that Finished message. It proves knowledge of the handshake secret and detects changes to the negotiated conversation. The client verifies the server’s Finished, then sends its own Finished using the client handshake traffic secret. Each side’s view must agree on the exact byte sequence, including handshake headers but excluding record headers.
There is one important split in time. The application traffic secrets are derived using the transcript through the server’s Finished, but the client sends its Finished first under the handshake keys. It then changes its sending epoch to application keys. The server must not act on the client’s application data before verifying the client’s Finished. The fact that decryption is mathematically possible is not permission to advance the protocol state.
A TLS implementation therefore needs both a record decoder and a handshake state machine. A perfectly authenticated record containing CertificateVerify before Certificate is still invalid. A Finished with a valid length but an incorrect MAC is invalid. The safe path through the handshake follows both cryptographic checks and message ordering, as specified in RFC 9846 §4.5.
Coming back, retrying and hiding the name
A return visit can reuse authentication work without reusing record keys. After the handshake, the server may send NewSessionTicket under application traffic protection. The ticket identifies resumption state, and both sides derive a resumption pre-shared key, or PSK, from the resumption master secret and the ticket’s nonce. The ticket itself is not the secret: a passive observer who learns an opaque ticket cannot automatically compute the PSK.
On the next connection, the browser offers the ticket identity in pre_shared_key and includes a A MAC over a defined prefix of ClientHello, proving possession of the PSK and binding it to the new offer.. The binder uses a key derived from the PSK and authenticates the partial ClientHello specified by the protocol. Its length fields are encoded as if the final binders were already present. This is not a MAC over arbitrary text or over the previous connection’s transcript.
The pre_shared_key extension must be last in ClientHello. The client also offers psk_key_exchange_modes; a server must not select a PSK mode the client did not offer. With psk_dhe_ke, a fresh ephemeral exchange contributes to the new handshake secret. This preserves forward secrecy for the new 1-RTT application traffic even if the old PSK is later compromised. PSK-only psk_ke has different security properties.
- Browser → server: ClientHello + key share
- Server → browser: ServerHello + encrypted certificate flight
- Browser → server: Finished + encrypted GET /
- Browser → server: ClientHello + ticket + binder + fresh share
- Server → browser: ServerHello + EncryptedExtensions + Finished
- Browser → server: Finished + encrypted GET /
- Browser → server: ClientHello + ticket + binder, then encrypted GET /
- Server → browser: accept or reject early data; handshake flight
- Browser → server: EndOfEarlyData if accepted, then Finished
- Browser → server: ClientHello, no share for the server’s group
- Server → browser: HelloRetryRequest naming the group
- Browser → server: second ClientHello with requested share
- Server → browser: ServerHello + encrypted certificate flight
- Browser → server: Finished + encrypted GET /
One TLS round trip before GET /. Server identity comes from a certificate and CertificateVerify.
Tickets have clocks as well as secrets
NewSessionTicket’s ticket_lifetime is seconds, with a maximum of 604,800, or seven days. A zero lifetime means discard immediately. Clients must not cache a ticket beyond seven days, and servers can expire it sooner. Each ticket carries a fresh random 32-bit ticket_age_add; the next ClientHello’s obfuscated_ticket_age reports its age in milliseconds, obscured by adding that value modulo 232. These fields are specified by RFC 9846 §4.7.1.
The §3 trace’s lifetime is just 30 seconds and its age-add is 0xfad6aac5. Ten seconds after receiving it, a client reports (10,000 + 0xfad6aac5) mod 232 = 0xfad6d1d5. Subtracting the original age-add modulo 232 recovers 10,000 ms. The ticket nonce derives a distinct PSK; the age-add obscures a timestamp. Neither substitutes for verifying the binder.
For 0-RTT freshness, the server estimates when the new ClientHello should arrive: ticket creation time + estimated RTT + recovered client age. If creation was at server time 100,000 ms and estimated RTT was 80 ms, that expected arrival is 110,080 ms. An actual arrival at 110,120 ms differs by 40 ms. A server choosing a ±10-second freshness window would pass that check; one arriving 20 seconds later would fail it, while a 1-RTT handshake could still proceed.
The window is deployment policy, not a universal TLS constant. RFC 9846 §8.3 discusses Internet windows on the order of ten seconds to tolerate delays and clock-rate error. Replays inside the window remain possible, so freshness alone cannot replace single-use tickets or replay tracking. It checks the ClientHello’s arrival, not a deadline for every following early-data record.
Why early data is different
If the ticket permits early data and the client is configured to use it, the browser can derive an early traffic secret and send encrypted application bytes immediately after ClientHello. That is 0-RTT: it removes the wait for a server reply before sending. The server can still reject early data while accepting resumption. Acceptance is signaled in EncryptedExtensions, and accepted early data introduces EndOfEarlyData before the client’s remaining handshake messages. TLS never automatically resends rejected early data; the application decides whether to retry after the handshake.
Early data lacks the normal handshake’s replay protection across connections. An attacker may replay a captured ClientHello and its early records at another accepting server instance. Authentication tags still verify: the attacker does not need to alter the bytes. Fresh DHE protects later traffic, but it cannot retroactively protect bytes sent before the server supplied a fresh share.
That makes “GET is safe” an inadequate deployment rule. A badly designed GET endpoint can change state; an otherwise read-only request can still consume a one-use token or trigger a costly operation. Servers need application-specific replay handling, suitable ticket policy and coordinated anti-replay state where applicable. RFC 8470 defines HTTP’s Early-Data signal and 425 Too Early response to support safe retry behavior.
A missing share costs another trip
ClientHello can list a group it supports without carrying a share for it. Generating and transmitting every possible share wastes CPU and bandwidth. If the server wants a supported group with no supplied share, it can send HelloRetryRequest, encoded as ServerHello with a special fixed random value. The second ClientHello supplies the requested share; the server then proceeds. A second HelloRetryRequest is forbidden.
A retry changes transcript handling. The first ClientHello is replaced in the transcript by a synthetic message_hash handshake message containing its hash; HelloRetryRequest and the second ClientHello follow that. Treating retry as an ordinary extra ServerHello in an unchanged transcript gives the wrong keys. The second ClientHello must also obey the restricted set of changes, rather than silently becoming a fresh, unrelated offer. RFC 9846 §4.1 defines the transcript substitution.
Ready. Computation runs locally when you press the button.
Hide the name before the server replies
Encrypted Client Hello, RFC 9849, published in March 2026, adds an encrypted inner ClientHello carried by a public outer ClientHello. The inner hello contains the sensitive name and other protected parameters. The outer hello still lets a frontend route and process the connection. The client obtains an ECH configuration, commonly through the HTTPS DNS record mechanism in RFC 9848, and uses HPKE to encrypt the inner hello to the ECH service.
ECH needs deployment on both sides and a usable configuration. Its privacy also depends on the surrounding system: unencrypted DNS can reveal a name, an IP address can identify a single site, and traffic analysis still sees lengths and timing. The outer name and public configuration remain visible. ECH acceptance confirmation and retry rules prevent the client from casually treating a rejected private offer as an authenticated connection to the intended hidden name.
Resumption saves authentication work. 0-RTT saves a wait by accepting a different replay risk. ECH protects an earlier privacy boundary.
Two headers and a hidden type
So far we have named messages. TCP sees none of those names: it carries an ordered byte stream. TLS packs handshake messages and application bytes into A length-delimited TLS unit with a five-byte public header. Encrypted records authenticate that header and protect an inner plaintext.. One handshake message can span records, and one record can carry several complete handshake messages. TCP segments and socket reads introduce still more unrelated boundaries.
The outer record header is five bytes: one content type, two legacy version bytes and a two-byte unsigned big-endian length. Before encryption starts, ClientHello and ServerHello use content type 0x16, handshake. TLS 1.3 record headers normally carry 0x0303; the initial ClientHello record may use 0x0301 for compatibility. Receivers must ignore TLSPlaintext’s legacy record version. In TLSCiphertext the field is authenticated as AAD; receivers may ignore it or require 0x0303. Neither field negotiates the version; RFC 9846 Appendix E.1 specifies this distinction.
After ServerHello, encrypted records use outer type 0x17, application_data, even when they carry a certificate or Finished. The true type moves inside the ciphertext. This removes an easy signal that would otherwise distinguish particular encrypted handshake messages from application traffic. It also gives the record layer a uniform authenticated format.
- Outer typeapplication_data, including encrypted handshakes
- Legacy record versionIgnored for version negotiation
- Ciphertext length674, not including these five header bytes
- Ciphertext prefixEncryptedExtensions starts here, but is unreadable on the wire
The encrypted input has the structure content || type || zeros, called TLSInnerPlaintext. Padding is a run of zero octets after the real type. The receiver first authenticates and decrypts, then scans backward past zero padding to find the last nonzero octet. That octet is the content type; preceding bytes are the content, including any zeros that belong to the content itself.
This is why padding is not a length byte or a special ciphertext marker. A zero inside an HTTP body is ordinary data, and an all-zero decrypted inner plaintext has no valid type. The type and padding are covered by the AEAD authentication tag, under RFC 9846 §5.4. A receiver must never expose tentative plaintext to the HTTP parser before the tag verifies.
The unencrypted TLSPlaintext content limit is 214 bytes. TLSCiphertext’s length field must not exceed 214 + 256, or 16,640 bytes. The inner plaintext is limited to 214 + 1 bytes, including its type and any padding; padding therefore consumes the same budget as content. AES-GCM adds a 16-byte tag. For an unpadded full-size content record, the total on the TCP stream is 16,384 + 1 + 16 + 5 = 16,406 bytes.
These limits constrain buffering before allocation. A parser can reject an excessive advertised length after reading the five-byte header instead of allocating what an attacker asked for. It must also handle a header split across reads, encrypted content split across reads and several records returned by one read. The encrypted length authenticates the record boundary, but a live parser still needs to find that boundary safely.
The record_size_limit extension, RFC 8449, lets a peer advertise a smaller receive limit. In TLS 1.3 that limit includes the entire inner plaintext, so its real type and padding count. The RFC trace advertises 0x4001, 16,385. It is a receive constraint, not a requirement to send exactly that many bytes in every record.
The network sees a five-byte envelope. The authenticated encrypted interior tells the endpoint what those bytes actually mean.
The first 201 bytes
The first record in the trace is 201 bytes. Its five-byte record header says 16 03 01 00 c4: handshake, compatibility version, 196 bytes to follow. Those 196 bytes begin with another header, this time for the handshake message: 01 00 00 c0, ClientHello with a 192-byte body. Record lengths use two bytes; handshake lengths use three. Confusing them moves every subsequent field.
Inside ClientHello, the legacy version is 03 03. Next come a 32-byte random and a length-prefixed legacy session ID. The trace’s session ID is empty. Browsers using TLS 1.3 middlebox compatibility mode commonly supply a nonempty ID that ServerHello echoes. This legacy field is not the resumption ticket mechanism we just discussed.
The cipher suite vector offers 13 01, 13 03 and 13 02, in that order. They mean AES-128-GCM/SHA-256, ChaCha20-Poly1305/SHA-256 and AES-256-GCM/SHA-384. A TLS 1.3 suite chooses the record AEAD and the key schedule hash. It no longer encodes the certificate type or the key agreement group, which are negotiated separately.
RFC 8448 §3 · complete ClientHello record · 201 bytes
Select a field or any byte. Arrow keys move between bytes; Home and End reach the edges.
1616 = handshake, still visible to the network.
Solid accent: selected field. Outlined teal: bytes counted by the selected length.
One legacy compression method follows, null compression, encoded as a one-byte vector 01 00. Then comes the two-byte total extensions length. Each extension has a two-byte type, a two-byte length and that many data bytes. A well-formed outer length does not make the nested vectors valid; the lengths at each level must agree.
Offers that answer different questions
supported_versions carries a one-byte vector length followed by two-byte version identifiers. The trace uses 02 03 04: one version, TLS 1.3. ServerHello returns the selected 03 04 without that client-side vector wrapper. Neither the record’s 03 01 nor the hello’s 03 03 overrides this selection.
supported_groups lists acceptable key agreement groups. Here it includes x25519 (00 1d), secp256r1 (00 17) and others. key_share supplies concrete public material for a subset of those groups. The trace carries one 32-byte X25519 share. Its group must appear in supported_groups, and multiple shares must follow the groups’ relative ordering. A duplicate share for a group is invalid.
signature_algorithms lists acceptable signature schemes. Modern TLS 1.3 CertificateVerify uses schemes such as RSA-PSS, ECDSA and Ed25519 according to the protocol’s rules. Some legacy entries remain in this multi-version fixture, but their presence does not make SHA-1 or RSA PKCS#1 v1.5 legal for TLS 1.3 CertificateVerify. The server must choose a scheme compatible with both the client offer and its certificate key.
server_name carries a nested ServerNameList. In the trace, 73 65 72 76 65 72 spells server. For our URL, the ASCII name example.com is eleven bytes and produces the encoding below. SNI carries a hostname, without a scheme, port, slash or trailing request path. It helps the server select a certificate before the HTTP Host field can arrive.
- SNI headertype 0, extension data length 16
- Name list + host_name14-byte list, type 0, 11-byte name
- example.com
- ALPN headertype 16, data length 14
- ProtocolNameList12-byte list: h2, then http/1.1
ALPN, specified by RFC 7301, prevents two endpoints from successfully encrypting bytes while disagreeing about their application framing. The browser might offer h2 and http/1.1; the server selects one, not the whole list. For our literal text request later, assume HTTP/1.1 is selected. With h2, the same semantic GET uses the HTTP/2 connection preface, SETTINGS and a HEADERS frame instead.
The trace also offers psk_key_exchange_modes with psk_dhe_ke, but offers no PSK identity in this first handshake. Capability is not selection. The empty legacy session_ticket and renegotiation_info extensions are compatibility fields, not evidence of TLS 1.3 renegotiation or successful resumption.
A real browser hello may include GREASE values. RFC 8701 reserves patterned values such as 0x0a0a and 0x1a1a to keep implementations tolerant of unknown extensible offers. An unknown client extension is ignored unless a specification gives it other meaning; the server must not select an unknown cipher or group just because it saw it. Reserved GREASE values are not secret algorithms.
The exact ordering of most ClientHello extensions is flexible. The critical exception is pre_shared_key last. Extension types cannot repeat in a block, and inner vectors must stay within their enclosing lengths. Those requirements are why a browser fingerprint is a pattern observed in valid messages, not permission to invent extra parser rules around one familiar ordering.
A ClientHello is a collection of typed, length-prefixed offers. Versions, record ciphers, key agreement, signatures and HTTP protocols each negotiate a different thing.
A shared secret that never crossed the wire
The explorer exposed the client’s public share. Where is the shared key? Nowhere in the capture. With X25519, the client chooses a fresh private scalar a and sends a public u-coordinate derived from it. The server does the same with b. Combining your private scalar with the peer’s public share yields the same 32-byte result at either endpoint.
At the group-operation level, the symmetry is a(bG) = b(aG). X25519 exposes the Montgomery u-coordinate rather than a full point encoding. Its field is built modulo 2255 − 19, and its public values use a 32-byte little-endian encoding. That byte order is an algorithm detail: TLS’s two-byte lengths and group identifiers remain big-endian.
The private values never need to cross the network. An observer sees both public shares but cannot feasibly recover the shared secret using known classical attacks at the intended security level. TLS requires checking for the all-zero X25519 shared result and aborting if it occurs. Private key generation must use a cryptographically secure random source, and ephemeral private material should be erased when no longer needed.
Try X25519 first; if this browser does not support it, use P-256 ECDH. Both parties compute the secret independently.
Ready. Computation runs locally when you press the button.
The “ephemeral” in ECDHE is what gives a full handshake forward secrecy. If someone records today’s encrypted connection and steals the server’s certificate private key next month, that key alone does not reveal the erased ephemeral scalar. It can forge future signatures while trusted, but it does not reconstruct the old Diffie–Hellman result. This depends on real key erasure and fresh ephemeral keys, not merely selecting a suite with a reassuring name.
The shared result is input key material, not directly the AES key. We still need to incorporate the transcript, separate client from server, separate handshake from application data, and derive IVs. That is the key schedule’s job. It prevents one raw agreement result from being used everywhere with ambiguous purpose.
A larger share for a different adversary
A sufficiently capable quantum computer running Shor’s algorithm would threaten classical elliptic-curve key agreement. The harvest-now-decrypt-later concern is that an adversary can store captures today and attack them later. Hybrid key agreement combines classical agreement with a post-quantum mechanism rather than waiting for a future attacker to arrive.
As of November 2026, RFC 10024, published in August 2026, specifies X25519MLKEM768. Its IANA group value is decimal 4588, hexadecimal 0x11ec. For this group the client share is a 1,184-byte ML-KEM-768 encapsulation key followed by a 32-byte X25519 share, totaling 1,216 bytes. The server share is a 1,088-byte ML-KEM ciphertext followed by 32 X25519 bytes, totaling 1,120 bytes.
The combined secret for X25519MLKEM768 concatenates the 32-byte ML-KEM result and the 32-byte X25519 result before feeding the TLS key schedule. This order is part of the group definition, not a convention to guess from the name. The hybrid is designed to retain confidentiality if at least one component remains secure under the combiner’s assumptions. It does not automatically make the certificate signature post-quantum.
This is deployed technology, but not universal negotiation. The Chrome team’s Chrome 131 rollout announcement describes moving from the incompatible Kyber experiment at 0x6399 to ML-KEM at 0x11ec. Whether a particular November 2026 connection uses it still depends on client version and policy, server support and key-share selection. Our RFC 8448 fixture predates it and remains plain X25519.
Public shares travel; private scalars stay local. The resulting shared secret is then bound to the negotiated transcript and split into purpose-specific keys.
Turning one secret into a family of keys
Both sides now have the same 32-byte X25519 result. They also have the same ClientHello and ServerHello bytes. TLS 1.3 turns those inputs into a tree of secrets with HKDF. For the selected TLS_AES_128_GCM_SHA256 suite, the hash is SHA-256, secrets are 32 bytes, AES keys are 16 bytes and record IVs are 12 bytes.
HKDF has two operations, specified in RFC 5869. Extract uses HMAC with a salt as key and input key material as message to produce a pseudorandom key. Expand derives a requested number of bytes using that key and an information string. They are distinct operations: importing a key into WebCrypto’s combined HKDF deriveBits interface and extracting it again would add an unwanted extraction.
Our implementation runs HMAC through WebCrypto and implements the HKDF expansion loop directly. For SHA-256, the first block is HMAC(PRK, info || 01). A second block, when needed, includes the first block before info and 02. Every output requested by this particular schedule fits in the first 32-byte block, but the label still records the requested output length.
Three extraction stages
The Early Secret is HKDF-Extract with a zero salt and the PSK as input. In this full, non-PSK handshake, the missing PSK is a string of 32 zero bytes, not an empty string. The early stage therefore has a reproducible value. That does not make the eventual connection key predictable: the next extraction brings in the ephemeral shared secret.
First derive an intermediate salt with the label derived and the hash of the empty transcript. Extract the ECDHE result with that salt to obtain the Handshake Secret. From it, derive client and server handshake traffic secrets, each bound to the hash of ClientHello through ServerHello. The labels differ, so the two directions get different secrets even with the same transcript.
A second derived operation prepares another salt; extracting 32 zero bytes with it yields the Master Secret. That root feeds application traffic secrets and exporter and resumption branches. “Master” does not mean “use these bytes directly as an AES key.” It is another secret with a defined set of child derivations.
RFC 9846 calls the trace’s Master Secret the Main Secret, and shortens the exporter and resumption secret names. The byte labels exp master and res master remain unchanged for compatibility. The calculations here follow the published trace’s names and values.
The bytes behind a label
TLS does not feed the word key directly to HKDF. HKDF-Expand-Label constructs an HkdfLabel structure: a two-byte output length, a one-byte label length, the ASCII bytes tls13 followed by the supplied label, then a one-byte context length and the context bytes. That exact prefix, including its space, separates TLS 1.3 derivations from unrelated HKDF uses, as specified in RFC 9846 §7.1.
For a 16-byte key with an empty context, the serialized information string is the 13 bytes below. An IV derivation instead starts with 00 0c, uses the label tls13 iv and remains empty-context. Finished uses a 32-byte output and the label tls13 finished. Similar-looking operations deliberately have different byte strings.
- Output length16 bytes
- Label length9 bytes, including prefix
- Prefixed labelASCII: tls13 key
- Context lengthEmpty context
Derive-Secret adds another layer: it hashes the supplied sequence of handshake messages and passes that digest as the context to Expand-Label. The empty transcript therefore produces the 32-byte SHA-256 digest of an empty string. That is different from the zero-byte context used for key, IV and finished-key expansion. Confusing those two kinds of “empty” produces plausible-looking but entirely wrong keys.
The transcript includes each handshake message’s type and three-byte length. It excludes record headers, ciphertext tags, padding and compatibility ChangeCipherSpec. Splitting the same handshake messages into different records must leave the transcript hash unchanged. With a retry, the synthetic message_hash rule from earlier replaces the first hello; the simple trace below has no retry.
Ready. Computation runs locally when you press the button.
The lab starts from the RFC’s published ECDHE result, so its HKDF calculation also works in browsers without X25519. A separate test derives that result from the RFC’s private and public X25519 inputs. The test suite then compares all 29 schedule values and reproduces the published encrypted application record, joining the agreement, derivation and record layers.
Application traffic secrets use the transcript through the server’s Finished. Resumption master instead waits for the transcript through the client’s Finished. A ticket-specific nonce expands resumption master into the ticket PSK. Exporter master supplies separately labeled keys to applications that use the TLS exporter API; it is not the record encryption key exposed under another name.
HKDF binds a shared secret to a purpose, a direction and a transcript boundary. One different label byte gives a different key.
Open the server’s encrypted flight
The server’s first encrypted record is now something you can open. Its 674 bytes after the header include a 16-byte GCM tag. AES-GCM combines encryption with authentication, an Authenticated encryption with associated data: encrypts content while also authenticating additional public bytes.. Its inputs are a key, a nonce, plaintext and additional authenticated data. The header stays readable but must not be changeable without detection.
For TLS 1.3 the additional authenticated data is exactly the five-byte TLSCiphertext header: 17 03 03 02 a2. The length includes the ciphertext and tag. There is no explicit per-record nonce field on the wire. Both endpoints compute it from a static traffic IV and an implicit record sequence number.
The sequence is an unsigned 64-bit counter, maintained independently for each direction and each traffic key. Encode it big-endian, left-pad it to the IV length and XOR it with the static IV. At sequence zero the nonce equals the IV. At sequence one its final byte is XORed with 01; at 256, the next-to-last byte changes. This is not addition, concatenation or a random nonce chosen for each TLS record; see RFC 9846 §5.3.
noncen = write_iv XOR (032 || uint64_be(n))
Each new traffic key starts its own counter at zero. Client and server may both use zero because they have different keys and IVs. Reusing the same key and nonce for different plaintexts would be catastrophic for GCM. Sequence numbers must not wrap. Endpoints must update keys before the applicable AEAD usage limits are exceeded, often much earlier than the counter’s mathematical limit.
Try changing the encrypted record header’s legacy version. A receiver may enforce its fixed value or ignore it after authentication; it never selects the protocol version. It is still authenticated as part of the AAD. Changing it without computing a new tag must fail. Likewise, a different nonce, a changed ciphertext bit or a changed tag must fail before the decoder releases any handshake bytes.
Ready. Computation runs locally when you press the button.
What those 657 bytes prove
The recovered record contains four handshake messages. EncryptedExtensions is 40 bytes, Certificate 445, CertificateVerify 136 and Finished 36. Their sum is 657. The encrypted inner type adds one byte, and the GCM tag adds 16, making 674. The visible five-byte header brings the complete record to 679. These are actual trace lengths, not estimates of a modern public certificate chain.
The CertificateVerify body begins with signature scheme 08 04, rsa_pss_rsae_sha256, then the signature’s two-byte length and 128 signature bytes. The signed input is 64 ASCII space bytes, the context string TLS 1.3, server CertificateVerify, one zero byte, and the transcript hash through Certificate. The role-specific context keeps this signature from being interpreted as a signature for an unrelated protocol or for the client role.
Our browser verifies that RSA-PSS signature with the public key embedded in the trace certificate. It does not validate the certificate against a browser trust store. The fixture uses a 1,024-bit RSA key to keep the trace short; a production web certificate must satisfy modern key-strength and trust policy. This is a useful distinction between verifying a mathematical signature and authorizing a real website.
Finished uses a different proof. Expand the server handshake traffic secret with label finished, an empty context and a 32-byte output to get finished_key. HMAC that key over the transcript hash through CertificateVerify. Compare the result to the 32-byte verify_data in Finished. Finished itself joins the transcript only after its own expected value has been calculated.
verify_data = HMAC(finished_key, Hash(handshake messages before this Finished))
The AEAD tag, CertificateVerify and Finished cover different things. The tag authenticates this record under the selected traffic key. CertificateVerify ties the handshake transcript to the certified signing key. Finished proves possession of the handshake-derived secret over the whole prior transcript. Passing one does not waive either of the others.
The record parser in this lab recognizes the full certificate flight in order and rejects truncated or extra messages. A real TLS endpoint additionally handles permitted optional messages, fragmentation and negotiated authentication modes. It cannot accept a reordered certificate proof just because each message’s length or surrounding record tag is valid.
Decrypting a record is one gate. A valid signature, a valid certificate and the right handshake state are additional gates before HTTP may proceed.
Finally: encrypt GET /
The server’s identity is accepted and its Finished verifies. The browser sends its own Finished using the client handshake write key. Then it switches to the client application traffic key and sends the request. Both records can be written back to back into TCP without waiting for another server flight. They remain separate records because they use different epochs and different content types inside their encryption.
Assume ALPN selected HTTP/1.1. Our request is the 37 ASCII bytes below, with every CRLF shown as \r\n: a request line, a Host field, and a final empty line. The line endings are carriage return followed by line feed, 0d 0a, including the final empty line. Host routes the request inside HTTP, while SNI helped select the TLS context earlier. They serve different layers and are not interchangeable.
GET / HTTP/1.1\r\nHost: example.com\r\n\r\nAdd inner type 17 and any zero padding after it. With no padding, the inner plaintext is 38 bytes. AES-GCM produces 38 encrypted bytes plus a 16-byte tag; the outer header adds five. The complete unpadded record is 59 bytes: 17 03 03 00 36 followed by 54 protected bytes. That fixed visible header tells an observer the ciphertext size, not the URL path.
The experiment below generates a fresh random AES key and IV for each run, encrypts this request and immediately reopens it to prove the round trip. It uses the exact TLS 1.3 record construction. Keeping its key fresh also avoids reusing the published RFC application key at sequence zero for a different plaintext, a habit that would be unsafe in a real connection.
HTTP/1.1 example: GET / with Host: example.com. Fresh random AES key and IV per run; this record is separate from the RFC fixture.
Ready. Computation runs locally when you press the button.
Padding changes the observed length, but there is no need for AES-GCM to round the content to a 16-byte block boundary. GCM’s counter-mode encryption can handle partial final blocks; its tag still occupies 16 bytes in TLS 1.3. A 37-byte request and a 1,024-byte request have the same fixed record overhead before padding.
Record order is authenticated indirectly by the implicit nonce sequence. If you replay a record at the next position in the same connection, the receiver computes a different nonce and the tag fails. If you drop a record from the byte stream and splice the next one forward, the same mismatch occurs. TCP handles ordinary retransmission below TLS, so duplicated TCP segments do not cause a second TLS record to be processed.
The server must receive and authenticate a complete record before releasing its content to the application. HTTP then applies its own message framing. A single HTTP request can span TLS records, and one TLS record can contain the end of one HTTP message and the start of another. Neither a TLS length nor a TCP packet boundary replaces HTTP’s parsing rules.
Living beyond the first request
Once established, the connection can protect many more requests without another certificate handshake. TLS 1.3 KeyUpdate advances an application traffic secret with the label traffic upd, then derives a new key and IV and resets that direction’s record sequence. The update message itself is protected using the old sending keys; subsequent records use the new ones.
A key update does not redo certificate validation or introduce a fresh Diffie–Hellman exchange. It limits use of a particular traffic key and evolves secrets forward. A receiver must process the update at the correct record boundary and coordinate the implicit counter with the new key. Trying both old and new keys until something decrypts is not the protocol’s state machine.
Shutdown also has authenticated meaning. A close_notify alert signals that the sender will send no more TLS messages. A bare TCP close can reflect interruption rather than a complete application response. HTTP framing and the caller’s needs determine whether a response is complete; TLS cannot supply application semantics merely because some earlier records authenticated.
Where the bytes become instructions
The first request is now bytes in a TCP stream, but the encryption itself runs as ordinary instructions. For AES-128-GCM, two pieces dominate the symmetric work: AES in counter mode creates a keystream to XOR with the plaintext, and GHASH authenticates the AAD and ciphertext. The tag combines that authentication result with an AES-derived mask.
AES works on 128-bit blocks. For a 96-bit nonce, GCM forms its initial counter block from the nonce and a fixed suffix, then increments the counter for encryption blocks. Distinct counter blocks can be processed in parallel. AES-128 uses ten rounds, with a key schedule expanded once for the record key and reused across records encrypted under that key.
On x86 CPUs with AES-NI, instructions such as AESENC and AESENCLAST perform AES rounds on registers. Newer vector AES instructions can process multiple blocks per instruction. On Arm implementations with the cryptography extensions, AESE and AESMC supply corresponding building blocks. These are hardware capabilities selected by a cryptographic library at runtime, not guarantees attached to the TLS suite name.
AES rounds: AESENC / AESE
Keystream XOR plaintextCiphertext
GHASH: PCLMULQDQ / PMULL
Polynomial hash + AES mask128-bit authentication tag
GHASH works in GF(2128), reducing polynomial products modulo x128 + x7 + x2 + x + 1. Carry-less multiplication instructions, such as x86 PCLMULQDQ and Arm PMULL, accelerate that work. “Carry-less” means polynomial coefficients combine with XOR, without the carries of ordinary integer multiplication. The associated data and ciphertext lengths also enter the authenticator.
Fast AES rounds alone do not guarantee fast GCM. The implementation also needs efficient GHASH, memory access and batching. On hardware without suitable acceleration, ChaCha20-Poly1305 can be an attractive alternative, built from additions, rotations, XORs and a different authenticator. The two peers negotiate a supported suite; they do not need identical CPUs to exchange records.
WebCrypto delegates these operations to the browser’s cryptographic implementation. Our page does not select CPU instructions, measure their throughput or implement an AES table in JavaScript. Production libraries also need constant-time behavior and side-channel hardening. A mathematically correct AES routine with secret-dependent memory access can expose keys through the machine executing it.
The record size is a latency decision
Large records amortize the five-byte header, inner type, tag and per-record work over more data. Small records create earlier authentication boundaries. On a slow link, a receiver cannot release a record’s first content byte while its remaining ciphertext and tag are still in flight. Sending a small first record can improve delivery time for an early useful part of a response.
- Records for 64 KiB
- 16
- TLS overhead
- 352 B
- First record at 1 Mbit/s
- 32.94 ms
Linear bar: 0–131.248 ms until a whole first record arrives. Model: 65,536 ready bytes, AES-GCM, no padding, 22 bytes overhead per record, no TCP/IP overhead or propagation.
A 4096-byte record trades 352 bytes of TLS overhead for a first authentication boundary after 32.94 ms of serialization.
The network adds other constraints. A TLS record can exceed the path’s TCP maximum segment size and span several segments. Losing one segment stalls the ordered byte stream, even if later segments arrive. Choosing a record size equal to an assumed Ethernet payload is therefore neither a general congestion-control strategy nor a guarantee against head-of-line blocking. Application write sizes, buffering and flushing policy also influence when a record is emitted.
On Linux, kTLS can move the symmetric record data path into the kernel after user-space handshake code has negotiated keys. The application configures the socket’s transmit and receive protection state; supported configurations may also offload record crypto to a NIC. Linux’s kTLS documentation describes this division. It can reduce copies and permit efficient file sending over encrypted connections, but does not eliminate encryption, certificate policy or key management.
Support depends on kernel, cipher, direction, device and library integration. A NIC’s offload feature does not make every TLS connection use it, and a browser request does not normally let page JavaScript choose the kernel’s TLS path. Key updates and error handling still have to keep the application’s TLS state consistent with whichever component owns the record keys.
Follow our request back up. Hardware instructions protected 38 bytes of inner plaintext with a key and an implicit nonce. A TLS record authenticated the visible header and hid the HTTP bytes. Those keys came from labeled HKDF expansions bound to a transcript. The transcript included ephemeral shares and a certificate-backed signature. That is why the browser could send GET / after one round trip and expect only the authenticated endpoint to read it.
The first round trip establishes identity and independent traffic keys. Every later record spends those keys through a strict nonce sequence, an AEAD tag and the machine’s cryptographic instructions.
End of TLS 1.3 · 11 levels, Idea to Silicon
Where to next
Next in Web and networking · 03 of 12
A passkey, from the button to the chip
Ana signs in without sharing a secret. Follow her passkey from a phone to a laptop, through the browser’s origin checks, a real signature, the USB frames and the hardware boundary that protects the key.
Practical notes
Read a TLS handshake from the command line
Use OpenSSL to check the certificate chain, hostname and negotiated parameters; use curl to see the HTTP request on the same connection.