From 37da2899f40661e3e9631e497da8dc59b971cbd0 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Fri, 22 Dec 2006 17:07:39 +0000 Subject: 20060303a --- libmp/port/crttest.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 libmp/port/crttest.c (limited to 'libmp/port/crttest.c') diff --git a/libmp/port/crttest.c b/libmp/port/crttest.c new file mode 100644 index 00000000..b58e1736 --- /dev/null +++ b/libmp/port/crttest.c @@ -0,0 +1,54 @@ +#include "os.h" +#include +#include + +void +testcrt(mpint **p) +{ + CRTpre *crt; + CRTres *res; + mpint *m, *x, *y; + int i; + + fmtinstall('B', mpconv); + + // get a modulus and a test number + m = mpnew(1024+160); + mpmul(p[0], p[1], m); + x = mpnew(1024+160); + mpadd(m, mpone, x); + + // do the precomputation for crt conversion + crt = crtpre(2, p); + + // convert x to residues + res = crtin(crt, x); + + // convert back + y = mpnew(1024+160); + crtout(crt, res, y); + print("x %B\ny %B\n", x, y); + mpfree(m); + mpfree(x); + mpfree(y); +} + +void +main(void) +{ + int i; + mpint *p[2]; + long start; + + start = time(0); + for(i = 0; i < 10; i++){ + p[0] = mpnew(1024); + p[1] = mpnew(1024); + DSAprimes(p[0], p[1], nil); + testcrt(p); + mpfree(p[0]); + mpfree(p[1]); + } + print("%d secs with more\n", time(0)-start); + exits(0); +} -- cgit v1.2.3