diff options
Diffstat (limited to 'tests/hazmat/primitives/test_block.py')
-rw-r--r-- | tests/hazmat/primitives/test_block.py | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/tests/hazmat/primitives/test_block.py b/tests/hazmat/primitives/test_block.py index dd9c54c9..28f34478 100644 --- a/tests/hazmat/primitives/test_block.py +++ b/tests/hazmat/primitives/test_block.py @@ -19,35 +19,37 @@ import pytest from cryptography.exceptions import UnsupportedAlgorithm from cryptography.hazmat.primitives import interfaces -from cryptography.hazmat.primitives.block import BlockCipher, ciphers, modes +from cryptography.hazmat.primitives.ciphers import ( + Cipher, algorithms, modes +) -class TestBlockCipher(object): +class TestCipher(object): def test_instantiate_without_backend(self): - BlockCipher( - ciphers.AES(binascii.unhexlify(b"0" * 32)), + Cipher( + algorithms.AES(binascii.unhexlify(b"0" * 32)), modes.CBC(binascii.unhexlify(b"0" * 32)) ) def test_creates_encryptor(self): - cipher = BlockCipher( - ciphers.AES(binascii.unhexlify(b"0" * 32)), + cipher = Cipher( + algorithms.AES(binascii.unhexlify(b"0" * 32)), modes.CBC(binascii.unhexlify(b"0" * 32)) ) assert isinstance(cipher.encryptor(), interfaces.CipherContext) def test_creates_decryptor(self): - cipher = BlockCipher( - ciphers.AES(binascii.unhexlify(b"0" * 32)), + cipher = Cipher( + algorithms.AES(binascii.unhexlify(b"0" * 32)), modes.CBC(binascii.unhexlify(b"0" * 32)) ) assert isinstance(cipher.decryptor(), interfaces.CipherContext) -class TestBlockCipherContext(object): +class TestCipherContext(object): def test_use_after_finalize(self, backend): - cipher = BlockCipher( - ciphers.AES(binascii.unhexlify(b"0" * 32)), + cipher = Cipher( + algorithms.AES(binascii.unhexlify(b"0" * 32)), modes.CBC(binascii.unhexlify(b"0" * 32)), backend ) @@ -67,8 +69,8 @@ class TestBlockCipherContext(object): decryptor.finalize() def test_unaligned_block_encryption(self, backend): - cipher = BlockCipher( - ciphers.AES(binascii.unhexlify(b"0" * 32)), + cipher = Cipher( + algorithms.AES(binascii.unhexlify(b"0" * 32)), modes.ECB(), backend ) @@ -86,8 +88,8 @@ class TestBlockCipherContext(object): assert pt == b"a" * 80 decryptor.finalize() - def test_nonexistant_cipher(self, backend): - cipher = BlockCipher( + def test_nonexistent_cipher(self, backend): + cipher = Cipher( object(), object(), backend ) with pytest.raises(UnsupportedAlgorithm): |