Merge pull request #94 from fperrad/20171018_cast

restore previous cast
This commit is contained in:
Steffen Jaeckel 2017-10-19 09:46:36 +02:00 committed by GitHub
commit 1ca973b6b8
7 changed files with 9 additions and 9 deletions

View File

@ -54,7 +54,7 @@ int mp_div_2d(const mp_int *a, int b, mp_int *c, mp_int *d)
mp_digit *tmpc, mask, shift;
/* mask */
mask = (1uL << D) - 1uL;
mask = ((mp_digit)1 << D) - 1uL;
/* shift for lsb */
shift = (mp_digit)DIGIT_BIT - D;

View File

@ -25,7 +25,7 @@ static int s_is_power_of_two(mp_digit b, int *p)
}
for (x = 0; x < DIGIT_BIT; x++) {
if (b == (1uL<<(mp_digit)x)) {
if (b == ((mp_digit)1<<(mp_digit)x)) {
*p = x;
return 1;
}
@ -60,7 +60,7 @@ int mp_div_d(const mp_int *a, mp_digit b, mp_int *c, mp_digit *d)
/* power of two ? */
if (s_is_power_of_two(b, &ix) == 1) {
if (d != NULL) {
*d = a->dp[0] & ((1uL<<(mp_digit)ix) - 1uL);
*d = a->dp[0] & (((mp_digit)1<<(mp_digit)ix) - 1uL);
}
if (c != NULL) {
return mp_div_2d(a, ix, c, NULL);

View File

@ -60,7 +60,7 @@ int mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
}
/* if the bit is set multiply */
if ((b & (1uL << (DIGIT_BIT - 1))) != 0u) {
if ((b & ((mp_digit)1 << (DIGIT_BIT - 1))) != 0u) {
if ((res = mp_mul(c, &g, c)) != MP_OKAY) {
mp_clear(&g);
return res;

View File

@ -43,7 +43,7 @@ int mp_mod_2d(const mp_int *a, int b, mp_int *c)
}
/* clear the digit that is not completely outside/inside the modulus */
c->dp[b / DIGIT_BIT] &=
(1uL << (mp_digit)(b % DIGIT_BIT)) - 1uL;
((mp_digit)1 << (mp_digit)(b % DIGIT_BIT)) - (mp_digit)1;
mp_clamp(c);
return MP_OKAY;
}

View File

@ -48,7 +48,7 @@ int mp_mul_2d(const mp_int *a, int b, mp_int *c)
int x;
/* bitmask for carries */
mask = (1uL << d) - 1uL;
mask = ((mp_digit)1 << d) - (mp_digit)1;
/* shift for msbs */
shift = (mp_digit)DIGIT_BIT - d;

View File

@ -131,7 +131,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style)
y = 1;
}
}
} while ((y == 1) && (step < ((1uL << DIGIT_BIT) - kstep)));
} while ((y == 1) && (step < (((mp_digit)1 << DIGIT_BIT) - kstep)));
/* add the step */
if ((err = mp_add_d(a, step, a)) != MP_OKAY) {
@ -139,7 +139,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style)
}
/* if didn't pass sieve and step == MAX then skip test */
if ((y == 1) && (step >= ((1uL << DIGIT_BIT) - kstep))) {
if ((y == 1) && (step >= (((mp_digit)1 << DIGIT_BIT) - kstep))) {
continue;
}

View File

@ -33,7 +33,7 @@ int mp_reduce(mp_int *x, const mp_int *m, const mp_int *mu)
mp_rshd(&q, um - 1);
/* according to HAC this optimization is ok */
if ((mp_digit)um > (1uL << (DIGIT_BIT - 1))) {
if ((mp_digit)um > ((mp_digit)1 << (DIGIT_BIT - 1))) {
if ((res = mp_mul(&q, mu, &q)) != MP_OKAY) {
goto CLEANUP;
}