aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-04-21 11:41:02 -0400
committerJack Lloyd <[email protected]>2019-04-21 11:41:02 -0400
commitf6b3505d2837f07a7f68255440901586272b5225 (patch)
tree9fd2b5080136f1a24dff5650df65dafd321c2d3e /src/scripts
parente37bd06ea487a4d7b59b2e3f7e21fb955651daf9 (diff)
More MPI functions
Diffstat (limited to 'src/scripts')
-rw-r--r--src/scripts/test_python.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/scripts/test_python.py b/src/scripts/test_python.py
index 94da4dc24..1ba21f570 100644
--- a/src/scripts/test_python.py
+++ b/src/scripts/test_python.py
@@ -402,6 +402,20 @@ ofvkP1EDmpx50fHLawIDAQAB
p = inv.pow_mod(botan2.MPI(46), mod)
self.assertEqual(int(p), 42)
+ def test_mpi_random(self):
+ rng = botan2.RandomNumberGenerator()
+
+ u = botan2.MPI.random(rng, 512)
+ self.assertEqual(u.bit_count(), 512)
+
+ l = u >> 32
+ self.assertEqual(l.bit_count(), 512-32)
+
+ for _i in range(10):
+ x = botan2.MPI.random_range(rng, l, u)
+ self.assertTrue(x < u)
+ self.assertTrue(x > l)
+
def test_fpe(self):
modulus = botan2.MPI('1000000000')