mirror of https://github.com/wolfSSL/wolfssl.git
check prime is prime with ecc compressed keys
parent
714aa97490
commit
c2be5dbe2b
|
@ -6931,6 +6931,14 @@ 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) {
|
||||
int isPrime = MP_NO;
|
||||
err = mp_prime_is_prime(curve->prime, 8, &isPrime);
|
||||
if (err == MP_OKAY && isPrime == MP_NO)
|
||||
err = MP_VAL;
|
||||
}
|
||||
|
||||
/* compute x^3 */
|
||||
if (err == MP_OKAY)
|
||||
err = mp_sqr(point->x, &t1);
|
||||
|
@ -7828,6 +7836,14 @@ 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) {
|
||||
int isPrime = MP_NO;
|
||||
err = mp_prime_is_prime(curve->prime, 8, &isPrime);
|
||||
if (err == MP_OKAY && isPrime == MP_NO)
|
||||
err = MP_VAL;
|
||||
}
|
||||
|
||||
/* compute x^3 */
|
||||
if (err == MP_OKAY)
|
||||
err = mp_sqr(key->pubkey.x, &t1);
|
||||
|
|
Loading…
Reference in New Issue