X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=testdata%2Fbignum.py;h=15ffe319b42d1637bf140d39b5ab5bde32f5487d;hb=095072fa46b2d7b8beafaddb2f873d2f500a1e10;hp=05ca45287d3e3b2b6eaf49c13ebb945bdcfec95d;hpb=9d4005e5c15ef9ae2ec51359c02cc48b66a1e3a6;p=PuTTY.git diff --git a/testdata/bignum.py b/testdata/bignum.py index 05ca4528..15ffe319 100644 --- a/testdata/bignum.py +++ b/testdata/bignum.py @@ -103,6 +103,30 @@ for i in range(1,4200): a, b, p = findprod((1<= 0 + print "divmod", hexstr(n), hexstr(d), hexstr(n/d), hexstr(n%d) + +# Simple tests of modmul. +for ai in range(20, 200, 60): + a = sqrt(3<<(2*ai-1)) + for bi in range(20, 200, 60): + b = sqrt(5<<(2*bi-1)) + for m in range(20, 600, 32): + m = sqrt(2**(m+1)) + print "modmul", hexstr(a), hexstr(b), hexstr(m), hexstr((a*b) % m) + # Simple tests of modpow. for i in range(64, 4097, 63): modulus = sqrt(1<<(2*i-1)) | 1 @@ -113,3 +137,4 @@ for i in range(64, 4097, 63): # Test even moduli, which can't be done by Montgomery. modulus = modulus - 1 print "pow", hexstr(base), hexstr(expt), hexstr(modulus), hexstr(pow(base, expt, modulus)) + print "pow", hexstr(i), hexstr(expt), hexstr(modulus), hexstr(pow(i, expt, modulus))