From 11016f9b792c59f4f95c1efb379db5d5ad8c7786 Mon Sep 17 00:00:00 2001 From: "Sybren A. St?vel" Date: Sun, 10 Jul 2011 13:23:34 +0200 Subject: Added test for randomness --- tests/test_pkcs1.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') 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' -- cgit v1.2.1