SP int: sp_mod check sp_div error before adding and replacing error

Fix to not overwrite error when sp_div fails in sp_mod.
This commit is contained in:
Sean Parkinson
2023-04-17 11:40:21 +10:00
parent 42b73ee326
commit 59c113d358

View File

@ -8434,7 +8434,7 @@ int sp_mod(const sp_int* a, const sp_int* m, sp_int* r)
#else
if ((err == MP_OKAY) && (r != m)) {
err = sp_div(a, m, NULL, r);
if ((!sp_iszero(r)) && (r->sign != m->sign)) {
if ((err == MP_OKAY) && (!sp_iszero(r)) && (r->sign != m->sign)) {
err = sp_add(r, m, r);
}
}