forked from wolfSSL/wolfssl
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:
@@ -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))) {
|
if ((k != NULL) && (R != NULL) && (mp_iszero(k))) {
|
||||||
mp_zero(R->x);
|
mp_zero(R->x);
|
||||||
mp_zero(R->y);
|
mp_zero(R->y);
|
||||||
mp_zero(R->z);
|
mp_set(R->z, 1);
|
||||||
return MP_OKAY;
|
return MP_OKAY;
|
||||||
}
|
}
|
||||||
return wc_ecc_mulmod_ex(k, G, R, a, modulus, map, NULL);
|
return wc_ecc_mulmod_ex(k, G, R, a, modulus, map, NULL);
|
||||||
|
@@ -31085,6 +31085,10 @@ static wc_test_ret_t ecc_mulmod_test(ecc_key* key1)
|
|||||||
ret = WC_TEST_RET_ENC_EC(ret);
|
ret = WC_TEST_RET_ENC_EC(ret);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if (mp_cmp_d(key3->pubkey.z, 1) != MP_EQ) {
|
||||||
|
ret = WC_TEST_RET_ENC_EC(ret);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
Reference in New Issue
Block a user