Skip to content

Reject small-order public keys for Edwards and Montgomery curves#10540

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

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

Conversation

@Frauschi
Copy link
Copy Markdown
Contributor

Reject small-order public keys for Ed25519, Ed448, and X25519, and validate peer-supplied public keys on import for X25519/X448.

Honest EdDSA/ECDH key generation never produces points of small order, but we previously accepted them, which weakens the contributory property of X25519/X448 ECDH (a small-order peer key yields a low-entropy shared secret the peer fully controls) and removes a defense-in-depth layer for EdDSA public-key validation. This change adds explicit rejection at both key-import and signature-verification time, and closes a related gap where wc_curve{25519,448}_import_public_ex() were not running their existing check_public() validation on peer-supplied keys.

All new behavior is gated on !HAVE_FIPS || FIPS_VERSION3_GE(7,0,0) so existing FIPS-certified modules are unaffected.

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

A public key that is the identity or another small-order point makes
h*A vanish during EdDSA verification, so a forged (R = [S]B, S) pair
verifies for any message; for X25519/X448 ECDH the same input yields a
low-entropy shared secret the peer fully controls. Honest key
generation never produces such keys, but we did not reject them on
import or verification. wc_ed{25519,448}_check_key() and
ed{25519,448}_verify_msg_final_with_sha() now reject every small-order
encoding; wc_curve25519_check_public() rejects the two intermediate
u-coordinates the range checks missed; and wc_curve{25519,448}_
import_public_ex() now invoke check_public() on peer-supplied input.
New tests are gated on !HAVE_FIPS || FIPS_VERSION3_GE(7,0,0).
@Frauschi Frauschi self-assigned this May 27, 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.

1 participant