aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-02-16 21:56:31 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-02-16 22:21:38 -0600
commitcf4f633c08f0b02119926b6d5abd624b18c7cf6e (patch)
tree7bcbe67ed78072f0b8170fdfdd04aac8abcb2182
parent3c93e511eed890d397b21fdb6040d252061268ea (diff)
downloadcryptography-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.py3
-rw-r--r--tests/hazmat/primitives/test_cast5.py17
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))
+ )