diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-08-09 12:12:30 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-08-09 12:12:30 -0700 |
commit | 250903aa4c1776a1859bbb41b9e19953e0733206 (patch) | |
tree | 03f5af319475080420822f8bc1d4f70ace4ba8e4 /tests/primitives/test_block.py | |
parent | 0b26f787601acedf80d8fad5c71bf60c907b5201 (diff) | |
download | cryptography-250903aa4c1776a1859bbb41b9e19953e0733206.tar.gz cryptography-250903aa4c1776a1859bbb41b9e19953e0733206.tar.bz2 cryptography-250903aa4c1776a1859bbb41b9e19953e0733206.zip |
Removed duplicate tests, added tests + fix for use after finalize
Diffstat (limited to 'tests/primitives/test_block.py')
-rw-r--r-- | tests/primitives/test_block.py | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/tests/primitives/test_block.py b/tests/primitives/test_block.py index 5e342d2f..79d65a0f 100644 --- a/tests/primitives/test_block.py +++ b/tests/primitives/test_block.py @@ -4,22 +4,16 @@ import pytest from cryptography.primitives.block import BlockCipher, ciphers, modes, padding -from ..utils import load_nist_vectors_from_file - class TestBlockCipher(object): - @pytest.mark.parametrize(("key", "iv", "plaintext", "ciphertext"), - load_nist_vectors_from_file( - "AES/KAT/CBCGFSbox256.rsp", - "ENCRYPT", - ["key", "iv", "plaintext", "ciphertext"] - ) - ) - def test_aes_cbc_nopadding(self, key, iv, plaintext, ciphertext): + def test_use_after_finalize(self): cipher = BlockCipher( - ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + ciphers.AES(binascii.unhexlify(b"0" * 32)), + modes.CBC(binascii.unhexlify(b"0" * 32), padding.NoPadding()) ) - actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) - actual_ciphertext += cipher.finalize() - assert binascii.hexlify(actual_ciphertext) + cipher.encrypt(b"a" * 16) + cipher.finalize() + with pytest.raises(ValueError): + cipher.encrypt(b"b" * 16) + with pytest.raises(ValueError): + cipher.finalize() |