ECC: when multiplying by zero, set z to 1

Make sure zero times a point is infinity but z is 1 as it is assumed
later on.
This commit is contained in:
Sean Parkinson
2024-05-30 09:59:59 +10:00
parent a141041d13
commit fbd69f9b48
2 changed files with 5 additions and 1 deletions

View File

@ -4061,7 +4061,7 @@ int wc_ecc_mulmod(const mp_int* k, ecc_point *G, ecc_point *R, mp_int* a,
if ((k != NULL) && (R != NULL) && (mp_iszero(k))) {
mp_zero(R->x);
mp_zero(R->y);
mp_zero(R->z);
mp_set(R->z, 1);
return MP_OKAY;
}
return wc_ecc_mulmod_ex(k, G, R, a, modulus, map, NULL);

View File

@ -31085,6 +31085,10 @@ static wc_test_ret_t ecc_mulmod_test(ecc_key* key1)
ret = WC_TEST_RET_ENC_EC(ret);
goto done;
}
if (mp_cmp_d(key3->pubkey.z, 1) != MP_EQ) {
ret = WC_TEST_RET_ENC_EC(ret);
goto done;
}
#endif
done: