Skip to content

[DTLS 1.3] Prepare (D)TLS 1.2 implementation - #6001

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

reneme merged 2 commits into
randombit:masterfrom
Rohde-Schwarz:dtls13/tls12_implementation_prep

Conversation

@reneme

@reneme reneme commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

This prepares the (D)TLS 1.2 stack for DTLS 1.3 support. Most notably: The downgrade mechanics must be prepared to receive fragment sequence numbers from a downgrading (D)TLS 1.3 stack. If we started off as DTLS 1.3 and sent/received a ClientHello that needed fragmentation, these fragment sequence numbers don't start at "0" for the incoming DTLS 1.2 implementation.

Additionally, this introduces a TLS_Flavor enum to replace various is_datagram boolean flags in function signatures. That is mostly a readability improvement that we introduced in DTLS 1.3 and applied to DTLS 1.2 for consistency. At some point in the future, we might do the same with the is_server flags and replace them with the Connection_Side enum.

#5000

This avoids a hard-to-read boolean flag in various constructors
or function invocations.

Co-Authored-By: René Meusel <rene.meusel@rohde-schwarz.com>
@reneme
reneme requested review from randombit and a balanced review from Copilot October 5, 2026 09:44
@reneme reneme self-assigned this Oct 5, 2026

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

Downgrade replay can discard early fragments, and the replacement DTLS state cannot retransmit the original ClientHello.

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

Open (2)
What changed in this PR

Prepares TLS/DTLS 1.2 for DTLS 1.3 downgrade handoff and replaces internal datagram booleans with TLS_Flavor.

Changes:

  • Transfers epoch-zero sequence numbers during downgrade.
  • Propagates TLS_Flavor through TLS 1.2 APIs.
  • Updates downgrade detection and ServerHello generation.
File Description
src/​lib/​tls/​tls13/​tls_types_13.h Defines downgrade sequence-number state.
src/​lib/​tls/​tls13/​tls_channel_impl_13.cpp Initializes downgrade flavor metadata.
src/​lib/​tls/​tls13/​msg_server_hello_13.cpp Supplies TLS flavor for random generation.
src/​lib/​tls/​tls12/​tls_server_impl_12.h Adopts TLS_Flavor in server construction.
src/​lib/​tls/​tls12/​tls_server_impl_12.cpp Propagates flavor through server behavior.
src/​lib/​tls/​tls12/​tls_seq_numbers.h Adds initial DTLS sequence counters.
src/​lib/​tls/​tls12/​tls_record.h Changes record API to use flavor.
src/​lib/​tls/​tls12/​tls_record.cpp Selects record parsing by flavor.
src/​lib/​tls/​tls12/​tls_messages_12.h Extends ServerHello constructors with flavor.
src/​lib/​tls/​tls12/​tls_client_impl_12.h Adopts flavor in client construction.
src/​lib/​tls/​tls12/​tls_client_impl_12.cpp Adds DTLS downgrade state restoration.
src/​lib/​tls/​tls12/​tls_channel_impl_12.h Stores flavor and accepts sequence counters.
src/​lib/​tls/​tls12/​tls_channel_impl_12.cpp Applies flavor and initializes counters.
src/​lib/​tls/​tls12/​msg_server_hello_12.cpp Passes flavor into random generation.
src/​lib/​tls/​tls_server.cpp Maps public datagram selection to flavor.
src/​lib/​tls/​tls_messages.h Exposes TLS 1.3 offer detection.
src/​lib/​tls/​tls_messages_internal.h Updates ServerHello random API.
src/​lib/​tls/​tls_client.cpp Maps offered version to flavor.
src/​lib/​tls/​tls_channel_impl.h Expands downgrade handoff metadata.
src/​lib/​tls/​msg_server_hello.cpp Accepts flavor during random generation.
src/​lib/​tls/​msg_client_hello.cpp Detects TLS/DTLS 1.3 offers.

💡 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/tls12/tls_client_impl_12.cpp Outdated
Comment thread src/lib/tls/tls12/tls_seq_numbers.h Outdated
This sets up the protocol downgrade mechanics to handle downgrades
from DTLS 1.3. Most notably, this requires handing over the current
read/write fragment sequence numbers (e.g. if a ClientHello was
transmitted as multiple fragments).

Co-Authored-By: René Meusel <rene.meusel@rohde-schwarz.com>
@reneme
reneme force-pushed the dtls13/tls12_implementation_prep branch from a6ff0d3 to 8ecb722 Compare October 5, 2026 11:34
@reneme
reneme merged commit fda1644 into randombit:master Oct 5, 2026
51 checks passed
@reneme
reneme deleted the dtls13/tls12_implementation_prep branch October 5, 2026 12:31
@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