mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Fix in SP math for casting signed -1 to unsigned.
This commit is contained in:
@ -950,7 +950,7 @@ static int sp_div(sp_int* a, sp_int* d, sp_int* r, sp_int* rem)
|
|||||||
}
|
}
|
||||||
for (i = sa->used - 1; i >= d->used; i--) {
|
for (i = sa->used - 1; i >= d->used; i--) {
|
||||||
if (sa->dp[i] == dt) {
|
if (sa->dp[i] == dt) {
|
||||||
t = (sp_digit)-1;
|
t = SP_MASK; /* f's */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
t = sp_div_word(sa->dp[i], sa->dp[i-1], dt);
|
t = sp_div_word(sa->dp[i], sa->dp[i-1], dt);
|
||||||
|
@ -85,8 +85,6 @@ This library provides single precision (SP) integer math functions.
|
|||||||
#endif
|
#endif
|
||||||
typedef uint128_t sp_int_word;
|
typedef uint128_t sp_int_word;
|
||||||
typedef int128_t sp_int_sword;
|
typedef int128_t sp_int_sword;
|
||||||
#else
|
|
||||||
#error Word size not defined
|
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if SP_WORD_SIZE == 32
|
#if SP_WORD_SIZE == 32
|
||||||
@ -106,12 +104,16 @@ This library provides single precision (SP) integer math functions.
|
|||||||
#endif
|
#endif
|
||||||
typedef uint128_t sp_int_word;
|
typedef uint128_t sp_int_word;
|
||||||
typedef int128_t sp_int_sword;
|
typedef int128_t sp_int_sword;
|
||||||
#else
|
|
||||||
#error Word size not defined
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SP_MASK (sp_digit)(-1)
|
#if SP_WORD_SIZE == 32
|
||||||
|
#define SP_MASK ((sp_digit)0xffffffff)
|
||||||
|
#elif SP_WORD_SIZE == 64
|
||||||
|
#define SP_MASK ((sp_digit)0xffffffffffffffff)
|
||||||
|
#else
|
||||||
|
#error Word size not defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(WOLFSSL_HAVE_SP_ECC) && defined(WOLFSSL_SP_NONBLOCK)
|
#if defined(WOLFSSL_HAVE_SP_ECC) && defined(WOLFSSL_SP_NONBLOCK)
|
||||||
|
Reference in New Issue
Block a user