summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authoradamantike <mike@fmanganiello.com.ar>2016-03-28 13:12:12 -0300
committerSybren A. Stüvel <sybren@stuvel.eu>2016-04-15 23:55:53 +0200
commit38a7255a5e935c3b2663613392db9d5290fc2340 (patch)
tree6d0d44fedf6c39619f4ea591c2b164ba47e2aec8 /tests
parent96eaa5e82b75b8cfc36a67ad72a768f03c285647 (diff)
downloadrsa-git-38a7255a5e935c3b2663613392db9d5290fc2340.tar.gz
Set Miller-Rabin rounds based on bitsize
Diffstat (limited to 'tests')
-rw-r--r--tests/test_prime.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_prime.py b/tests/test_prime.py
index 173c991..44d8d71 100644
--- a/tests/test_prime.py
+++ b/tests/test_prime.py
@@ -74,3 +74,17 @@ class PrimeTest(unittest.TestCase):
self.assertEqual([], randints)
finally:
rsa.randnum.randint = orig_randint
+
+ def test_get_primality_testing_rounds(self):
+ """Test round calculation for primality testing."""
+
+ self.assertEquals(rsa.prime.get_primality_testing_rounds(1 << 63), 10)
+ self.assertEquals(rsa.prime.get_primality_testing_rounds(1 << 127), 10)
+ self.assertEquals(rsa.prime.get_primality_testing_rounds(1 << 255), 10)
+ self.assertEquals(rsa.prime.get_primality_testing_rounds(1 << 511), 7)
+ self.assertEquals(rsa.prime.get_primality_testing_rounds(1 << 767), 7)
+ self.assertEquals(rsa.prime.get_primality_testing_rounds(1 << 1023), 4)
+ self.assertEquals(rsa.prime.get_primality_testing_rounds(1 << 1279), 4)
+ self.assertEquals(rsa.prime.get_primality_testing_rounds(1 << 1535), 3)
+ self.assertEquals(rsa.prime.get_primality_testing_rounds(1 << 2047), 3)
+ self.assertEquals(rsa.prime.get_primality_testing_rounds(1 << 4095), 3)