Skip to content

F-5606: don't enforce DTLS 1.3 2^48-1 epoch cap on the receive side#10627

Open
julek-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
julek-wolfssl:fenrir-fixes-20260601-dtls13-recv-epoch
Open

F-5606: don't enforce DTLS 1.3 2^48-1 epoch cap on the receive side#10627
julek-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
julek-wolfssl:fenrir-fixes-20260601-dtls13-recv-epoch

Conversation

@julek-wolfssl

Copy link
Copy Markdown
Member

Summary

Follow-up to F-5606 (#10575). RFC 9147 Section 8's 2^48-1 epoch ceiling is a sender-only rule; the same paragraph states that receiving implementations MUST NOT enforce it ("In order to allow this value to be changed later").

The KeyUpdate receive path in DoTls13KeyUpdate was rejecting a peer epoch that crossed 2^48-1, which violates that requirement. This changes the receive-side guard to catch only the genuine wrap-to-zero (RFC 9147 Section 4.2.1) — which would alias epoch 0 and reuse keys — and otherwise lets the receiving (peer) epoch advance past 2^48-1.

The sender-side gates that keep our own epoch at or below 2^48-1 (SendTls13KeyUpdate, Dtls13KeyUpdateAckReceived) are unchanged.

Testing

  • ./configure --enable-dtls13 --enable-dtls and rebuild — compiles cleanly under -Wall -Wextra.

Depends on #10575, which introduces the F-5606 code this corrects. The other commits shown here belong to #10575 and will drop out of this diff once it merges to master.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates wolfSSL’s DTLS 1.3 KeyUpdate receive-path epoch handling to align with RFC 9147 by no longer enforcing the 2^48-1 ceiling on received epochs (while still preventing the dangerous wrap-to-zero), and it also includes several TLS/DTLS conformance and crypto hardening follow-up changes that are noted as coming from the dependent PR.

Changes:

  • DTLS 1.3: adjust KeyUpdate receive-side epoch advancement to only reject wrap-to-zero, while keeping sender-side epoch ceiling checks.
  • TLS 1.3: tighten CertificateRequest validation (context rules, duplicate context rejection for post-handshake auth, and require signature_algorithms).
  • OpenSSL-compat / protocol hardening fixes: wolfSSL_get_verify_result(NULL) returns a non-zero X509-style error, chunked wolfSSL_CRYPTO_memcmp, stricter ALPN/MFL response parsing, DH shared-secret right-justification fix, Camellia key schedule free, and DTLS 1.3 epoch slot eviction fix.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
wolfssl/ssl.h Adds an OpenSSL-compatible verify error code used by wolfSSL_get_verify_result(NULL).
wolfssl/internal.h Introduces DTLS 1.3 epoch max constants used by sender-side KeyUpdate gating.
tests/api.c Updates API test expectations for wolfSSL_get_verify_result(NULL).
src/tls13.c Tightens TLS 1.3 CertificateRequest parsing and adjusts DTLS 1.3 KeyUpdate receive epoch logic.
src/tls.c Adds stricter input validation for group setters and hardens ALPN/MFL response parsing.
src/ssl.c Changes OpenSSL-compat behaviors (get_verify_result, CRYPTO_memcmp) and group count validation message.
src/pk.c Fixes DH padded shared-secret right-justification for short outputs.
src/internal.c Ensures Camellia key schedule is freed/zeroized before deallocation.
src/dtls13.c Fixes epoch slot eviction selection and hardens sender epoch increment validation on KeyUpdate ACK.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wolfssl/internal.h Outdated
RFC 9147 Section 8's 2^48-1 epoch ceiling is a sender-only rule; the same
paragraph says receiving implementations MUST NOT enforce it. The KeyUpdate
receive path was rejecting a peer epoch that crossed 2^48-1, violating that.
Guard only the genuine wrap-to-zero (Section 4.2.1) and let the receiving
epoch advance past 2^48-1. The sender-side gates are unchanged.
@julek-wolfssl julek-wolfssl force-pushed the fenrir-fixes-20260601-dtls13-recv-epoch branch from a933eba to 5c72732 Compare June 8, 2026 12:43
@julek-wolfssl julek-wolfssl marked this pull request as ready for review June 8, 2026 13:14
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

retest this please

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.

[Bug]: DTLS 1.3 Sending Epoch Limit Is Only Checked for 64-bit Wrap

2 participants