Fix for sp_div when a > d but same bit length

This commit is contained in:
Sean Parkinson
2019-11-25 09:14:14 +10:00
parent 8315ae892f
commit 2ac0ac8776

View File

@@ -672,6 +672,14 @@ static int sp_div(sp_int* a, sp_int* d, sp_int* r, sp_int* rem)
}
done = 1;
}
else if (sp_count_bits(a) == sp_count_bits(d)) {
/* a is greater than d but same bit length */
sp_sub(a, d, rem);
if (r != NULL) {
sp_set(r, 1);
}
done = 1;
}
#ifdef WOLFSSL_SMALL_STACK
if (!done && err == MP_OKAY) {