Skip to content

Commit b5bdcfc

Browse files
committed
Fix problem related to SM build
1 parent 27f32e9 commit b5bdcfc

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

tests/api.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34449,9 +34449,10 @@ static int test_zd21418_ecc_invalid_curve_point(void)
3444934449

3445034450
ExpectIntEQ(wc_ecc_init(&peerKey), 0);
3445134451

34452-
/* Import of invalid point must be rejected */
34453-
ExpectIntNE(wc_ecc_import_x963_ex(badPt, sizeof(badPt), &peerKey,
34454-
ECC_SECP256R1), 0);
34452+
/* Import of invalid point as untrusted (TLS peer) must be rejected.
34453+
* Uses _ex2 with untrusted=1 to match the TLS key exchange path. */
34454+
ExpectIntNE(wc_ecc_import_x963_ex2(badPt, sizeof(badPt), &peerKey,
34455+
ECC_SECP256R1, 1), 0);
3445534456

3445634457
wc_ecc_free(&peerKey);
3445734458
#endif

wolfcrypt/src/ecc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11005,8 +11005,8 @@ int wc_ecc_import_x963_ex2(const byte* in, word32 inLen, ecc_key* key,
1100511005
if (err == MP_OKAY)
1100611006
err = wc_ecc_check_key(key);
1100711007
#else
11008-
/* Always validate ECC imports to prevent invalid curve attacks */
11009-
if (err == MP_OKAY)
11008+
/* Validate untrusted ECC imports to prevent invalid curve attacks */
11009+
if ((err == MP_OKAY) && untrusted)
1101011010
err = wc_ecc_check_key(key);
1101111011
#endif
1101211012
#if (!defined(WOLFSSL_VALIDATE_ECC_IMPORT) || \

0 commit comments

Comments
 (0)