From 922f2be2352b6fbe1388257cc8b4127ed3037905 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Thu, 26 Mar 2020 03:47:49 -0500 Subject: [PATCH] added binary forward secrecy test --- tests/test_forward_secrecy.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/test_forward_secrecy.py b/tests/test_forward_secrecy.py index 62f35b02..b7aec6fb 100644 --- a/tests/test_forward_secrecy.py +++ b/tests/test_forward_secrecy.py @@ -20,9 +20,27 @@ class OnionrForwardSecrecyTests(unittest.TestCase): ''' Tests both the onionrusers class and the contactmanager (which inherits it) ''' + def test_forward_encrypt_bin(self): + + friend = crypto.generate() + + friendUser = onionrusers.OnionrUser(friend[0], saveUser=True) + + for x in range(5): + message = os.urandom(32) + forwardKey = friendUser.generateForwardKey() + + fakeForwardPair = crypto.generate() + + self.assertTrue(friendUser.addForwardKey(fakeForwardPair[0])) + + encrypted = friendUser.forwardEncrypt(message) + + decrypted = crypto.encryption.pub_key_decrypt(encrypted[0], privkey=fakeForwardPair[1], encodedData=True) + self.assertEqual(decrypted, message.encode()) def test_forward_encrypt(self): - + friend = crypto.generate() friendUser = onionrusers.OnionrUser(friend[0], saveUser=True)