From d1dee8c6e1c8afb7de0551cbcb2131d158ea8fa9 Mon Sep 17 00:00:00 2001 From: Giovanni Bajo Date: Tue, 27 Sep 2011 01:55:42 +0200 Subject: [PATCH] Fix a sign-extension bug on 64-bit platforms --- src/numtheory/fp_prime_random_ex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/numtheory/fp_prime_random_ex.c b/src/numtheory/fp_prime_random_ex.c index 7db5e9e..0c4b479 100644 --- a/src/numtheory/fp_prime_random_ex.c +++ b/src/numtheory/fp_prime_random_ex.c @@ -10,10 +10,10 @@ #include #define fp_on_bitnum(a, bitnum) \ - a->dp[(bitnum) >> DIGIT_SHIFT] |= 1 << ((bitnum) & (DIGIT_BIT-1)); + a->dp[(bitnum) >> DIGIT_SHIFT] |= (fp_digit)1 << ((bitnum) & (DIGIT_BIT-1)) #define fp_off_bitnum(a, bitnum) \ - a->dp[(bitnum) >> DIGIT_SHIFT] &= ~(1 << ((bitnum) & (DIGIT_BIT-1))); + a->dp[(bitnum) >> DIGIT_SHIFT] &= ~((fp_digit)1 << ((bitnum) & (DIGIT_BIT-1))) /* This is possibly the mother of all prime generation functions, muahahahahaha! */ int fp_prime_random_ex(fp_int *a, int size, int flags, tfm_prime_callback cb, void *dat)