Skip to content

feat: tls 1.3 handshake message parsers - #436

Merged
kacy merged 1 commit into
mainfrom
feat/mtls-handshake-parsers
Jun 9, 2026
Merged

feat: tls 1.3 handshake message parsers#436
kacy merged 1 commit into
mainfrom
feat/mtls-handshake-parsers

Conversation

@kacy

@kacy kacy commented Jun 7, 2026

Copy link
Copy Markdown
Owner

summary

second PR-4 chunk (after #435). adds the TLS 1.3 handshake message
parsers the client driver will need, plus a small iterator for walking
the packed handshake stream that comes out of a single decrypted record.

no behavior change — these are pure decoders. mirrors the senders in
message_build.zig one-for-one so a builder + parser test covers each
message format.

what's in here

src/tls/handshake/message_parse.zig with:

  • nextMessage(stream, &pos) — walks the concatenated stream of
    handshake messages, returns each as { msg_type, body, raw } (raw
    is what feeds the transcript hash on both sides)
  • parseServerHello — extracts server_random, X25519 share; rejects
    anything that isn't TLS 1.3 / AES-256-GCM / X25519
  • parseEncryptedExtensions — selected ALPN (or null)
  • parseCertificateMessage — leaf cert DER (single-cert chain only,
    matches what we issue)
  • parseCertificateVerify — algorithm code + signature DER
  • parseFinished — verify_data slice
  • parseCertificateRequest — context + raw SignatureSchemeList, plus
    a certRequestOffersEcdsaP256Sha256 helper for the only scheme we
    actually understand

tests

eight round-trip tests (builder → parser) cover every message type plus
a packed-stream walk and a truncated-stream rejection.

not in this PR

  • ClientHello builder + parameterized CertificateVerify context string
  • client session driver
  • server-side CertificateRequest + client-cert verify path

still security-sensitive (it's the wire format), so no auto-merge —
landing in chunks per your earlier instruction.

mirror the senders in message_build.zig — server_hello, encrypted_
extensions, certificate (single-leaf only), certificate_verify,
finished, certificate_request — plus a small nextMessage iterator
since the server packs several handshake messages into one record.
narrow profile (AES-256-GCM / X25519 / ECDSA-SHA256) so the parsers
reject anything the rest of the stack can't handle anyway.

eight round-trip tests against the existing builders cover every
parser, including the certificate_request scheme-list check.
@kacy
kacy merged commit a5e135d into main Jun 9, 2026
10 checks passed
@kacy
kacy deleted the feat/mtls-handshake-parsers branch June 9, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant