70 #define NUM_BITS (BN_BITS*2)
72 static const char rnd_seed[] =
"string to make the random number generator think it has entropy";
74 int main(
int argc,
char *argv[])
80 BIGNUM *r_mont,*r_mont_const,*r_recp,*r_simple,*
a,*
b,*m;
89 if (ctx == NULL)
EXIT(1);
97 if ( (r_mont == NULL) || (r_recp == NULL) ||
98 (a == NULL) || (b == NULL))
103 if (out == NULL)
EXIT(1);
106 for (i=0; i<200; i++)
109 c=(c%BN_BITS)-BN_BITS2;
113 c=(c%BN_BITS)-BN_BITS2;
117 c=(c%BN_BITS)-BN_BITS2;
126 printf(
"BN_mod_exp_mont() problems\n");
134 printf(
"BN_mod_exp_recp() problems\n");
142 printf(
"BN_mod_exp_simple() problems\n");
150 printf(
"BN_mod_exp_mont_consttime() problems\n");
155 if (
BN_cmp(r_simple, r_mont) == 0
156 &&
BN_cmp(r_simple,r_recp) == 0
157 &&
BN_cmp(r_simple,r_mont_const) == 0)
164 if (
BN_cmp(r_simple,r_mont) != 0)
165 printf(
"\nsimple and mont results differ\n");
166 if (
BN_cmp(r_simple,r_mont_const) != 0)
167 printf(
"\nsimple and mont const time results differ\n");
168 if (
BN_cmp(r_simple,r_recp) != 0)
169 printf(
"\nsimple and recp results differ\n");
174 printf(
"\nsimple =");
BN_print(out,r_simple);
175 printf(
"\nrecp =");
BN_print(out,r_recp);
176 printf(
"\nmont =");
BN_print(out,r_mont);
177 printf(
"\nmont_ct =");
BN_print(out,r_mont_const);
198 #ifdef OPENSSL_SYS_NETWARE