Skip to content

Reject small-order public keys for Ed25519 and Ed448#10540

Open
Frauschi wants to merge 1 commit into
wolfSSL:masterfrom
Frauschi:small_order_check
Open

Reject small-order public keys for Ed25519 and Ed448#10540
Frauschi wants to merge 1 commit into
wolfSSL:masterfrom
Frauschi:small_order_check

Conversation

@Frauschi
Copy link
Copy Markdown
Contributor

@Frauschi Frauschi commented May 27, 2026

Add defense-in-depth checks to wc_ed{25519,448}_check_key() and ed{25519,448}_verify_msg_final_with_sha() that reject the identity point and other small-order public keys. Honest EdDSA key generation never produces such keys, but we previously accepted them on import and verification. The guard runs at both entry points so it holds even when a key is imported with trusted=1.

Fixes zd21881. Thanks to piquo, HOOKED! / Majestic Labs for reporting.

@Frauschi Frauschi self-assigned this May 27, 2026
@Frauschi Frauschi force-pushed the small_order_check branch 2 times, most recently from 92256d8 to 47406e2 Compare May 28, 2026 07:50
@Frauschi
Copy link
Copy Markdown
Contributor Author

Jenkins retest this please

@Frauschi Frauschi changed the title Reject small-order public keys for Edwards and Montgomery curves Reject small-order public keys for Ed25519 and Ed448 May 28, 2026
@Frauschi Frauschi assigned wolfSSL-Bot and unassigned Frauschi May 28, 2026
@JacobBarthelmeh JacobBarthelmeh requested a review from Copilot May 28, 2026 16:05
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

This PR adds defense-in-depth checks to Ed25519 and Ed448 public-key handling to reject identity/small-order points at both key-check and signature-verification entry points, and extends test coverage to exercise the new rejection behavior.

Changes:

  • Add small-order public key detection to wc_ed25519_check_key() / wc_ed448_check_key() and to the “final” verification paths to catch even trusted=1 imports.
  • Update wolfcrypt test vectors to reflect the new rejection behavior and add positive-control valid public keys.
  • Add new API-level tests to ensure small-order keys are rejected on import and during verification (trusted import bypass path).

Reviewed changes

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

Show a summary per file
File Description
wolfcrypt/src/ed25519.c Adds ed25519_is_small_order() and rejects small-order keys during key check and verify-final.
wolfcrypt/src/ed448.c Adds ed448_is_small_order() and rejects small-order keys during key check and verify-final.
wolfcrypt/test/test.c Updates Ed25519/Ed448 key-check tests to expect rejection of the order-2 point and adds positive controls.
tests/api/test_ed25519.c Adds API test to ensure small-order Ed25519 keys are rejected (import + trusted-import verify path).
tests/api/test_ed25519.h Registers the new Ed25519 API test.
tests/api/test_ed448.c Adds API test to ensure small-order Ed448 keys are rejected (import + trusted-import verify path).
tests/api/test_ed448.h Registers the new Ed448 API test.

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

Comment thread wolfcrypt/src/ed448.c Outdated
Comment thread tests/api/test_ed25519.c
Comment thread tests/api/test_ed448.c Outdated
Add defense-in-depth checks to wc_ed{25519,448}_check_key() and
ed{25519,448}_verify_msg_final_with_sha() that reject the identity
point and other small-order public keys. Honest EdDSA key generation
never produces such keys, but wolfSSL previously accepted them on
import and verification. The guard runs at both entry points so it
holds even when a key is imported with trusted=1. New tests are gated
on !HAVE_FIPS || FIPS_VERSION3_GE(7,0,0).
@Frauschi Frauschi force-pushed the small_order_check branch from 47406e2 to 25a1a20 Compare May 28, 2026 17:53
@Frauschi
Copy link
Copy Markdown
Contributor Author

Fixed the Copilot issues

@Frauschi
Copy link
Copy Markdown
Contributor Author

Jenkins 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.

3 participants