diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-02-16 20:57:49 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-02-16 20:57:49 -0800 |
commit | 23532b67d0027ad343b056cfb4bbb7a363c5145a (patch) | |
tree | 3fe5a77e8bf5a3b95dbf369e8218a8d48bcca30f | |
parent | 3c93e511eed890d397b21fdb6040d252061268ea (diff) | |
parent | d2644ddae721337b20805fa2bf751b79c22f669b (diff) | |
download | cryptography-23532b67d0027ad343b056cfb4bbb7a363c5145a.tar.gz cryptography-23532b67d0027ad343b056cfb4bbb7a363c5145a.tar.bz2 cryptography-23532b67d0027ad343b056cfb4bbb7a363c5145a.zip |
Merge pull request #629 from reaperhulk/cast5-ctr-support
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..21119286 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_CTR = 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)) + ) |