aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_aes.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-07-01 20:05:53 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-07-01 20:05:53 -0500
commit463de43d9cc05ae97e08b3d439b70d44c70f9f62 (patch)
tree35deb0d3c52c2ec0f3f1df8f7efb551182ecb6d6 /tests/hazmat/primitives/test_aes.py
parentb073c8cd31f27af8002174999904556ec283ac7e (diff)
downloadcryptography-463de43d9cc05ae97e08b3d439b70d44c70f9f62.tar.gz
cryptography-463de43d9cc05ae97e08b3d439b70d44c70f9f62.tar.bz2
cryptography-463de43d9cc05ae97e08b3d439b70d44c70f9f62.zip
add additional increment tests
Diffstat (limited to 'tests/hazmat/primitives/test_aes.py')
-rw-r--r--tests/hazmat/primitives/test_aes.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/tests/hazmat/primitives/test_aes.py b/tests/hazmat/primitives/test_aes.py
index 32892678..06e8adf8 100644
--- a/tests/hazmat/primitives/test_aes.py
+++ b/tests/hazmat/primitives/test_aes.py
@@ -270,16 +270,26 @@ class TestAESModeGCM(object):
with pytest.raises(ValueError):
encryptor.update(b"0")
- def test_gcm_aad_limit(self, backend):
+ def test_gcm_ciphertext_increments(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")
+ encryptor.update(b"0" * 8)
+ assert encryptor._bytes_processed == 8
+ encryptor.update(b"0" * 7)
+ assert encryptor._bytes_processed == 15
+ encryptor.update(b"0" * 18)
+ assert encryptor._bytes_processed == 33
+
+ def test_gcm_aad_increments(self, backend):
+ encryptor = base.Cipher(
+ algorithms.AES(b"\x00" * 16),
+ modes.GCM(b"\x01" * 16),
+ backend=backend
+ ).encryptor()
+ encryptor.authenticate_additional_data(b"0" * 8)
+ assert encryptor._aad_bytes_processed == 8
+ encryptor.authenticate_additional_data(b"0" * 18)
+ assert encryptor._aad_bytes_processed == 26