diff options
| author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-02-16 21:56:31 -0600 | 
|---|---|---|
| committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-02-16 22:21:38 -0600 | 
| commit | cf4f633c08f0b02119926b6d5abd624b18c7cf6e (patch) | |
| tree | 7bcbe67ed78072f0b8170fdfdd04aac8abcb2182 | |
| parent | 3c93e511eed890d397b21fdb6040d252061268ea (diff) | |
| download | cryptography-cf4f633c08f0b02119926b6d5abd624b18c7cf6e.tar.gz cryptography-cf4f633c08f0b02119926b6d5abd624b18c7cf6e.tar.bz2 cryptography-cf4f633c08f0b02119926b6d5abd624b18c7cf6e.zip  | |
add CAST5 CTR support to commoncrypto + tests
| -rw-r--r-- | cryptography/hazmat/backends/commoncrypto/backend.py | 3 | ||||
| -rw-r--r-- | tests/hazmat/primitives/test_cast5.py | 17 | 
2 files changed, 19 insertions, 1 deletions
diff --git a/cryptography/hazmat/backends/commoncrypto/backend.py b/cryptography/hazmat/backends/commoncrypto/backend.py index 5c08a356..4a451d34 100644 --- a/cryptography/hazmat/backends/commoncrypto/backend.py +++ b/cryptography/hazmat/backends/commoncrypto/backend.py @@ -202,7 +202,8 @@ class Backend(object):              (CBC, self._lib.kCCModeCBC),              (ECB, self._lib.kCCModeECB),              (CFB, self._lib.kCCModeCFB), -            (OFB, self._lib.kCCModeOFB) +            (OFB, self._lib.kCCModeOFB), +            (CTR, self._lib.kCCModeCTR)          ]:              self._register_cipher_adapter(                  CAST5, diff --git a/tests/hazmat/primitives/test_cast5.py b/tests/hazmat/primitives/test_cast5.py index 682b4496..c617b817 100644 --- a/tests/hazmat/primitives/test_cast5.py +++ b/tests/hazmat/primitives/test_cast5.py @@ -90,3 +90,20 @@ class TestCAST5_CFB(object):          lambda key, **kwargs: algorithms.CAST5(binascii.unhexlify((key))),          lambda iv, **kwargs: modes.CFB(binascii.unhexlify(iv))      ) + + +@pytest.mark.supported( +    only_if=lambda backend: backend.cipher_supported( +        algorithms.CAST5("\x00" * 16), modes.CTR("\x00" * 8) +    ), +    skip_message="Does not support CAST5 CTR", +) +@pytest.mark.cipher +class TestCAST5_CTR(object): +    test_CFB = generate_encrypt_test( +        load_nist_vectors, +        os.path.join("ciphers", "CAST5"), +        ["cast5-ctr.txt"], +        lambda key, **kwargs: algorithms.CAST5(binascii.unhexlify((key))), +        lambda iv, **kwargs: modes.CTR(binascii.unhexlify(iv)) +    )  | 
