test (memory): fixes crypto encryption/decryption test
This commit is contained in:
parent
4e2366a3d5
commit
7a9392f486
1 changed files with 8 additions and 4 deletions
|
|
@ -34,14 +34,18 @@ class CryptoTest(helpers.SatTestCase):
|
|||
|
||||
def test_encrypt_decrypt(self):
|
||||
d_list = []
|
||||
|
||||
def test(key, message):
|
||||
d = BlockCipher.encrypt(key, message)
|
||||
d.addCallback(lambda ciphertext: BlockCipher.decrypt(key, ciphertext))
|
||||
d.addCallback(lambda decrypted: self.assertEqual(message, decrypted))
|
||||
d_list.append(d)
|
||||
|
||||
for key_len in (0, 2, 8, 10, 16, 24, 30, 32, 40):
|
||||
key = urandom(key_len)
|
||||
for message_len in (0, 2, 16, 24, 32, 100):
|
||||
message = urandom(message_len)
|
||||
d = BlockCipher.encrypt(key, message)
|
||||
d.addCallback(lambda ciphertext: lambda key, cipher: BlockCipher.decrypt(key, ciphertext))
|
||||
d.addCallback(lambda decrypted: lambda message, decrypted: self.assertEqual(message, decrypted))
|
||||
d_list.append(d)
|
||||
test(key, message)
|
||||
return defer.DeferredList(d_list)
|
||||
|
||||
def test_hash_verify(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue