X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fbn%2Fbn_prime.c;h=57305c7273b5b271665a0d9d29e0453b2849d1d8;hp=28610766d0cde49a4b851bf7937b601c0c55db84;hb=76aa0ddc86772080db4f61821b9ff357e330c843;hpb=73d2257d978c7a201d6a914dc141ea1484d9aa6f diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c index 28610766d0..57305c7273 100644 --- a/crypto/bn/bn_prime.c +++ b/crypto/bn/bn_prime.c @@ -73,15 +73,16 @@ static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx,BN_CTX *ctx2, static int probable_prime(BIGNUM *rnd, int bits); static int probable_prime_dh(BIGNUM *rnd, int bits, BIGNUM *add, BIGNUM *rem, BN_CTX *ctx); -static int probable_prime_dh_strong(BIGNUM *rnd, int bits, +static int probable_prime_dh_safe(BIGNUM *rnd, int bits, BIGNUM *add, BIGNUM *rem, BN_CTX *ctx); -BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int strong, BIGNUM *add, - BIGNUM *rem, void (*callback)(int,int,char *), char *cb_arg) +BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, BIGNUM *add, + BIGNUM *rem, void (*callback)(int,int,void *), void *cb_arg) { BIGNUM *rnd=NULL; BIGNUM t; int i,j,c1=0; BN_CTX *ctx; + int checks = BN_prime_checks(bits); ctx=BN_CTX_new(); if (ctx == NULL) goto err; @@ -100,9 +101,9 @@ loop: } else { - if (strong) + if (safe) { - if (!probable_prime_dh_strong(rnd,bits,add,rem,ctx)) + if (!probable_prime_dh_safe(rnd,bits,add,rem,ctx)) goto err; } else @@ -114,21 +115,21 @@ loop: /* if (BN_mod_word(rnd,(BN_ULONG)3) == 1) goto loop; */ if (callback != NULL) callback(0,c1++,cb_arg); - if (!strong) + if (!safe) { - i=BN_is_prime(rnd,BN_prime_checks,callback,ctx,cb_arg); + i=BN_is_prime(rnd,checks,callback,ctx,cb_arg); if (i == -1) goto err; if (i == 0) goto loop; } else { - /* for a strong prime generation, + /* for "safe prime" generation, * check that (p-1)/2 is prime. * Since a prime is odd, We just * need to divide by 2 */ if (!BN_rshift1(&t,rnd)) goto err; - for (i=0; i