Skip to content

[DTLS 1.3] Prep the Transcript_Hash_state + introduce strong record types - #6006

Merged
reneme merged 5 commits into
randombit:masterfrom
Rohde-Schwarz:dtls13/typed_records_transcript
Oct 6, 2026
Merged

reneme merged 5 commits into
randombit:masterfrom
Rohde-Schwarz:dtls13/typed_records_transcript

Conversation

@reneme

@reneme reneme commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

This prepares the Transcript_Hash_State for DTLS 1.3 (#5000) and adds strong record types (as subclasses of the Record_Content struct). The strong types are currently just unpacked at the usage location, but that'll change with the coming patches.

Details;

  • Handshake_Type::MessageHash — introduces the virtual handshake message type (RFC 9846 4.3.11.2) used for the transcript hash in the HelloRetryRequest case.
  • Record_Content strong types — adds subclasses of the generic Record_Content for each record type (AppData, Handshake, CCS, Alert) to enable type-safe dispatching in a later patch.
  • std::optional<Transcript_Hash_State> — the transcript hash state in Channel_Impl_13 can now be reset after the handshake completes
  • Split handshake header from message in Transcript_Hash_State — ::update() now explicitly takes the 4-byte handshake protocol header and the serialized message as separate strongly typed parameters, since DTLS 1.3 headers carry extra fields that must not be hashed.

No functional changes; each commit builds and passes the tests.

@reneme
reneme requested review from randombit and a balanced review from Copilot October 6, 2026 10:22
@reneme reneme self-assigned this Oct 6, 2026
Comment thread src/lib/tls/tls13/tls_types_13.h Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Successful handshakes can dereference a reset transcript optional, and additional transcript and type-invariant regressions remain unresolved.

Review effort: Balanced
Findings: 2 High severity · 2 Medium severity · 1 Low severity

Open (5)
What changed in this PR

Prepares TLS 1.3 internals for future DTLS 1.3 support through typed transcript components, optional transcript lifetime, and typed record variants.

Changes:

  • Splits handshake headers from message bodies during transcript hashing.
  • Introduces typed TLS record variants and record-number types.
  • Makes channel transcript state optional after handshake completion.
File Description
src/​tests/​test_tls_transcript_hash_13.cpp Updates transcript-hash tests.
src/​tests/​test_tls_record_layer_13.cpp Tests typed record variants.
src/​tests/​test_tls_handshake_layer_13.cpp Supplies TLS flavor to transcript state.
src/​tests/​test_tls_cipher_state.cpp Validates decrypted record variants.
src/​lib/​tls/​tls13/​tls_types_13.h Adds handshake and record strong types.
src/​lib/​tls/​tls13/​tls_transcript_hash_13.h Revises transcript-hash API and buffering.
src/​lib/​tls/​tls13/​tls_transcript_hash_13.cpp Implements split transcript processing.
src/​lib/​tls/​tls13/​tls_server_impl_13.cpp Adapts server transcript ownership.
src/​lib/​tls/​tls13/​tls_record_layer_13.h Exposes variant-based record results.
src/​lib/​tls/​tls13/​tls_record_layer_13.cpp Returns annotated record alternatives.
src/​lib/​tls/​tls13/​tls_record_13.h Defines typed record alternatives.
src/​lib/​tls/​tls13/​tls_record_13.cpp Maps content types to record variants.
src/​lib/​tls/​tls13/​tls_messages_13.h Adds TLS flavor to ClientHello construction.
src/​lib/​tls/​tls13/​tls_handshake_layer_13.cpp Splits headers before transcript updates.
src/​lib/​tls/​tls13/​tls_client_impl_13.cpp Adapts client transcript ownership.
src/​lib/​tls/​tls13/​tls_cipher_state.h Returns typed decrypted records.
src/​lib/​tls/​tls13/​tls_cipher_state.cpp Annotates decrypted record content.
src/​lib/​tls/​tls13/​tls_channel_impl_13.h Makes transcript state optional.
src/​lib/​tls/​tls13/​tls_channel_impl_13.cpp Handles variant records and transcript state.
src/​lib/​tls/​tls13/​msg_client_hello_13.cpp Propagates TLS flavor for PSK binders.
src/​lib/​tls/​tls_magic.h Adds handshake constants and MessageHash.
src/​lib/​tls/​tls_magic.cpp Stringifies MessageHash.
src/​lib/​tls/​tls_handshake_transitions.cpp Adds transition-mask support.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lib/tls/tls13/tls_channel_impl_13.cpp Outdated
Comment thread src/lib/tls/tls_magic.h
Comment thread src/lib/tls/tls13/tls_record_13.h
Comment thread src/lib/tls/tls13/tls_transcript_hash_13.cpp Outdated
Comment thread src/tests/test_tls_transcript_hash_13.cpp Outdated
@reneme
reneme force-pushed the dtls13/typed_records_transcript branch from 027989c to c0b250c Compare October 6, 2026 13:45
This is a 'virtual handshake message type' used to calculate a
transcript hash based on a previous ClientHello in the
HelloRetryRequest case.

Co-Authored-By: Amos Treiber <amos.treiber@rohde-schwarz.com>
@reneme
reneme force-pushed the dtls13/typed_records_transcript branch from c0b250c to 69d964a Compare October 6, 2026 13:47
reneme and others added 2 commits October 6, 2026 16:04
This introduces a bunch of subclasses to the generic Record_Content struct,
one for each supported record type (AppData, Handshake, CCS, Alert). In a
later patch this will be used for type safe dispatching of those types.

Co-Authored-By: Amos Treiber <amos.treiber@rohde-schwarz.com>
This allows resetting the transcript hash state after the handshake
completed.

Co-Authored-By: René Meusel <rene.meusel@rohde-schwarz.com>
@reneme
reneme force-pushed the dtls13/typed_records_transcript branch from 69d964a to 9698d8e Compare October 6, 2026 14:04
@reneme
reneme requested a balanced review from Copilot October 6, 2026 14:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

A non-PSK ClientHello can retain and expose a stale PSK binder transcript hash.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (5)

Comment thread src/lib/tls/tls13/tls_transcript_hash_13.cpp
atreiber94 and others added 2 commits October 6, 2026 16:46
Transcript_Hash_State::update() now takes the 4-byte handshake protocol
header and the serialized handshake message as separate, strongly typed
parameters. This is a preparatory refactoring for DTLS 1.3, where the
handshake protocol header carries additional fields (message_seq,
fragment_offset, fragment_length) that must not be naively hashed.

Also introduces strong types for marshalled handshake messages, message
flights and fragments as well as DTLS record numbers in tls_types_13.h
and passes the TLS_Flavor down to the transcript hash state.

Co-Authored-By: René Meusel <rene.meusel@rohde-schwarz.com>
Co-Authored-By: René Meusel <rene.meusel@rohde-schwarz.com>
@reneme
reneme force-pushed the dtls13/typed_records_transcript branch from 9698d8e to 850c1ea Compare October 6, 2026 14:46

@randombit randombit left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@reneme
reneme merged commit 156dd90 into randombit:master Oct 6, 2026
51 checks passed
@reneme
reneme deleted the dtls13/typed_records_transcript branch October 6, 2026 20:15
@reneme reneme mentioned this pull request Oct 8, 2026
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.

4 participants