From 250903aa4c1776a1859bbb41b9e19953e0733206 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Fri, 9 Aug 2013 12:12:30 -0700 Subject: Removed duplicate tests, added tests + fix for use after finalize --- tests/primitives/test_block.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'tests') 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() -- cgit v1.2.3