Fix a sign-extension bug on 64-bit platforms

This commit is contained in:
Giovanni Bajo 2011-09-27 01:55:42 +02:00
parent 3bab60e89c
commit d1dee8c6e1

View File

@ -10,10 +10,10 @@
#include <tfm.h> #include <tfm.h>
#define fp_on_bitnum(a, bitnum) \ #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) \ #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! */ /* 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) int fp_prime_random_ex(fp_int *a, int size, int flags, tfm_prime_callback cb, void *dat)