Skip to content
This repository was archived by the owner on Apr 20, 2025. It is now read-only.

Commit 5f6d9e2

Browse files
committed
Added test for randomness
1 parent f44c6b4 commit 5f6d9e2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/test_pkcs1.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ def test_decoding_failure(self):
3434

3535
self.assertRaises(ValueError, pkcs1.decrypt, encrypted, self.priv)
3636

37+
def test_randomness(self):
38+
'''Encrypting the same message twice should result in different
39+
cryptos.
40+
'''
41+
42+
message = struct.pack('>IIII', 0, 0, 0, 1)
43+
encrypted1 = pkcs1.encrypt(message, self.pub)
44+
encrypted2 = pkcs1.encrypt(message, self.pub)
45+
46+
self.assertNotEqual(encrypted1, encrypted2)
47+
3748
# def test_sign_verify(self):
3849
#
3950
# message = struct.pack('>IIII', 0, 0, 0, 1) + 20 * '\x00'

0 commit comments

Comments
 (0)