aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/utils.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-12-06 14:26:08 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2013-12-06 14:26:08 -0800
commitb5c4891e0c2e30118641092aff975e8d0e63cbab (patch)
treeb6209797e16ed81a5021fa6172e47ce2ebd94e1d /tests/hazmat/primitives/utils.py
parent07c36baec6ee7d4a89b3cbe18a37b9e5cbe48f64 (diff)
parenta07925a154e2b28db30499c5a3cf40fedc451d10 (diff)
downloadcryptography-b5c4891e0c2e30118641092aff975e8d0e63cbab.tar.gz
cryptography-b5c4891e0c2e30118641092aff975e8d0e63cbab.tar.bz2
cryptography-b5c4891e0c2e30118641092aff975e8d0e63cbab.zip
Merge pull request #285 from reaperhulk/fix-282
raise ValueErrors when supplying/not supplying tags for GCM
Diffstat (limited to 'tests/hazmat/primitives/utils.py')
-rw-r--r--tests/hazmat/primitives/utils.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py
index 9aa3a89a..705983a0 100644
--- a/tests/hazmat/primitives/utils.py
+++ b/tests/hazmat/primitives/utils.py
@@ -353,3 +353,38 @@ def aead_exception_test(backend, cipher_factory, mode_factory,
decryptor.update(b"a" * 16)
with pytest.raises(AttributeError):
decryptor.tag
+
+
+def generate_aead_tag_exception_test(cipher_factory, mode_factory,
+ only_if, skip_message):
+ def test_aead_tag_exception(self):
+ for backend in _ALL_BACKENDS:
+ yield (
+ aead_tag_exception_test,
+ backend,
+ cipher_factory,
+ mode_factory,
+ only_if,
+ skip_message
+ )
+ return test_aead_tag_exception
+
+
+def aead_tag_exception_test(backend, cipher_factory, mode_factory,
+ only_if, skip_message):
+ if not only_if(backend):
+ pytest.skip(skip_message)
+ cipher = Cipher(
+ cipher_factory(binascii.unhexlify(b"0" * 32)),
+ mode_factory(binascii.unhexlify(b"0" * 24)),
+ backend
+ )
+ with pytest.raises(ValueError):
+ cipher.decryptor()
+ cipher = Cipher(
+ cipher_factory(binascii.unhexlify(b"0" * 32)),
+ mode_factory(binascii.unhexlify(b"0" * 24), b"0" * 16),
+ backend
+ )
+ with pytest.raises(ValueError):
+ cipher.encryptor()