diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/libmp/port/crttest.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/libmp/port/crttest.c')
-rwxr-xr-x | sys/src/libmp/port/crttest.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/sys/src/libmp/port/crttest.c b/sys/src/libmp/port/crttest.c new file mode 100755 index 000000000..ef3d18e1f --- /dev/null +++ b/sys/src/libmp/port/crttest.c @@ -0,0 +1,53 @@ +#include "os.h" +#include <mp.h> +#include <libsec.h> + +void +testcrt(mpint **p) +{ + CRTpre *crt; + CRTres *res; + mpint *m, *x, *y; + + fmtinstall('B', mpfmt); + + // 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("%ld secs with more\n", time(0)-start); + exits(0); +} |