diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-10-21 17:55:01 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-10-21 18:00:05 -0500 |
commit | 653463f0e133def71425a26fdd80bfe7c8ad5961 (patch) | |
tree | 1572961e89a9b1502ad91464b891b85ca611b426 /tests | |
parent | e98867acf056857d6e9b005fd00c07de2c31570f (diff) | |
download | cryptography-653463f0e133def71425a26fdd80bfe7c8ad5961.tar.gz cryptography-653463f0e133def71425a26fdd80bfe7c8ad5961.tar.bz2 cryptography-653463f0e133def71425a26fdd80bfe7c8ad5961.zip |
address review comments
* inline some methods
* refactor enc/dec classes
* modify docs
Diffstat (limited to 'tests')
-rw-r--r-- | tests/primitives/test_block.py | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/tests/primitives/test_block.py b/tests/primitives/test_block.py index 4a67002f..8e429085 100644 --- a/tests/primitives/test_block.py +++ b/tests/primitives/test_block.py @@ -49,20 +49,20 @@ class TestBlockCipherContext(object): modes.CBC(binascii.unhexlify(b"0" * 32)), api ) - context = cipher.encryptor() - context.update(b"a" * 16) - context.finalize() + encryptor = cipher.encryptor() + encryptor.update(b"a" * 16) + encryptor.finalize() with pytest.raises(ValueError): - context.update(b"b" * 16) + encryptor.update(b"b" * 16) with pytest.raises(ValueError): - context.finalize() - context = cipher.decryptor() - context.update(b"a" * 16) - context.finalize() + encryptor.finalize() + decryptor = cipher.decryptor() + decryptor.update(b"a" * 16) + decryptor.finalize() with pytest.raises(ValueError): - context.update(b"b" * 16) + decryptor.update(b"b" * 16) with pytest.raises(ValueError): - context.finalize() + decryptor.finalize() def test_unaligned_block_encryption(self, api): cipher = BlockCipher( @@ -70,15 +70,16 @@ class TestBlockCipherContext(object): modes.ECB(), api ) - context = cipher.encryptor() - ct = context.update(b"a" * 15) + encryptor = cipher.encryptor() + ct = encryptor.update(b"a" * 15) assert ct == b"" - ct += context.update(b"a" * 65) + ct += encryptor.update(b"a" * 65) assert len(ct) == 80 - ct += context.finalize() - context = cipher.decryptor() - pt = context.update(ct[:3]) + ct += encryptor.finalize() + decryptor = cipher.decryptor() + pt = decryptor.update(ct[:3]) assert pt == b"" - pt += context.update(ct[3:]) + pt += decryptor.update(ct[3:]) assert len(pt) == 80 - context.finalize() + assert pt == b"a" * 80 + decryptor.finalize() |