Skip to content

TLS ECH keylogging#10259

Open
sebastian-carpenter wants to merge 2 commits into
wolfSSL:masterfrom
sebastian-carpenter:tls-ech-keylog
Open

TLS ECH keylogging#10259
sebastian-carpenter wants to merge 2 commits into
wolfSSL:masterfrom
sebastian-carpenter:tls-ech-keylog

Conversation

@sebastian-carpenter
Copy link
Copy Markdown
Contributor

@sebastian-carpenter sebastian-carpenter commented Apr 19, 2026

Description

Adds keylog support for TLS 1.3 ECH by exposing the HPKE shared secret and ECHConfig as new ECH_SECRET / ECH_CONFIG labels via the existing tls13SecretCb and OpenSSL tls13KeyLogCb callbacks. Enables Wireshark decryption of ECH-protected ClientHellos.

https://www.ietf.org/archive/id/draft-ietf-tls-keylogfile-05.html#name-secret-labels-for-ech

Changes

  • New Tls13Secret enum values, wired into keylog label tables.
  • hpke.c: capture HPKE shared secret when echSecret is allocated; new wc_HpkeInit/FreeEchSecret helpers.
  • tls.c: EchWriteKeyLog() emits both labels; TLSX_FinalizeEch/TLSX_ExtractEch now take WOLFSSL* and log after HPKE setup.
  • Gated on HAVE_SECRET_CALLBACK + HAVE_ECH; no overhead when unused.
  • Fixed when inner random is installed

Testing

  • Extended the existing test_wolfSSL_Tls13_Key_Logging_test to run an ECH handshake and assert the keylog file contains ECH_SECRET and ECH_CONFIG (and also EXPORTER_SECRET, which was previously unchecked).
  • Added testing to the same test_wolfSSL_Tls13_Key_Logging_test and test_wolfSSL_Tls13_Key_Logging_reject to verify the correct random is used.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@sebastian-carpenter sebastian-carpenter self-assigned this Apr 19, 2026
Copilot AI review requested due to automatic review settings April 19, 2026 03:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds TLS 1.3 ECH keylog support by exposing the HPKE shared secret and ECHConfig through existing TLS 1.3 secret/keylog callbacks to enable ECH ClientHello decryption in external tooling (e.g., Wireshark).

Changes:

  • Introduces new Tls13Secret labels (ECH_SECRET, ECH_CONFIG) and wires them into TLS 1.3 keylog label mapping.
  • Captures the HPKE shared secret during HPKE sender/receiver setup and logs ECH secret/config at ECH finalize/extract points.
  • Extends the TLS 1.3 keylog API test to validate presence of ECH labels (and now also checks EXPORTER_SECRET).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
wolfssl/wolfcrypt/hpke.h Adds optional Hpke::echSecret storage and local init/free helpers under HAVE_SECRET_CALLBACK && HAVE_ECH.
wolfcrypt/src/hpke.c Copies HPKE shared secret into echSecret when allocated; implements wc_HpkeInitEchSecret / wc_HpkeFreeEchSecret.
wolfssl/ssl.h Extends enum Tls13Secret with ECH_SECRET / ECH_CONFIG under HAVE_ECH.
wolfssl/internal.h Updates TLSX_FinalizeEch signature to accept WOLFSSL* ssl.
src/tls.c Adds EchWriteKeyLog() and logs ECH secret/config in TLSX_FinalizeEch (client) and TLSX_ExtractEch (server).
src/tls13.c Updates ECH finalize callsite; updates tls13ShowSecrets() string mapping for new labels.
src/internal.c Updates OpenSSL-extra TLS 1.3 keylog label mapping to include ECH labels.
tests/api.c Extends TLS 1.3 keylog test to expect ECH labels (and now EXPORTER_SECRET).

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

Comment thread src/tls.c
Comment thread src/tls.c Outdated
Comment thread tests/api.c Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 19, 2026

MemBrowse Memory Report

No memory changes detected for:

@sebastian-carpenter sebastian-carpenter force-pushed the tls-ech-keylog branch 2 times, most recently from e3117f4 to 887b69e Compare May 12, 2026 16:05
@sebastian-carpenter
Copy link
Copy Markdown
Contributor Author

sebastian-carpenter commented May 12, 2026

Jenkins retest this please.

@sebastian-carpenter sebastian-carpenter marked this pull request as ready for review May 13, 2026 15:33
Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10259

Scan targets checked: wolfcrypt-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src

No new issues found in the changed files. ✅

Comment thread src/tls.c
Comment thread tests/api.c
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.

5 participants