diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-16 16:55:40 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-16 16:55:40 -0700 |
commit | e761f8b33519104605b14cf8a24e9f68bd23b624 (patch) | |
tree | 672968fa7c23790bc9f5c9cd3c779adce09fae8c /tests/primitives/test_block.py | |
parent | 62ebc7e212a92a13c3836de5d129cb93f40a128d (diff) | |
parent | 169dee88faa7c46b5551b89cf97a1b30c0a1c6ea (diff) | |
download | cryptography-e761f8b33519104605b14cf8a24e9f68bd23b624.tar.gz cryptography-e761f8b33519104605b14cf8a24e9f68bd23b624.tar.bz2 cryptography-e761f8b33519104605b14cf8a24e9f68bd23b624.zip |
Merge branch 'master' into triple-des
Also moved most of the tests to the new format except for one which doesn't yet
have an obvious translation
Conflicts:
cryptography/primitives/block/ciphers.py
tests/primitives/test_nist.py
Diffstat (limited to 'tests/primitives/test_block.py')
-rw-r--r-- | tests/primitives/test_block.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/tests/primitives/test_block.py b/tests/primitives/test_block.py index 774409ca..774885fa 100644 --- a/tests/primitives/test_block.py +++ b/tests/primitives/test_block.py @@ -23,18 +23,27 @@ from cryptography.primitives.block.base import _Operation class TestBlockCipher(object): - def test_cipher_name(self): + def test_cipher_name(self, api): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), - modes.CBC(binascii.unhexlify(b"0" * 32)) + modes.CBC(binascii.unhexlify(b"0" * 32)), + api ) assert cipher.name == "AES-128-CBC" - def test_use_after_finalize(self): + def test_instantiate_without_api(self): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), modes.CBC(binascii.unhexlify(b"0" * 32)) ) + assert cipher.name == "AES-128-CBC" + + def test_use_after_finalize(self, api): + cipher = BlockCipher( + ciphers.AES(binascii.unhexlify(b"0" * 32)), + modes.CBC(binascii.unhexlify(b"0" * 32)), + api + ) cipher.encrypt(b"a" * 16) cipher.finalize() with pytest.raises(ValueError): @@ -42,20 +51,22 @@ class TestBlockCipher(object): with pytest.raises(ValueError): cipher.finalize() - def test_encrypt_with_invalid_operation(self): + def test_encrypt_with_invalid_operation(self, api): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), - modes.CBC(binascii.unhexlify(b"0" * 32)) + modes.CBC(binascii.unhexlify(b"0" * 32)), + api ) cipher._operation = _Operation.decrypt with pytest.raises(ValueError): cipher.encrypt(b"b" * 16) - def test_finalize_with_invalid_operation(self): + def test_finalize_with_invalid_operation(self, api): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), - modes.CBC(binascii.unhexlify(b"0" * 32)) + modes.CBC(binascii.unhexlify(b"0" * 32)), + api ) cipher._operation = pretend.stub(name="wat") |