Browse Source

[test/aes] Test aes_decrypt_text with 256 bit

totalwebcasting
Jaime Marquínez Ferrándiz 10 years ago
parent
commit
f9544f6e8f
2 changed files with 15 additions and 1 deletions
  1. +7
    -1
      devscripts/generate_aes_testdata.py
  2. +8
    -0
      test/test_aes.py

+ 7
- 1
devscripts/generate_aes_testdata.py View File

@ -32,5 +32,11 @@ print(repr(r))
password = key
new_key = aes_encrypt(password, key_expansion(password))
r = openssl_encode('aes-128-ctr', new_key, iv)
print('aes_decrypt_text')
print('aes_decrypt_text 16')
print(repr(r))
password = key + 16 * [0]
new_key = aes_encrypt(password, key_expansion(password)) * (32 // 16)
r = openssl_encode('aes-256-ctr', new_key, iv)
print('aes_decrypt_text 32')
print(repr(r))

+ 8
- 0
test/test_aes.py View File

@ -43,5 +43,13 @@ class TestAES(unittest.TestCase):
decrypted = (aes_decrypt_text(encrypted, password, 16))
self.assertEqual(decrypted, self.secret_msg)
password = intlist_to_bytes(self.key).decode('utf-8')
encrypted = base64.b64encode(
intlist_to_bytes(self.iv[:8]) +
b'\x0b\xe6\xa4\xd9z\x0e\xb8\xb9\xd0\xd4i_\x85\x1d\x99\x98_\xe5\x80\xe7.\xbf\xa5\x83'
)
decrypted = (aes_decrypt_text(encrypted, password, 32))
self.assertEqual(decrypted, self.secret_msg)
if __name__ == '__main__':
unittest.main()

Loading…
Cancel
Save