aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCédric Krier <ced@b2ck.com>2016-02-27 00:28:39 +0100
committerCédric Krier <ced@b2ck.com>2016-02-27 19:24:42 +0100
commit94f9ea25b50a3dd2592abfc63385989955e60e68 (patch)
treef9301d7a74915ab2991e732d3034367e82ae65ee /tests
parentf8c230d1ab16905c64baa88322aa0bb4e8f094bd (diff)
downloadcryptography-94f9ea25b50a3dd2592abfc63385989955e60e68.tar.gz
cryptography-94f9ea25b50a3dd2592abfc63385989955e60e68.tar.bz2
cryptography-94f9ea25b50a3dd2592abfc63385989955e60e68.zip
Add padding check for ANSI X.923
All padding bytes must be 0.
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/primitives/test_padding.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_padding.py b/tests/hazmat/primitives/test_padding.py
index 9da8ea7a..9126e5bf 100644
--- a/tests/hazmat/primitives/test_padding.py
+++ b/tests/hazmat/primitives/test_padding.py
@@ -102,6 +102,21 @@ class TestPKCS7(object):
class TestANSIX923(object):
+ @pytest.mark.parametrize(("size", "padded"), [
+ (128, b"1111"),
+ (128, b"1111111111111111"),
+ (128, b"111111111111111\x06"),
+ (128, b"1111111111\x06\x06\x06\x06\x06\x06"),
+ (128, b""),
+ (128, b"\x06" * 6),
+ (128, b"\x00" * 16),
+ ])
+ def test_invalid_padding(self, size, padded):
+ unpadder = padding.ANSIX923(size).unpadder()
+ with pytest.raises(ValueError):
+ unpadder.update(padded)
+ unpadder.finalize()
+
@pytest.mark.parametrize(("size", "unpadded", "padded"), [
(
128,