forked from wolfSSL/wolfssl
Merge pull request #3558 from douzzer/fix-mp_mod_2d-sub-byte-clearing
fix mp_mod_2d() for DIGIT_BIT != sizeof(mp_digit)*8
This commit is contained in:
@ -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 */
|
/* clear the digit that is not completely outside/inside the modulus */
|
||||||
x = DIGIT_BIT - (b % DIGIT_BIT);
|
x = DIGIT_BIT - (b % DIGIT_BIT);
|
||||||
if (x != 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);
|
mp_clamp (c);
|
||||||
return MP_OKAY;
|
return MP_OKAY;
|
||||||
|
Reference in New Issue
Block a user