From 8b2719cc83a86b01429b5c601a0b023e42c1d2f5 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Fri, 26 Aug 2022 08:47:49 +1000 Subject: [PATCH] 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. --- wolfcrypt/src/sp_int.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index 69296a446..b4df9f2f2 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -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) { + int err = MP_OKAY; + int i; #ifdef WOLFSSL_SP_SMALL int c; #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; #endif #endif /* WOLFSSL_SP_SMALL */ - int err = MP_OKAY; - int i; sp_int_digit t; 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; sp_clear(r); r->used = a->used - d->used + 1;