Skip to content

Size ENCRYPT_LEN for both (EC)DHE-PSK pre-master secret length fields - #11483

Open
gasbytes wants to merge 1 commit into
wolfSSL:masterfrom
gasbytes:dhe-psk-premaster-fix
Open

gasbytes wants to merge 1 commit into
wolfSSL:masterfrom
gasbytes:dhe-psk-premaster-fix

Conversation

@gasbytes

Copy link
Copy Markdown
Contributor

Description

ENCRYPT_LEN covers both 2-byte length prefixes, so a max-size DH prime plus a max-length PSK fits the buffer.

Thanks to Anthropic for the report.

Testing

Added associated regression test (test_tls12_dhe_psk_max_pms).

Checklist

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

@gasbytes gasbytes self-assigned this Sep 17, 2026
Copilot AI lite review requested due to automatic review settings September 17, 2026 11:48

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.

🟡 Changes recommended

Critical buffer-sizing and regression-coverage issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes TLS 1.2 (EC)DHE-PSK pre-master-secret buffer sizing and adds a maximum-size regression test.

Changes:

  • Accounts for both 2-byte length prefixes in ENCRYPT_LEN.
  • Adds and registers maximum-size DHE-PSK test coverage.
File summaries
File Summary Review status
wolfssl/internal.h Adjusts pre-master-secret buffer sizing. Critical: May underallocate for 16384-bit DH configurations.
tests/api/test_tls.h Declares and registers the regression test. Reviewed.
tests/api/test_tls.c Implements maximum-size DHE-PSK coverage. Critical: Test is skipped for supported maximum sizes beyond the listed fixtures.
Review details

Suppressed comments (1)

tests/api/test_tls.c:652

  • TEST_TLS12_DHE_PSK_DH_FILE enables code that calls file-based DH setup, the client/server TLS 1.2 method APIs, and the default RSA certificate fixture. Its current definition is not gated for NO_FILESYSTEM/NO_CERTS/PEM-disabled, client/server-disabled, or NO_RSA builds, so reduced configurations can fail to compile, link, or initialize this test. Gate the fixture macro on those prerequisites (or provide buffer-based fixtures).
#if MAX_DHKEY_SZ == 512
    #define TEST_TLS12_DHE_PSK_DH_FILE "./certs/dh4096.pem"
#elif MAX_DHKEY_SZ == 384
    #define TEST_TLS12_DHE_PSK_DH_FILE "./certs/dh3072.pem"
#elif MAX_DHKEY_SZ == 256
    #define TEST_TLS12_DHE_PSK_DH_FILE "./certs/dh2048.pem"
#endif
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

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

Comment thread tests/api/test_tls.c Outdated
Comment thread wolfssl/internal.h
@gasbytes
gasbytes force-pushed the dhe-psk-premaster-fix branch from b2dbf81 to 60eaf09 Compare September 17, 2026 12:04
@gasbytes gasbytes assigned wolfSSL-Bot and unassigned gasbytes Sep 17, 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.

3 participants