BIGNUM t;
int found=0;
int i,j,c1=0;
- BN_CTX *ctx;
+ BN_CTX *ctx,*ctx2=NULL;
int checks = BN_prime_checks_for_size(bits);
ctx=BN_CTX_new();
if (ctx == NULL) goto err;
+ ctx2=BN_CTX_new();
+ if (ctx2 == NULL) goto err;
if (ret == NULL)
{
if ((rnd=BN_new()) == NULL) goto err;
if (!safe)
{
- i=BN_is_prime(rnd,checks,callback,ctx,cb_arg);
+ i=BN_is_prime_fasttest(rnd,checks,callback,ctx,ctx2,cb_arg,0);
if (i == -1) goto err;
if (i == 0) goto loop;
}
for (i=0; i<checks; i++)
{
- j=BN_is_prime(rnd,1,callback,ctx,cb_arg);
+ j=BN_is_prime_fasttest(rnd,1,callback,ctx,ctx2,cb_arg,0);
if (j == -1) goto err;
if (j == 0) goto loop;
- j=BN_is_prime(&t,1,callback,ctx,cb_arg);
+ j=BN_is_prime_fasttest(&t,1,callback,ctx,ctx2,cb_arg,0);
if (j == -1) goto err;
if (j == 0) goto loop;
if (!found && (ret == NULL) && (rnd != NULL)) BN_free(rnd);
BN_free(&t);
if (ctx != NULL) BN_CTX_free(ctx);
+ if (ctx2 != NULL) BN_CTX_free(ctx2);
return(found ? rnd : NULL);
}