SP math: don't modify sign in sp_div

Not need to modify sign of a and d in sp_div().
Signs cached at start and used to calculate sign result.
This commit is contained in:
Sean Parkinson
2022-08-26 08:47:49 +10:00
parent 1976601811
commit 8b2719cc83

View File

@@ -7021,6 +7021,8 @@ void sp_rshb(sp_int* a, int n, sp_int* r)
*/ */
static int _sp_div(sp_int* a, sp_int* d, sp_int* r, sp_int* trial) static int _sp_div(sp_int* a, sp_int* d, sp_int* r, sp_int* trial)
{ {
int err = MP_OKAY;
int i;
#ifdef WOLFSSL_SP_SMALL #ifdef WOLFSSL_SP_SMALL
int c; int c;
#else #else
@@ -7034,16 +7036,9 @@ static int _sp_div(sp_int* a, sp_int* d, sp_int* r, sp_int* trial)
sp_int_digit st; sp_int_digit st;
#endif #endif
#endif /* WOLFSSL_SP_SMALL */ #endif /* WOLFSSL_SP_SMALL */
int err = MP_OKAY;
int i;
sp_int_digit t; sp_int_digit t;
sp_int_digit dt; sp_int_digit dt;
#ifdef WOLFSSL_SP_INT_NEGATIVE
a->sign = MP_ZPOS;
d->sign = MP_ZPOS;
#endif /* WOLFSSL_SP_INT_NEGATIVE */
r->used = a->used - d->used + 1; r->used = a->used - d->used + 1;
sp_clear(r); sp_clear(r);
r->used = a->used - d->used + 1; r->used = a->used - d->used + 1;