Blob


1 #include "os.h"
2 #include <mp.h>
4 void
5 testcrt(mpint **p)
6 {
7 CRTpre *crt;
8 CRTres *res;
9 mpint *m, *x, *y;
10 int i;
12 fmtinstall('B', mpconv);
14 /* get a modulus and a test number */
15 m = mpnew(1024+160);
16 mpmul(p[0], p[1], m);
17 x = mpnew(1024+160);
18 mpadd(m, mpone, x);
20 /* do the precomputation for crt conversion */
21 crt = crtpre(2, p);
23 /* convert x to residues */
24 res = crtin(crt, x);
26 /* convert back */
27 y = mpnew(1024+160);
28 crtout(crt, res, y);
29 print("x %B\ny %B\n", x, y);
30 mpfree(m);
31 mpfree(x);
32 mpfree(y);
33 }
35 void
36 main(void)
37 {
38 int i;
39 mpint *p[2];
40 long start;
42 start = time(0);
43 for(i = 0; i < 10; i++){
44 p[0] = mpnew(1024);
45 p[1] = mpnew(1024);
46 DSAprimes(p[0], p[1], nil);
47 testcrt(p);
48 mpfree(p[0]);
49 mpfree(p[1]);
50 }
51 print("%d secs with more\n", time(0)-start);
52 exits(0);
53 }