diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-11-22 14:10:59 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-11-29 17:19:45 -0600 |
commit | ce9c611feb4db781fcab5b7bbc68b936816d6a73 (patch) | |
tree | 4a100b1c88c38cba5df20ee4950d240507e7d7d1 /tests/hazmat/primitives/utils.py | |
parent | 6331daa36902edf5a5dd04e4e3fa0e188db59420 (diff) | |
download | cryptography-ce9c611feb4db781fcab5b7bbc68b936816d6a73.tar.gz cryptography-ce9c611feb4db781fcab5b7bbc68b936816d6a73.tar.bz2 cryptography-ce9c611feb4db781fcab5b7bbc68b936816d6a73.zip |
enforce AEAD add_data before update
Diffstat (limited to 'tests/hazmat/primitives/utils.py')
-rw-r--r-- | tests/hazmat/primitives/utils.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py index 2a99cab9..8df02e78 100644 --- a/tests/hazmat/primitives/utils.py +++ b/tests/hazmat/primitives/utils.py @@ -7,7 +7,7 @@ from cryptography.hazmat.bindings import _ALL_BACKENDS from cryptography.hazmat.primitives import hashes, hmac from cryptography.hazmat.primitives.ciphers import Cipher from cryptography.exceptions import ( - AlreadyFinalized, NotYetFinalized, + AlreadyFinalized, NotYetFinalized, AlreadyUpdated, ) from ...utils import load_vectors_from_file @@ -307,23 +307,23 @@ def base_hmac_test(backend, algorithm, only_if, skip_message): assert h._ctx != h_copy._ctx -def generate_aead_use_after_finalize_test(cipher_factory, mode_factory, - only_if, skip_message): - def test_aead_use_after_finalize(self): +def generate_aead_exception_test(cipher_factory, mode_factory, + only_if, skip_message): + def test_aead_exception(self): for backend in _ALL_BACKENDS: yield ( - aead_use_after_finalize_test, + aead_exception_test, backend, cipher_factory, mode_factory, only_if, skip_message ) - return test_aead_use_after_finalize + return test_aead_exception -def aead_use_after_finalize_test(backend, cipher_factory, mode_factory, - only_if, skip_message): +def aead_exception_test(backend, cipher_factory, mode_factory, + only_if, skip_message): if not only_if(backend): pytest.skip(skip_message) cipher = Cipher( @@ -335,6 +335,8 @@ def aead_use_after_finalize_test(backend, cipher_factory, mode_factory, encryptor.update(b"a" * 16) with pytest.raises(NotYetFinalized): encryptor.tag + with pytest.raises(AlreadyUpdated): + encryptor.add_data(b"b" * 16) encryptor.finalize() with pytest.raises(AlreadyFinalized): encryptor.add_data(b"b" * 16) |