From dff22d4707a50b8164c5c6acd5521bcd91160cd1 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Fri, 27 Sep 2013 13:43:06 -0500 Subject: Camellia block cipher support * Tests for CBC, OFB, CFB, and ECB * Tests will be automatically skipped if camellia support is not present in your OpenSSL library (e.g. OS X 10.8 with default OpenSSL) * Test for unsupported cipher in create_block_cipher_context * Docs for the cipher --- tests/primitives/test_ciphers.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests/primitives/test_ciphers.py') diff --git a/tests/primitives/test_ciphers.py b/tests/primitives/test_ciphers.py index 5ee9f223..27d35850 100644 --- a/tests/primitives/test_ciphers.py +++ b/tests/primitives/test_ciphers.py @@ -17,7 +17,7 @@ import binascii import pytest -from cryptography.primitives.block.ciphers import AES +from cryptography.primitives.block.ciphers import AES, Camellia class TestAES(object): @@ -33,3 +33,18 @@ class TestAES(object): def test_invalid_key_size(self): with pytest.raises(ValueError): AES(binascii.unhexlify(b"0" * 12)) + + +class TestCamellia(object): + @pytest.mark.parametrize(("key", "keysize"), [ + (b"0" * 32, 128), + (b"0" * 48, 192), + (b"0" * 64, 256), + ]) + def test_key_size(self, key, keysize): + cipher = Camellia(binascii.unhexlify(key)) + assert cipher.key_size == keysize + + def test_invalid_key_size(self): + with pytest.raises(ValueError): + Camellia(binascii.unhexlify(b"0" * 12)) -- cgit v1.2.3