summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSybren A. St?vel <sybren@stuvel.eu>2011-07-10 13:23:34 +0200
committerSybren A. St?vel <sybren@stuvel.eu>2011-07-10 13:23:34 +0200
commit11016f9b792c59f4f95c1efb379db5d5ad8c7786 (patch)
treee47a4b923a693b01600260db2e3c2b6fd5490d11 /tests
parentb21277340477dc6cce400c1473de74230b0e3b46 (diff)
downloadrsa-11016f9b792c59f4f95c1efb379db5d5ad8c7786.tar.gz
Added test for randomness
Diffstat (limited to 'tests')
-rw-r--r--tests/test_pkcs1.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_pkcs1.py b/tests/test_pkcs1.py
index 230e7f7..0d55d7b 100644
--- a/tests/test_pkcs1.py
+++ b/tests/test_pkcs1.py
@@ -34,6 +34,17 @@ class BinaryTest(unittest.TestCase):
self.assertRaises(ValueError, pkcs1.decrypt, encrypted, self.priv)
+ def test_randomness(self):
+ '''Encrypting the same message twice should result in different
+ cryptos.
+ '''
+
+ message = struct.pack('>IIII', 0, 0, 0, 1)
+ encrypted1 = pkcs1.encrypt(message, self.pub)
+ encrypted2 = pkcs1.encrypt(message, self.pub)
+
+ self.assertNotEqual(encrypted1, encrypted2)
+
# def test_sign_verify(self):
#
# message = struct.pack('>IIII', 0, 0, 0, 1) + 20 * '\x00'