aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_block.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hazmat/primitives/test_block.py')
-rw-r--r--tests/hazmat/primitives/test_block.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_block.py b/tests/hazmat/primitives/test_block.py
index 9460c53d..ea40127e 100644
--- a/tests/hazmat/primitives/test_block.py
+++ b/tests/hazmat/primitives/test_block.py
@@ -108,3 +108,19 @@ class TestCipherContext(object):
with pytest.raises(UnsupportedAlgorithm):
cipher.decryptor()
+
+ def test_incorrectly_padded(self, backend):
+ cipher = Cipher(
+ algorithms.AES(b"\x00" * 16),
+ modes.CBC(b"\x00" * 16),
+ backend
+ )
+ encryptor = cipher.encryptor()
+ encryptor.update(b"1")
+ with pytest.raises(ValueError):
+ encryptor.finalize()
+
+ decryptor = cipher.decryptor()
+ decryptor.update(b"1")
+ with pytest.raises(ValueError):
+ decryptor.finalize()