The Handshake Is Thirteen Records
A recorded TLS 1.3 connection has 13 records: two plaintext hellos, two change_cipher_spec records and nine records of outer type 23, and seven of the 13 carry the handshake messages.
The question
One TLS 1.3 handshake is seven messages: ClientHello, ServerHello, EncryptedExtensions, Certificate, CertificateVerify and two Finished. The recording holds 13 records. Which of them carry those messages, and which records can an observer who has no keys tell apart?
This book reads one recording: a handshake between two test programs on one computer, lmssl s_server and lmssl s_client, made on 2026-11-20 with OpenSSL 4.0.3 and kept in the repository as test material. Everything quoted from it is bytes of that one connection. The five header bytes of a record are the subject of TLS Records Carry a Length; here they are only used.
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. The live runs produce new randoms and key shares, rather than replaying these bytes.
Work it by hand
A record starts with a type byte, two version bytes and a two-byte length. Take the first bytes of the recording, 16 03 01 01 32. The type 0x16 is 22, a handshake record. The length 0x0132 is 306, so the record is 5 + 306 = 311 bytes long and the next header starts at byte 311.
Counting the whole recording this way gives 13 records. The two hellos are plaintext handshake records (outer type 22). Each side sends one change_cipher_spec record (type 20, a single 01 byte), and that is not a handshake message. The other nine records have outer type 23, application_data, whatever they contain: five hold handshake messages, two hold the HTTP request and reply, and two hold alerts (stated from the recording's decrypted types, not run on this page).
Only a byte inside a decrypted record tells its real type: the last byte, when the sender added no padding, as in this recording (RFC 9846, 5.1, 5.2 and 5.4): handshake 22, application_data 23 or alert 21. Without the keys an observer sees type 23 and a length.
Run it
The program takes the bytes of back-to-back records as hex in stream and walks them. Line 3 starts the loop that stops when pos reaches the end of the data; line 4 reads the type byte at pos, line 10 the length at pos + 3, and line 11 adds one row. Line 12 moves pos over the 5 header bytes and the body; line 15 returns the rows. The input is the first three records of the recording, 444 bytes.

Watch the steps (recorded video)
Public test material, generated for this lesson. Never use it for anything real.
let rows = str_list();
let pos = 0; let n = 1;
while (pos < hex_len(stream)) {
let kind = hex_u8(stream, pos);
let name = "other";
if (kind == 22) { name = "handshake"; }
if (kind == 20) { name = "change_cipher_spec"; }
if (kind == 23) { name = "application_data"; }
if (kind == 21) { name = "alert"; }
let len = hex_u16(stream, pos + 3);
rows.add(str(n) + "|" + name + "|" + str(len));
pos = pos + 5 + len;
n = n + 1;
}
let answer = rows;
{
"answer": [
"1|handshake|306",
"2|handshake|122",
"3|change_cipher_spec|1"
]
}You can change the stream to any bytes made of records. A record whose body is cut off is still listed with the length it states (a stream cut to 434 bytes gives two rows, measured); a cut inside a header stops the run with "byte 441 is past the end of the data" (measured with 441 bytes); an empty stream gives an empty list; an unknown type byte is named other. The page takes at most 1024 bytes of hex.
Your turn
A monitor wants the outer shape of a stream of records: how many plaintext handshake records, how many change_cipher_spec records and how many application_data records it holds, and how many bytes the whole stream takes on the wire. The program below is meant to return those four numbers, in that order, as a list of integers.
Records of any other outer type are not counted in the first three numbers, but their bytes are in the fourth. Decide whether it does, and find the candidates that do. Check runs each candidate on the stream shown and on six others. The streams are made of records of the recording or built by hand; they are test material.

Public test material, generated for this lesson. Never use it for anything real.
let total = hex_len(stream);
let pos = 0; let hs = 0; let ccs = 0; let prot = 0;
while (pos < total) {
let kind = hex_u8(stream, pos);
if (kind == 22) { hs = hs + 1; }
if (kind == 20) { ccs = ccs + 1; }
if (kind == 23) { prot = prot + 1; }
pos = pos + 5 + hex_u16(stream, pos + 3);
}
let answer = int_list();
answer.add(hs); answer.add(prot); answer.add(ccs); answer.add(pos);
{
"answer": [
0,
3,
1,
128
]
}Return a list of four integers: the number of records with outer type 22, with outer type 20 and with outer type 23, and the total number of bytes of the stream, headers included. Records of other outer types are counted in no list entry but the last.
Read the result carefully
The page decodes outer types because it has the bytes. It does not decrypt anything in this lesson, and it does not say what a real network shows: one recorded connection between two test programs cannot show other servers, other clients or other versions. The counts hold for this handshake only: a different server, a resumed session or a HelloRetryRequest changes the number of records.
The fourth number is the size of the records on the wire, not of the messages inside them. The tool's own summary of the recording says that the client had read 2344 bytes and written 375 bytes when the handshake finished (stated in trace.txt of the recording, not recomputed by this page).
Recap
- A TLS record is a 5-byte header (type, legacy version, length) and a body of that length.
- This recording has 13 records: 2 plaintext handshake records, 2 change_cipher_spec records and 9 records of outer type 23.
- The outer type of a protected record is 23; the real type is the last byte inside it, visible only with the keys.
- A change_cipher_spec record is not a handshake message.