Skip to content

Commit feb8782

Browse files
committed
Fix missing ECC point validation on import (ZD 21418)
Validate ECC key imports when the untrusted flag is set to prevent invalid curve attacks. The TLS key exchange path (internal.c) passes untrusted=1 for peer keys. Trusted imports (cert parsing) pass untrusted=0 and skip the check.
1 parent 392ce13 commit feb8782

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎wolfcrypt/src/ecc.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11004,6 +11004,10 @@ int wc_ecc_import_x963_ex2(const byte* in, word32 inLen, ecc_key* key,
1100411004
#ifdef WOLFSSL_VALIDATE_ECC_IMPORT
1100511005
if (err == MP_OKAY)
1100611006
err = wc_ecc_check_key(key);
11007+
#else
11008+
/* Validate untrusted ECC imports to prevent invalid curve attacks */
11009+
if ((err == MP_OKAY) && untrusted)
11010+
err = wc_ecc_check_key(key);
1100711011
#endif
1100811012
#if (!defined(WOLFSSL_VALIDATE_ECC_IMPORT) || \
1100911013
!defined(HAVE_ECC_CHECK_PUBKEY_ORDER)) && \

0 commit comments

Comments
 (0)