diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-07-01 20:21:33 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-07-01 20:21:33 -0500 |
commit | d5119d530b4bd15cae9e758972e0407a5bcdd244 (patch) | |
tree | 477bb48f4c60942be11cd113baa8961accd5fda1 /tests/hazmat/primitives/test_aes.py | |
parent | 463de43d9cc05ae97e08b3d439b70d44c70f9f62 (diff) | |
download | cryptography-d5119d530b4bd15cae9e758972e0407a5bcdd244.tar.gz cryptography-d5119d530b4bd15cae9e758972e0407a5bcdd244.tar.bz2 cryptography-d5119d530b4bd15cae9e758972e0407a5bcdd244.zip |
add missing test, simplify encrypted byte near limit calculation
Diffstat (limited to 'tests/hazmat/primitives/test_aes.py')
-rw-r--r-- | tests/hazmat/primitives/test_aes.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/hazmat/primitives/test_aes.py b/tests/hazmat/primitives/test_aes.py index 06e8adf8..f079ae4f 100644 --- a/tests/hazmat/primitives/test_aes.py +++ b/tests/hazmat/primitives/test_aes.py @@ -260,9 +260,7 @@ class TestAESModeGCM(object): modes.GCM(b"\x01" * 16), backend=backend ).encryptor() - # 16 bytes less than the encryption limit - near_limit_bytes = (2 ** 39 - 256 - 128) // 8 - encryptor._bytes_processed = near_limit_bytes + encryptor._bytes_processed = modes.GCM._MAX_ENCRYPTED_BYTES - 16 encryptor.update(b"0" * 16) assert ( encryptor._bytes_processed == modes.GCM._MAX_ENCRYPTED_BYTES @@ -270,6 +268,20 @@ class TestAESModeGCM(object): with pytest.raises(ValueError): encryptor.update(b"0") + def test_gcm_aad_limit(self, backend): + encryptor = base.Cipher( + algorithms.AES(b"\x00" * 16), + modes.GCM(b"\x01" * 16), + backend=backend + ).encryptor() + # 16 bytes less than the AAD limit + near_limit_bytes = (2 ** 64 - 128) // 8 + encryptor._aad_bytes_processed = near_limit_bytes + encryptor.authenticate_additional_data(b"0" * 16) + assert encryptor._aad_bytes_processed == modes.GCM._MAX_AAD_BYTES + with pytest.raises(ValueError): + encryptor.authenticate_additional_data(b"0") + def test_gcm_ciphertext_increments(self, backend): encryptor = base.Cipher( algorithms.AES(b"\x00" * 16), |