From 36d534034c24007c8c1c432d51f53641fe120bde Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Wed, 30 Jun 2021 09:28:51 +1000 Subject: [PATCH] SP math: cast number to sp_digit rather than declare as long --- wolfcrypt/src/sp_int.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index 067784c77..99cd6c627 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -12938,7 +12938,7 @@ int sp_rand_prime(sp_int* r, int len, WC_RNG* rng, void* heap) #endif /* LITTLE_ENDIAN_ORDER */ #ifdef WOLFSSL_SP_MATH_ALL if (bits > 0) { - r->dp[r->used - 1] &= (1L << bits) - 1; + r->dp[r->used - 1] &= ((sp_digit)1 << bits) - 1; } #endif /* WOLFSSL_SP_MATH_ALL */ @@ -13322,7 +13322,7 @@ int sp_prime_is_prime_ex(sp_int* a, int t, int* result, WC_RNG* rng) b->used = a->used; /* Ensure the top word has no more bits than necessary. */ if (bits > 0) { - b->dp[b->used - 1] &= (1L << bits) - 1; + b->dp[b->used - 1] &= ((sp_digit)1 << bits) - 1; } if ((sp_cmp_d(b, 2) != MP_GT) || (_sp_cmp(b, c) != MP_LT)) {