Speed

The ClientHello Grows With the Name

The size of a flight is the sum of 5 plus the length over its records, and the first flight depends on what the client says: the server name travels in the ClientHello in the clear. Measure two names in this tab, then compute a flight's size from its record headers.

The question

The last lesson split a flight into records. The size of the flight is then the sum, over its records, of the 5-byte header and the bytes behind it. The first flight, the client's ClientHello, depends on what the client says. In particular the server name that the client asks for travels in the ClientHello in the clear (RFC 9846 section 4.2.2 describes the ClientHello; the server_name extension is defined in RFC 6066). Does a longer name make a longer flight?

Work it by hand

The first record of the demo below has a length field of 310 in this build, so the flight is 5 plus 310 = 315 bytes. For the name www.example.test, 16 characters, the program measures 315. For example.test, 12 characters, the run below shows 311. The names differ by 4 characters and the flights by 4 bytes.

The next two flights are the same for both names: 2332 and 80 bytes. The last flight, the server's session tickets, is shown as a dash: its length is not the same in every run (in some repeated runs it was 16 bytes shorter). The name is part of the ClientHello only. The lengths are from this build (lmssl 0.2.2, OpenSSL 4.0.3): another client offers other groups and its hello has another length.

Run it

The function in lines 1 to 13 runs one pair and returns the flight lengths as a text. A function does not see the inputs, so line 6 takes the name as a parameter, and the program calls it twice, in lines 14 and 15: once for host and once for other_host. Line 20 returns how many bytes the first flight of the first name is longer than the other.

The name www.example.test with flights of 315, 2332 and 80 bytes and a dash for the last one, the name example.test with flights of 311, 2332 and 80 bytes and a dash, and the first flights differing by 4 bytes.

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

fn sizes(c: string, k: string, m: string, r: string, h: string) -> string {
  let server = ssl.server_ctx(ssl.parse_cert(c), ssl.parse_key(k));
  server.chain(ssl.parse_cert(m)); server.groups("X25519");
  let client = ssl.client_ctx(); client.add_ca(ssl.parse_cert(r));
  client.groups("X25519");
  let pair = ssl.tls_pair(client, server, h); let text = ""; let turns = 0;
  while (!pair.done() && pair.error() == "" && turns < 10) {
    let size = str(str_len(pair.step())); turns = turns + 1;
    if (pair.done()) { size = "-"; }
    text = text + size + " ";
  }
  return str_trim(text);
}
let a = sizes(leaf_pem, leaf_key, int_pem, root_pem, host);
let b = sizes(leaf_pem, leaf_key, int_pem, root_pem, other_host);
lmcode_return_put("sizes_host", a);
lmcode_return_put("sizes_other", b);
let first_a = str_to_int(str_split(a, " ").at(0));
let first_b = str_to_int(str_split(b, " ").at(0));
let answer = first_a - first_b;
{
  "answer": 4,
  "sizes_host": "315 2332 80 -",
  "sizes_other": "311 2332 80 -"
}

The picture shows the lengths of both runs. The oracle of this page computes the answer from the rule, the difference of the lengths of the two names, and not from a handshake: Python's own ClientHello is padded to 512 bytes and cannot show the difference. The rule is valid for two DNS names.

The certificates and the key that the page passes in are test material. You can change host and other_host. A name the certificate does not cover, such as www.example.testx, still runs but the client refuses the certificate: the lengths of that run are 316 2332 7 and the answer is 5. An IP address or an empty name sends no name: 192.0.2.7 as host gives 290 2332 7 and the answer -21, and an empty other_host gives 25, so the rule above no longer describes those runs.

A name of one character, such as x, stops line 6, inside the function, with "Line 6: Ssl.tls_pair: set host to verify".

Your turn

The program below is meant to return the length of a flight in bytes from the headers of its records. The input headers is hex: the 5-byte headers back to back, taken from a handshake made in this tab, as in the last lesson.

You can edit the hex (whole bytes, lowercase); the programs here read only complete groups of 5 bytes, and a hex with no complete group has no records. Decide whether it does, and find the candidates that do. Check runs each candidate on the data shown and on six others.

The 30 bytes of six record headers, back to back, and the number that the shown program returns as the length of the flight.
let total = 0; let at = 0; let count = 0;
while (at + 5 <= hex_len(headers)) {
  total = total + hex_u16(headers, at + 3);
  at = at + 5; count = count + 1;
}
let answer = total + 5;
lmcode_return_put("records", count);
{
  "answer": 2307,
  "records": 6
}

headers holds the 5-byte headers of the records of one flight, back to back, in hex: one byte of type, two of version, two of length. The length field gives the number of bytes behind the header. Return, as a whole number, the length of the whole flight in bytes: the sum over all records of the header and the bytes behind it. Check runs your program with the headers of other flights.

Read the result carefully

Anyone who sees the first flight can read the name: the page shows only its length, but the name is in the bytes. With an IP address or an empty name no name is sent, and the first flight is shorter. The lengths of this page belong to this build, and the two ends are test endpoints in this tab's memory.

The test chain is valid from 2026-01-01 to 2036-01-01 and the client checks the dates against the reader's clock; outside those years the handshake ends with a certificate error. The bytes of a ClientHello are in the recording of A TLS 1.3 Handshake, Message by Message, not here: they differ on every run.

Recap

  • A flight is as long as the sum of 5 plus the length of each of its records.
  • The server name is in the ClientHello, so a longer name makes a longer first flight.
  • The other flights do not depend on the name.
  • Lengths are what this build does, not a rule of the protocol.