aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hypothesis
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2016-01-13 09:01:42 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2016-01-13 09:01:42 -0500
commitb301627b88f1535d63e2bccbd7845161f7c619b8 (patch)
tree4f93554182f32c60d8f35ce7cd07539ebf9de4af /tests/hypothesis
parent0c2feae1b35131f270a17af3a8573b5cffb54e6c (diff)
downloadcryptography-b301627b88f1535d63e2bccbd7845161f7c619b8.tar.gz
cryptography-b301627b88f1535d63e2bccbd7845161f7c619b8.tar.bz2
cryptography-b301627b88f1535d63e2bccbd7845161f7c619b8.zip
Added hypothesis tests for padding
Diffstat (limited to 'tests/hypothesis')
-rw-r--r--tests/hypothesis/test_padding.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/hypothesis/test_padding.py b/tests/hypothesis/test_padding.py
new file mode 100644
index 00000000..d2b77756
--- /dev/null
+++ b/tests/hypothesis/test_padding.py
@@ -0,0 +1,20 @@
+# This file is dual licensed under the terms of the Apache License, Version
+# 2.0, and the BSD License. See the LICENSE file in the root of this repository
+# for complete details.
+
+from hypothesis import given
+from hypothesis.strategies import binary
+
+from cryptography.hazmat.primitives.padding import PKCS7
+
+
+@given(binary())
+def test_pkcs7(data):
+ # TODO: add additional tests with arbitrary block sizes
+ p = PKCS7(block_size=128)
+ padder = p.padder()
+ unpadder = p.unpadder()
+
+ padded = padder.update(data) + padder.finalize()
+
+ assert unpadder.update(padded) + unpadder.finalize() == data