From 644636e0f880dd1c6e90fe27281ac124865a07de Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Sat, 6 Feb 2021 05:46:19 +0700 Subject: [PATCH] only check prime value with custom curves --- wolfcrypt/src/ecc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 4ee4dd12f..ed1b87e7b 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -6931,8 +6931,8 @@ int wc_ecc_import_point_der_ex(byte* in, word32 inLen, const int curve_idx, (ECC_CURVE_FIELD_PRIME | ECC_CURVE_FIELD_AF | ECC_CURVE_FIELD_BF)); - /* validate prime is prime */ - if (err == MP_OKAY) { + /* validate prime is prime for custom curves */ + if (err == MP_OKAY && curve->id == ECC_CURVE_CUSTOM) { int isPrime = MP_NO; err = mp_prime_is_prime(curve->prime, 8, &isPrime); if (err == MP_OKAY && isPrime == MP_NO) @@ -7836,8 +7836,8 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key, (ECC_CURVE_FIELD_PRIME | ECC_CURVE_FIELD_AF | ECC_CURVE_FIELD_BF)); - /* validate prime is prime */ - if (err == MP_OKAY) { + /* validate prime is prime for custom curves */ + if (err == MP_OKAY && curve->id == ECC_CURVE_CUSTOM) { int isPrime = MP_NO; err = mp_prime_is_prime(curve->prime, 8, &isPrime); if (err == MP_OKAY && isPrime == MP_NO)