diff options
Diffstat (limited to 'tests/hazmat/primitives/test_ciphers.py')
-rw-r--r-- | tests/hazmat/primitives/test_ciphers.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/hazmat/primitives/test_ciphers.py b/tests/hazmat/primitives/test_ciphers.py index 50cadf64..9f8123eb 100644 --- a/tests/hazmat/primitives/test_ciphers.py +++ b/tests/hazmat/primitives/test_ciphers.py @@ -17,9 +17,14 @@ import binascii import pytest +from cryptography.exceptions import _Reasons +from cryptography.hazmat.primitives import ciphers from cryptography.hazmat.primitives.ciphers.algorithms import ( - AES, Camellia, TripleDES, Blowfish, ARC4, CAST5 + AES, ARC4, Blowfish, CAST5, Camellia, IDEA, TripleDES ) +from cryptography.hazmat.primitives.ciphers.modes import ECB + +from ...utils import raises_unsupported_algorithm class TestAES(object): @@ -110,3 +115,20 @@ class TestARC4(object): def test_invalid_key_size(self): with pytest.raises(ValueError): ARC4(binascii.unhexlify(b"0" * 34)) + + +class TestIDEA(object): + def test_key_size(self): + cipher = IDEA(b"\x00" * 16) + assert cipher.key_size == 128 + + def test_invalid_key_size(self): + with pytest.raises(ValueError): + IDEA(b"\x00" * 17) + + +def test_invalid_backend(): + pretend_backend = object() + + with raises_unsupported_algorithm(_Reasons.BACKEND_MISSING_INTERFACE): + ciphers.Cipher(AES(b"AAAAAAAAAAAAAAAA"), ECB, pretend_backend) |