diff options
author | Terry Chia <terrycwk1994@gmail.com> | 2016-11-15 09:56:02 +0800 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-11-15 09:56:02 +0800 |
commit | e9b87d5de47008ddf6fcc6e07deb662cbe376c64 (patch) | |
tree | 162719213c18edc62d9d95b36a8073cbcf986d97 /tests/hazmat/primitives/test_padding.py | |
parent | 9977786b56294292fb7da9eabc0f3b94d638e8a7 (diff) | |
download | cryptography-e9b87d5de47008ddf6fcc6e07deb662cbe376c64.tar.gz cryptography-e9b87d5de47008ddf6fcc6e07deb662cbe376c64.tar.bz2 cryptography-e9b87d5de47008ddf6fcc6e07deb662cbe376c64.zip |
Raise padding block_size limit to what is allowed by the specs. (#3108)
* Raize padding block_size limit to what is allowed by the specs.
* Add tests for raising padding limits.
* Amend C code for padding check to use uint16_t instead of uint8_t.
* Fix test to work in Python 3.
* Fix typo.
* Fix another typo.
* Fix return type of the padding checks.
* Change hypothesis test on padding.
* Update comment.
Diffstat (limited to 'tests/hazmat/primitives/test_padding.py')
-rw-r--r-- | tests/hazmat/primitives/test_padding.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_padding.py b/tests/hazmat/primitives/test_padding.py index e934c0ac..fb72a794 100644 --- a/tests/hazmat/primitives/test_padding.py +++ b/tests/hazmat/primitives/test_padding.py @@ -6,6 +6,8 @@ from __future__ import absolute_import, division, print_function import pytest +import six + from cryptography.exceptions import AlreadyFinalized from cryptography.hazmat.primitives import padding @@ -100,6 +102,20 @@ class TestPKCS7(object): with pytest.raises(AlreadyFinalized): unpadder.finalize() + def test_large_padding(self): + padder = padding.PKCS7(2040).padder() + padded_data = padder.update(b"") + padded_data += padder.finalize() + + for i in six.iterbytes(padded_data): + assert i == 255 + + unpadder = padding.PKCS7(2040).unpadder() + data = unpadder.update(padded_data) + data += unpadder.finalize() + + assert data == b"" + class TestANSIX923(object): @pytest.mark.parametrize("size", [127, 4096, -2]) |