aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2013-10-19 16:10:25 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2013-10-19 16:14:11 -0500
commitc3a2b4270fbf9aba44afd04088866f2a3da21af7 (patch)
tree23563d7a19166b4397b5cdeb2524d13902272db7 /tests
parent3b8729006b9f2778158554d3699c05babb0c6489 (diff)
downloadcryptography-c3a2b4270fbf9aba44afd04088866f2a3da21af7.tar.gz
cryptography-c3a2b4270fbf9aba44afd04088866f2a3da21af7.tar.bz2
cryptography-c3a2b4270fbf9aba44afd04088866f2a3da21af7.zip
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/primitives/test_block.py11
1 files changed, 11 insertions, 0 deletions
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