diff options
| author | rsc <devnull@localhost> | 2004-03-21 14:06:38 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2004-03-21 14:06:38 +0000 |
| commit | b3f61791f1e9095ce8ae9c6d6415b4ee94e2f7eb (patch) | |
| tree | deaa85427ae73a045ddef39395bd286f9d3dc2ff /src/libmp/port/crttest.c | |
| parent | 498bb22174aa2c76493e8c67b92949271131ebfb (diff) | |
| download | plan9port-b3f61791f1e9095ce8ae9c6d6415b4ee94e2f7eb.tar.gz plan9port-b3f61791f1e9095ce8ae9c6d6415b4ee94e2f7eb.zip | |
Add libmp.
Diffstat (limited to 'src/libmp/port/crttest.c')
| -rw-r--r-- | src/libmp/port/crttest.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/libmp/port/crttest.c b/src/libmp/port/crttest.c new file mode 100644 index 00000000..b58e1736 --- /dev/null +++ b/src/libmp/port/crttest.c @@ -0,0 +1,54 @@ +#include "os.h" +#include <mp.h> +#include <libsec.h> + +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); +} |
