BN_mod_exp(r,a,b,c,ctx);
{ if (k%50 == 0)  { if (!BN_pseudo_rand(a,sizes[i],1,0)) goto err; if (!BN_pseudo_rand(b,sizes[i],1,0)) goto err; #ifndef C_PRIME if (!BN_pseudo_rand(c,sizes[i],1,1)) goto err; #endif } #if defined(TEST_EXP) if (!BN_mod_exp(r,a,b,c,ctx)) goto err; #elif defined(TEST_GCD) if (!BN_gcd(r,a,b,ctx)) goto err; if (!BN_gcd(r,b,c,ctx)) goto err; if (!BN_gcd(r,b,c,ctx)) goto err; #else  if (!BN_mod_inverse(r,a,c,ctx)) goto err; if (!BN_mod_inverse(r,b,c,ctx)) goto err; #endif }
void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx)	{	int i,k;	double tm;	long num;	num=BASENUM;	for (i=0; i<NUM_SIZES; i++)		{		BN_pseudo_rand(a,sizes[i],1,0);		BN_pseudo_rand(b,sizes[i],1,0);		BN_pseudo_rand(c,sizes[i],1,1);		BN_mod(a,a,c,ctx);		BN_mod(b,b,c,ctx);		Time_F(START);		for (k=0; k<num; k++)			BN_mod_exp(r,a,b,c,ctx);		tm=Time_F(STOP);		printf("mul %4d ^ %4d %% %d -> %8.3fms %5.1f\n",sizes[i],sizes[i],sizes[i],tm*1000.0/num,tm*mul_c[i]/num);		num/=7;		if (num <= 0) num=1;		}	}