diff options
author | Alex Stapleton <alexs@prol.etari.at> | 2014-05-16 15:25:48 +0100 |
---|---|---|
committer | Alex Stapleton <alexs@prol.etari.at> | 2014-05-16 15:25:48 +0100 |
commit | 3a7e9d3f4a9ad32c0782d69620543f6ad3adae93 (patch) | |
tree | 73e814331252a27cba43648ef7cb620eb487d5c2 /tests | |
parent | d1c0fb8bbe0984d54ba0f4b7a8861bca0e446e19 (diff) | |
parent | 2e36fe1289bcf44f9ba232218a0ee666ea34efd2 (diff) | |
download | cryptography-3a7e9d3f4a9ad32c0782d69620543f6ad3adae93.tar.gz cryptography-3a7e9d3f4a9ad32c0782d69620543f6ad3adae93.tar.bz2 cryptography-3a7e9d3f4a9ad32c0782d69620543f6ad3adae93.zip |
Merge pull request #1043 from reaperhulk/support-some-cfb8
add CFB8 support for AES/3DES on CommonCrypto and OpenSSL backends
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hazmat/primitives/test_3des.py | 37 | ||||
-rw-r--r-- | tests/hazmat/primitives/test_aes.py | 33 |
2 files changed, 70 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_3des.py b/tests/hazmat/primitives/test_3des.py index a4d696c9..b9354f0e 100644 --- a/tests/hazmat/primitives/test_3des.py +++ b/tests/hazmat/primitives/test_3des.py @@ -137,3 +137,40 @@ class TestTripleDESModeCFB(object): ), lambda iv, **kwargs: modes.CFB(binascii.unhexlify(iv)), ) + + +@pytest.mark.supported( + only_if=lambda backend: backend.cipher_supported( + algorithms.TripleDES("\x00" * 8), modes.CFB8("\x00" * 8) + ), + skip_message="Does not support TripleDES CFB8", +) +@pytest.mark.cipher +class TestTripleDESModeCFB8(object): + test_KAT = generate_encrypt_test( + load_nist_vectors, + os.path.join("ciphers", "3DES", "CFB"), + [ + "TCFB8invperm.rsp", + "TCFB8permop.rsp", + "TCFB8subtab.rsp", + "TCFB8varkey.rsp", + "TCFB8vartext.rsp", + ], + lambda keys, **kwargs: algorithms.TripleDES(binascii.unhexlify(keys)), + lambda iv, **kwargs: modes.CFB8(binascii.unhexlify(iv)), + ) + + test_MMT = generate_encrypt_test( + load_nist_vectors, + os.path.join("ciphers", "3DES", "CFB"), + [ + "TCFB8MMT1.rsp", + "TCFB8MMT2.rsp", + "TCFB8MMT3.rsp", + ], + lambda key1, key2, key3, **kwargs: algorithms.TripleDES( + binascii.unhexlify(key1 + key2 + key3) + ), + lambda iv, **kwargs: modes.CFB8(binascii.unhexlify(iv)), + ) diff --git a/tests/hazmat/primitives/test_aes.py b/tests/hazmat/primitives/test_aes.py index 03be268d..173075d6 100644 --- a/tests/hazmat/primitives/test_aes.py +++ b/tests/hazmat/primitives/test_aes.py @@ -158,6 +158,39 @@ class TestAESModeCFB(object): @pytest.mark.supported( only_if=lambda backend: backend.cipher_supported( + algorithms.AES("\x00" * 16), modes.CFB8("\x00" * 16) + ), + skip_message="Does not support AES CFB8", +) +@pytest.mark.cipher +class TestAESModeCFB8(object): + test_CFB8 = generate_encrypt_test( + load_nist_vectors, + os.path.join("ciphers", "AES", "CFB"), + [ + "CFB8GFSbox128.rsp", + "CFB8GFSbox192.rsp", + "CFB8GFSbox256.rsp", + "CFB8KeySbox128.rsp", + "CFB8KeySbox192.rsp", + "CFB8KeySbox256.rsp", + "CFB8VarKey128.rsp", + "CFB8VarKey192.rsp", + "CFB8VarKey256.rsp", + "CFB8VarTxt128.rsp", + "CFB8VarTxt192.rsp", + "CFB8VarTxt256.rsp", + "CFB8MMT128.rsp", + "CFB8MMT192.rsp", + "CFB8MMT256.rsp", + ], + lambda key, **kwargs: algorithms.AES(binascii.unhexlify(key)), + lambda iv, **kwargs: modes.CFB8(binascii.unhexlify(iv)), + ) + + +@pytest.mark.supported( + only_if=lambda backend: backend.cipher_supported( algorithms.AES("\x00" * 16), modes.CTR("\x00" * 16) ), skip_message="Does not support AES CTR", |