Get rid of remaining C++-style comments which strict C compilers hate.
[openssl.git] / crypto / bn / exp.c
1 #include <stdio.h>
2 #include "tmdiff.h"
3 #include "bn_lcl.h"
4
5 #define SIZE    256
6 #define NUM     (8*8*8)
7 #define MOD     (8*8*8*8*8)
8
9 main(argc,argv)
10 int argc;
11 char *argv[];
12         {
13         BN_CTX ctx;
14         BIGNUM a,b,c,r,rr,t,l;
15         int j,i,size=SIZE,num=NUM,mod=MOD;
16         char *start,*end;
17         BN_MONT_CTX mont;
18         double d,md;
19
20         BN_MONT_CTX_init(&mont);
21         BN_CTX_init(&ctx);
22         BN_init(&a);
23         BN_init(&b);
24         BN_init(&c);
25         BN_init(&r);
26
27         start=ms_time_new();
28         end=ms_time_new();
29         while (size <= 1024*8)
30                 {
31                 BN_rand(&a,size,0,0);
32                 BN_rand(&b,size,1,0);
33                 BN_rand(&c,size,0,1);
34
35                 BN_mod(&a,&a,&c,&ctx);
36
37                 ms_time_get(start);
38                 for (i=0; i<10; i++)
39                         BN_MONT_CTX_set(&mont,&c,&ctx);
40                 ms_time_get(end);
41                 md=ms_time_diff(start,end);
42
43                 ms_time_get(start);
44                 for (i=0; i<num; i++)
45                         {
46                         /* bn_mull(&r,&a,&b,&ctx); */
47                         /* BN_sqr(&r,&a,&ctx); */
48                         BN_mod_exp_mont(&r,&a,&b,&c,&ctx,&mont);
49                         }
50                 ms_time_get(end);
51                 d=ms_time_diff(start,end)/* *50/33 */;
52                 printf("%5d bit:%6.2f %6d %6.4f %4d m_set(%5.4f)\n",size,
53                         d,num,d/num,(int)((d/num)*mod),md/10.0);
54                 num/=8;
55                 mod/=8;
56                 if (num <= 0) num=1;
57                 size*=2;
58                 }
59
60         }