diff --git a/src/headers/tfm.h b/src/headers/tfm.h index 3c7d9ac..ac6c9e6 100644 --- a/src/headers/tfm.h +++ b/src/headers/tfm.h @@ -431,6 +431,7 @@ int fp_exptmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d); /* perform a Miller-Rabin test of a to the base b and store result in "result" */ void fp_prime_miller_rabin (fp_int * a, fp_int * b, int *result); +#define FP_PRIME_SIZE 256 /* 256 trial divisions + 8 Miller-Rabins, returns FP_YES if probable prime */ int fp_isprime(fp_int *a); /* extended version of fp_isprime, do 't' Miller-Rabins instead of only 8 */ diff --git a/src/numtheory/fp_isprime_ex.c b/src/numtheory/fp_isprime_ex.c index 6af6cee..0a4f0a3 100644 --- a/src/numtheory/fp_isprime_ex.c +++ b/src/numtheory/fp_isprime_ex.c @@ -10,7 +10,7 @@ #include /* a few primes */ -static const fp_digit primes[256] = { +static const fp_digit primes[FP_PRIME_SIZE] = { 0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013, 0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035, 0x003B, 0x003D, 0x0043, 0x0047, 0x0049, 0x004F, 0x0053, 0x0059, @@ -54,7 +54,7 @@ int fp_isprime_ex(fp_int *a, int t) fp_digit d; int r, res; - if (t <= 0 || t > 256) { + if (t <= 0 || t > FP_PRIME_SIZE) { return FP_NO; }