diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-11-07 08:02:13 +0800 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-11-07 08:02:13 +0800 |
commit | a5f04c053ca819d6d8be485d2b62a6bed8bdf195 (patch) | |
tree | 9b4a684e814fbb41fee846d5721edb2f34bd4954 /tests/hazmat/primitives | |
parent | 4da28c35d93e14a5e6b0a252751e7cfbaf0fe372 (diff) | |
download | cryptography-a5f04c053ca819d6d8be485d2b62a6bed8bdf195.tar.gz cryptography-a5f04c053ca819d6d8be485d2b62a6bed8bdf195.tar.bz2 cryptography-a5f04c053ca819d6d8be485d2b62a6bed8bdf195.zip |
add ARC4 keysize testing
Diffstat (limited to 'tests/hazmat/primitives')
-rw-r--r-- | tests/hazmat/primitives/test_ciphers.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/hazmat/primitives/test_ciphers.py b/tests/hazmat/primitives/test_ciphers.py index dfafab3f..653f7ce6 100644 --- a/tests/hazmat/primitives/test_ciphers.py +++ b/tests/hazmat/primitives/test_ciphers.py @@ -18,7 +18,7 @@ import binascii import pytest from cryptography.hazmat.primitives.ciphers.algorithms import ( - AES, Camellia, TripleDES, Blowfish, CAST5 + AES, Camellia, TripleDES, Blowfish, CAST5, ARC4 ) @@ -91,3 +91,22 @@ class TestCAST5(object): def test_invalid_key_size(self): with pytest.raises(ValueError): CAST5(binascii.unhexlify(b"0" * 34)) + + +class TestARC4(object): + @pytest.mark.parametrize(("key", "keysize"), [ + (b"0" * 10, 40), + (b"0" * 14, 56), + (b"0" * 16, 64), + (b"0" * 20, 80), + (b"0" * 32, 128), + (b"0" * 48, 192), + (b"0" * 64, 256), + ]) + def test_key_size(self, key, keysize): + cipher = ARC4(binascii.unhexlify(key)) + assert cipher.key_size == keysize + + def test_invalid_key_size(self): + with pytest.raises(ValueError): + ARC4(binascii.unhexlify(b"0" * 34)) |