Skip to content

Commit

Permalink
Merge pull request wolfSSL#7600 from SparkiDev/wc_ecc_mulmod_zero_z1
Browse files Browse the repository at this point in the history
ECC: when multiplying by zero, set z to 1
  • Loading branch information
JacobBarthelmeh authored Jun 18, 2024
2 parents 2b0d724 + fbd69f9 commit 24291b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion wolfcrypt/src/ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 24291b4

Please sign in to comment.