Skip to content

Validate custom curve points and ECDH parameters - #12252

Open
ageprocpp wants to merge 5 commits into
wolfSSL:masterfrom
ageprocpp:fix/fenrir-19103
Open

ageprocpp wants to merge 5 commits into
wolfSSL:masterfrom
ageprocpp:fix/fenrir-19103

Conversation

@ageprocpp

@ageprocpp ageprocpp commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes Fenrir #19103

Validate untrusted X9.63 public points against the selected custom curve during import. In wc_ecc_shared_secret(), reject custom-curve keys when their stored size, cofactor, prime, a, b, order, Gx, or Gy values differ. Custom curves share the ECC_CURVE_CUSTOM id, so comparing only the curve id does not distinguish different parameter sets.

Testing

Built and ran the targeted API test with custom curves enabled and the minimum ECC size set to zero.

./configure --enable-ecccustcurves --with-eccminsz=0 --disable-shared --enable-static --enable-examples --enable-crypttests
make -j8 tests/unit.test
./tests/unit.test --api -test_wc_ecc_shared_secret_custom_curve_match

The regression test verifies that import rejects an off-curve point, ECDH succeeds when the stored custom-curve parameters match, and wc_ecc_shared_secret() returns ECC_BAD_ARG_E when they differ.

Some existing tests generated errors by giving invalid off-curve points, so changed it to valid points provided that the modification can keep the original intention for those tests.

Checklist

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

Copilot AI balanced review requested due to automatic review settings November 24, 2026 21:27

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

wolfSSL-Fenrir-bot

This comment was marked as resolved.

wolfSSL-Fenrir-bot

This comment was marked as resolved.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot 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.

Fenrir Automated Review — PR #12252

Scan targets checked: wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): tests/api/test_ecc.h
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed stale reviews from themself November 25, 2026 07:31

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

@ageprocpp
ageprocpp marked this pull request as ready for review November 25, 2026 07:32
@github-actions

Copy link
Copy Markdown

retest this please

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

gcc-arm-cortex-m0plus

  • FLASH: .text +112 B (+0.2%, 72,576 B / 262,144 B, total: 28% used)

gcc-arm-cortex-m3

  • FLASH: .text +236 B (+0.2%, 134,310 B / 262,144 B, total: 51% used)

gcc-arm-cortex-m4

  • FLASH: .text +256 B (+0.1%, 211,693 B / 262,144 B, total: 81% used)

gcc-arm-cortex-m4-baremetal

  • FLASH: .text +128 B (+0.2%, 75,380 B / 262,144 B, total: 29% used)

gcc-arm-cortex-m4-crypto-only

  • FLASH: .text +128 B (+0.1%, 184,272 B / 262,144 B, total: 70% used)

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +448 B (+0.2%, 199,652 B / 1,048,576 B, total: 19% used)

gcc-arm-cortex-m4-min-ecc

  • FLASH: .text +128 B (+0.2%, 69,782 B / 262,144 B, total: 27% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .rodata +48 B, .text +1,152 B (+0.1%, 804,296 B / 1,048,576 B, total: 77% used)
  • RAM: .bss +64 B, .data +16 B (+0.1%, 121,760 B / 262,144 B, total: 46% used)

gcc-arm-cortex-m4-pkcs7

  • FLASH: .text +256 B (+0.1%, 225,937 B / 262,144 B, total: 86% used)

gcc-arm-cortex-m4-pq

  • FLASH: .text +768 B (+0.2%, 318,512 B / 1,048,576 B, total: 30% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .text +832 B (+0.2%, 348,840 B / 1,048,576 B, total: 33% used)

gcc-arm-cortex-m4-sp-math

  • FLASH: .text +128 B (+0.2%, 69,782 B / 262,144 B, total: 27% used)

gcc-arm-cortex-m4-tls12

  • FLASH: .text +256 B (+0.2%, 135,054 B / 262,144 B, total: 52% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +704 B (+0.3%, 254,791 B / 262,144 B, total: 97% used)

gcc-arm-cortex-m7

  • FLASH: .text +256 B (+0.1%, 211,693 B / 262,144 B, total: 81% used)

gcc-arm-cortex-m7-pq

  • FLASH: .text +768 B (+0.2%, 319,344 B / 1,048,576 B, total: 30% used)

gcc-arm-cortex-m7-tls13

  • FLASH: .text +704 B (+0.3%, 254,791 B / 262,144 B, total: 97% used)

stm32-sim-stm32h753

  • FLASH: .text +64 B (+0.0%, 210,028 B / 2,097,152 B, total: 10% used)

zephyr-frdm_rw612

  • FLASH: text +16 B (+0.0%, 296,492 B / 67,108,864 B, total: 0% used)

Catch memory regressions in CI with MemBrowse. Free for open source.

@ageprocpp ageprocpp assigned wolfSSL-Bot and unassigned ageprocpp Nov 25, 2026
Comment thread wolfcrypt/src/ecc.c Resolved
Comment thread wolfcrypt/src/ecc.c Resolved
@ageprocpp
ageprocpp requested a review from SparkiDev November 26, 2026 05:36
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