added binary forward secrecy test

This commit is contained in:
Kevin Froman 2020-03-26 03:47:49 -05:00
parent d5c9b01b53
commit 922f2be235
1 changed files with 19 additions and 1 deletions

View File

@ -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)