From ef1284165f8605ae9c6e76268b051eb7eec89aea Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Thu, 10 Dec 2020 23:50:30 -0600 Subject: [PATCH] wolfcrypt/src/integer.c: fix sub-byte clearing step of mp_mod_2d() to work when DIGIT_BIT != sizeof(mp_digit)*8. --- wolfcrypt/src/integer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index 53f8f2f59..badf70994 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -686,7 +686,7 @@ int mp_mod_2d (mp_int * a, int b, mp_int * c) /* clear the digit that is not completely outside/inside the modulus */ x = DIGIT_BIT - (b % DIGIT_BIT); if (x != DIGIT_BIT) { - c->dp[b / DIGIT_BIT] &= ~((mp_digit)0) >> x; + c->dp[b / DIGIT_BIT] &= ~((mp_digit)0) >> (x + ((sizeof(mp_digit)*8) - DIGIT_BIT)); } mp_clamp (c); return MP_OKAY;