Alex Gaynor | b301627 | 2016-01-13 09:01:42 -0500 | [diff] [blame^] | 1 | # This file is dual licensed under the terms of the Apache License, Version |
| 2 | # 2.0, and the BSD License. See the LICENSE file in the root of this repository |
| 3 | # for complete details. |
| 4 | |
| 5 | from hypothesis import given |
| 6 | from hypothesis.strategies import binary |
| 7 | |
| 8 | from cryptography.hazmat.primitives.padding import PKCS7 |
| 9 | |
| 10 | |
| 11 | @given(binary()) |
| 12 | def test_pkcs7(data): |
| 13 | # TODO: add additional tests with arbitrary block sizes |
| 14 | p = PKCS7(block_size=128) |
| 15 | padder = p.padder() |
| 16 | unpadder = p.unpadder() |
| 17 | |
| 18 | padded = padder.update(data) + padder.finalize() |
| 19 | |
| 20 | assert unpadder.update(padded) + unpadder.finalize() == data |