Undo as mp_digit is not allowed to get as large as tested

This commit is contained in:
Sean Parkinson
2017-03-14 10:23:13 +10:00
parent 610ac07cd8
commit 72728b21af

View File

@ -4101,17 +4101,14 @@ int mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
c->used = a->used;
/* subtract first digit */
*tmpc = *tmpa - b;
if (b > *tmpa++)
mu = ((0 - *tmpc) >> DIGIT_BIT) + 1;
else
mu = *tmpc >> DIGIT_BIT;
*tmpc = *tmpa++ - b;
mu = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1);
*tmpc++ &= MP_MASK;
/* handle rest of the digits */
for (ix = 1; ix < a->used; ix++) {
*tmpc = *tmpa++ - mu;
mu = *tmpc >> DIGIT_BIT;
mu = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1);
*tmpc++ &= MP_MASK;
}
}