From c3a2b4270fbf9aba44afd04088866f2a3da21af7 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sat, 19 Oct 2013 16:10:25 -0500 Subject: Unaligned block encryption test This test verifies that the underlying buffer is being sized correctly by passing data into the encryption function without aligning it to the block size of the cipher. This ensures that we will get a larger return value than the initial argument from our second encrypt call. --- tests/primitives/test_block.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/primitives/test_block.py b/tests/primitives/test_block.py index f4d3f467..9f5905bf 100644 --- a/tests/primitives/test_block.py +++ b/tests/primitives/test_block.py @@ -63,3 +63,14 @@ class TestBlockCipher(object): with pytest.raises(ValueError): cipher.finalize() + + def test_unaligned_block_encryption(self, api): + cipher = BlockCipher( + ciphers.AES(binascii.unhexlify(b"0" * 32)), + modes.ECB(), + api + ) + ct = cipher.encrypt(b"a" * 15) + assert ct == b"" + ct += cipher.encrypt(b"a" * 65) + assert len(ct) == 80 -- cgit v1.2.3