def test_aes_encryption_consistency(self):
# test encryption-decryption for each test message
for msg in self.TEST_MSGS:
# precreate simple ASN.1 structure to encode and encrypt
test_der = encode(OctetString(msg))
# generate random IV and a key
iv = urandom(16)
key = urandom(16)
# encrypt and decrypt message
ct = self.crypto_obj._Crypto__encrypt_with_aes(test_der, key, iv)
pt = self.crypto_obj._Crypto__decrypt_with_aes(ct, key, iv)
# check whether they are equal
self.assertEqual(test_der, pt)
评论列表
文章目录