improve ltc_math_descriptor a bit
* introduce LTC_MILLER_RABIN_REPS which is used as default value in the isprime() implementations
This commit is contained in:
+1
-1
@@ -446,7 +446,7 @@ static int isprime(void *a, int b, int *c)
|
||||
LTC_ARGCHK(a != NULL);
|
||||
LTC_ARGCHK(c != NULL);
|
||||
if (b == 0) {
|
||||
b = 8;
|
||||
b = LTC_MILLER_RABIN_REPS;
|
||||
} /* if */
|
||||
*c = mpz_probab_prime_p(a, b) > 0 ? LTC_MP_YES : LTC_MP_NO;
|
||||
return CRYPT_OK;
|
||||
|
||||
+1
-1
@@ -404,7 +404,7 @@ static int isprime(void *a, int b, int *c)
|
||||
LTC_ARGCHK(a != NULL);
|
||||
LTC_ARGCHK(c != NULL);
|
||||
if (b == 0) {
|
||||
b = 8;
|
||||
b = LTC_MILLER_RABIN_REPS;
|
||||
} /* if */
|
||||
err = mpi_to_ltc_error(mp_prime_is_prime(a, b, c));
|
||||
*c = (*c == MP_YES) ? LTC_MP_YES : LTC_MP_NO;
|
||||
|
||||
@@ -66,7 +66,7 @@ int rand_prime(void *N, long len, prng_state *prng, int wprng)
|
||||
}
|
||||
|
||||
/* test */
|
||||
if ((err = mp_prime_is_prime(N, 8, &res)) != CRYPT_OK) {
|
||||
if ((err = mp_prime_is_prime(N, LTC_MILLER_RABIN_REPS, &res)) != CRYPT_OK) {
|
||||
XFREE(buf);
|
||||
return err;
|
||||
}
|
||||
|
||||
+4
-2
@@ -415,8 +415,10 @@ static int isprime(void *a, int b, int *c)
|
||||
{
|
||||
LTC_ARGCHK(a != NULL);
|
||||
LTC_ARGCHK(c != NULL);
|
||||
(void)b;
|
||||
*c = (fp_isprime(a) == FP_YES) ? LTC_MP_YES : LTC_MP_NO;
|
||||
if (b == 0) {
|
||||
b = LTC_MILLER_RABIN_REPS;
|
||||
} /* if */
|
||||
*c = (fp_isprime_ex(a, b) == FP_YES) ? LTC_MP_YES : LTC_MP_NO;
|
||||
return CRYPT_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user