Speed

Finished Closes the Handshake

Finished is an HMAC of the transcript hash under a key expanded from the handshake traffic secret; RFC 8448's server finished key is 008d3b66f816ea55 and a Finished message is 36 bytes.

The question

After the certificate comes the message that closes the handshake. How does Finished prove that both sides saw the same handshake and hold the same keys?

Each side sends a Finished message: an HMAC, under a key derived from its handshake traffic secret, of the hash of the handshake so far (RFC 9846, 4.5.3). This page uses numbers that RFC 8448 publishes for the demo and the secrets and hashes of the recorded loopback connection (a connection between two test programs, made on 2026-11-20 and kept as test material) for the exercise. The toy version of this check is the subject of Finished Checks the Transcript; here the key schedule is the real one.

Work it by hand

The finished key is HKDF-Expand-Label(BaseKey, "finished", "", 32): the same expansion as for a traffic key, with the label tls13 finished, 14 characters, and 32 bytes of output. Its info block is 0020, 0e, the 14 bytes of the label and 00: 00200e746c7331332066696e697368656400.

The verify data is HMAC-SHA-256 under the finished key of the transcript hash up to the message before Finished. The message is 14 (type 20), the length 000020 and the 32 bytes: 36 bytes in all. For the RFC 8448 server the published verify data starts 9b9b141d (stated here, not run). The server's Finished covers the messages up to CertificateVerify; the client's covers those up to the server's Finished and uses the client's handshake secret.

Run it

The command is the expand step that the previous lessons used, now with the label finished and 32 bytes of output. The secret is the RFC 8448 server handshake traffic secret of section 3. The result is the published finished key, which the RFC prints as 008d3b66f816ea559f96b537e885c31fc068bf492c652f01f288a1d8cdc19fc8.

The first 16 bytes of the published secret b6 7b 7d 69 and the first 16 bytes of the 32-byte finished key, starting 00 8d 3b 66.

Public test material, generated for this lesson. Never use it for anything real.

# HKDF-Expand of the finished key from the RFC 8448 server handshake secret.
# The info is the HkdfLabel for "finished": length 32, label "tls13 finished".
kdf -binary -keylen 32 -kdfopt digest:SHA256 -kdfopt hexkey:b67b7d690cc16c4e75e54213cb2d37b4e9c912bcded9105d42befd59d391ad38 \
  -kdfopt hexinfo:00200e746c7331332066696e697368656400 \
  -kdfopt mode:EXPAND_ONLY -out out.bin HKDF
{
  "answer": "008d3b66f816ea559f96b537e885c31fc068bf492c652f01f288a1d8cdc19fc8",
  "file": "out.bin",
  "bytes": 32
}

The RFC does not print the transcript hash for the HMAC step, and this page does not run it for the RFC trace: the hash is computable from the messages the RFC prints, but only the key is run here. You can change the numbers on the command line; a character that is not a hex digit ends the command with a message ending "illegal hex digit".

Your turn

A reader wants the whole Finished message from a handshake secret and a transcript hash, as the page built the key above. The program below is meant to return the 36-byte Finished message as hex for the traffic secret in secret and the transcript hash in transcript (32 bytes). Decide whether it does, and find the candidates that do. Check runs each candidate on the data shown and on four others. The secrets are test material; some are from the recording and some are made up.

The first 16 bytes of a traffic secret and the first 16 bytes of a transcript hash.

Public test material, generated for this lesson. Never use it for anything real.

let info = "0020" + "0e" + ssl.hex("tls13 finished") + "00";
let fk = ssl.hmac("SHA256", ssl.unhex(secret), ssl.unhex(info + "01"));
let data = ssl.hmac("SHA256", ssl.unhex(fk), ssl.unhex(transcript));
let answer = data;
{
  "answer": "5cf498dc3158ca37226c605b68ea269a4c411f9d4e31261fea091bccde30e447"
}

Return the Finished message as hex: the handshake type 20, the 3-byte length and the verify data, computed from the traffic secret in secret and the transcript hash in transcript (RFC 9846, 4.5.3).

Read the result carefully

A matching Finished shows that the sender knew the secret and saw the same transcript, in this recording, with keys that are known to anyone who reads this page. A recipient must check it and end the connection if it is wrong (RFC 9846, 4.5.3). The recording shows no failure: it contains one finished connection between two test programs.

The application data in the recording is a plain request over this one session; the page does not show another connection, a client certificate, a resumed session or an attacker. Nothing here says TLS is secure; it shows how one check is computed.

To run a fresh TLS 1.3 handshake with your own client and server in the tab, start with A TLS 1.3 Handshake You Can Step Through; to trigger failures, see TLS Failures You Can Trigger.

Recap

  • The finished key is expanded from the handshake traffic secret with the label tls13 finished.
  • The verify data is an HMAC of the transcript hash up to the message before Finished.
  • A Finished message is a handshake message of type 20.
  • Each side checks the other's Finished before application data is trusted.