Read a TLS 1.3 record by hand

The padlock and the one extra round trip. This lesson opens the messages inside that round trip and reads every byte.
A developer runs tcpdump on a server because HTTPS requests to it are failing. The capture opens in a viewer. The first packet after the TCP handshake is readable: a name, a list of options. The next packets are a wall of hex with no meaning. The developer cannot tell whether the server rejected the client, the client rejected the server, or the network cut the connection in the middle.
By the end of this lesson you will be able to take the bytes of a TLS 1.3 handshake, split them into records, read every field of the ClientHello, and name each step of the key schedule. You will also run a hand-written client that decrypts the server’s side of the handshake and checks its own keys against OpenSSL’s.
The history (optional)
TLS 1.3 was published as RFC 8446 in August 2018, with Eric Rescorla of Mozilla as author. It replaced TLS 1.2 (RFC 5246). Part of the design was making the handshake look like TLS 1.2 on the wire, so that firewalls and other boxes between two machines would not block it. You will see that in the bytes: a version field that says 1.2 or 1.0, a dummy record, and a session id that is not used for sessions. (RFC 8446 has since been marked as replaced by a newer RFC. The record and key schedule layout below is the same one.)
Before you start. The whisper code (how a call goes private) showed that TLS costs one extra round trip, and that the two sides agree a secret while others listen. TCP vs UDP, and the 3-way handshake gave you the TCP connection that TLS bytes travel on, in order. Build it: read the capture (a pcap reader, layer by layer) taught the habit used here: trust the length inside a header, not the size of the container. A byte is written as two hex characters, so 16 is one byte.