Repository navigation
[DTLS 1.3] Prepare (D)TLS 1.2 implementation - #6001
Merged
reneme merged 2 commits intoOct 5, 2026
Merged
Conversation
This avoids a hard-to-read boolean flag in various constructors or function invocations. Co-Authored-By: René Meusel <rene.meusel@rohde-schwarz.com>
There was a problem hiding this comment.
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
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_Flavorthrough 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.
randombit
approved these changes
Oct 5, 2026
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
force-pushed
the
dtls13/tls12_implementation_prep
branch
from
October 5, 2026 11:34
a6ff0d3 to
8ecb722
Compare
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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_Flavorenum to replace variousis_datagramboolean 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 theis_serverflags and replace them with theConnection_Sideenum.#5000