wolfcrypt/src/sp_int.c: add _LINUXKM do_div codepaths for a couple more 64 bit divisions, in sp_div_word() and sp_mod_d().

This commit is contained in:
Daniel Pouzzner
2020-08-20 14:01:27 -05:00
parent 9ab1df690a
commit add78dfba9

View File

@ -808,7 +808,11 @@ static WC_INLINE sp_int_digit sp_div_word(sp_int_digit hi, sp_int_digit lo,
sp_int_digit r;
w = ((sp_int_word)hi << SP_WORD_SIZE) | lo;
#ifdef WOLFSSL_LINUXKM
do_div(w, d);
#else
w /= d;
#endif
r = (sp_int_digit)w;
return r;
@ -1487,7 +1491,12 @@ static int sp_mod_d(sp_int* a, const sp_int_digit d, sp_int_digit* r)
if (err == MP_OKAY) {
for (i = a->used - 1; i >= 0; i--) {
w = (w << SP_WORD_SIZE) | a->dp[i];
#ifdef WOLFSSL_LINUXKM
t = (sp_int_digit)w;
do_div(t, d);
#else
t = (sp_int_digit)(w / d);
#endif
w -= (sp_int_word)t * d;
}