forked from wolfSSL/wolfssl
Merge pull request #4074 from SparkiDev/ecdsa_dbl_table_point
ECDSA FP ECC: fix corner case
This commit is contained in:
@@ -5942,7 +5942,18 @@ int ecc_projective_add_point_safe(ecc_point* A, ecc_point* B, ecc_point* R,
|
|||||||
if ((err == MP_OKAY) && mp_iszero(R->z)) {
|
if ((err == MP_OKAY) && mp_iszero(R->z)) {
|
||||||
/* When all zero then should have done a double */
|
/* When all zero then should have done a double */
|
||||||
if (mp_iszero(R->x) && mp_iszero(R->y)) {
|
if (mp_iszero(R->x) && mp_iszero(R->y)) {
|
||||||
err = ecc_projective_dbl_point(B, R, a, modulus, mp);
|
if (mp_iszero(B->z)) {
|
||||||
|
err = wc_ecc_copy_point(B, R);
|
||||||
|
if (err == MP_OKAY) {
|
||||||
|
err = mp_montgomery_calc_normalization(R->z, modulus);
|
||||||
|
}
|
||||||
|
if (err == MP_OKAY) {
|
||||||
|
err = ecc_projective_dbl_point(R, R, a, modulus, mp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
err = ecc_projective_dbl_point(B, R, a, modulus, mp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* When only Z zero then result is infinity */
|
/* When only Z zero then result is infinity */
|
||||||
else {
|
else {
|
||||||
|
Reference in New Issue
Block a user