From e0608db24e4744fd0aeb83a52d173e66989cd54c Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Wed, 29 Jan 2014 17:17:44 -0600 Subject: simplify hmac supported and hash supported calls for commoncrypto --- cryptography/hazmat/backends/commoncrypto/backend.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/cryptography/hazmat/backends/commoncrypto/backend.py b/cryptography/hazmat/backends/commoncrypto/backend.py index 4e70cab5..b612a805 100644 --- a/cryptography/hazmat/backends/commoncrypto/backend.py +++ b/cryptography/hazmat/backends/commoncrypto/backend.py @@ -90,20 +90,10 @@ class Backend(object): } def hash_supported(self, algorithm): - try: - self._hash_mapping[algorithm.name] - except KeyError: - return False - else: - return True + return algorithm.name in self._hash_mapping def hmac_supported(self, algorithm): - try: - self._supported_hmac_algorithms[algorithm.name] - except KeyError: - return False - else: - return True + return algorithm.name in self._supported_hmac_algorithms def create_hash_ctx(self, algorithm): return _HashContext(self, algorithm) -- cgit v1.2.3 From ef9d65a808d5afef3f7824cf0300aac21e7c698f Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Wed, 29 Jan 2014 17:20:10 -0600 Subject: one more replacement --- cryptography/hazmat/backends/commoncrypto/backend.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cryptography/hazmat/backends/commoncrypto/backend.py b/cryptography/hazmat/backends/commoncrypto/backend.py index b612a805..6a986090 100644 --- a/cryptography/hazmat/backends/commoncrypto/backend.py +++ b/cryptography/hazmat/backends/commoncrypto/backend.py @@ -102,11 +102,7 @@ class Backend(object): return _HMACContext(self, key, algorithm) def cipher_supported(self, cipher, mode): - try: - self._cipher_registry[type(cipher), type(mode)] - except KeyError: - return False - return True + return (type(cipher), type(mode)) in self._cipher_registry def create_symmetric_encryption_ctx(self, cipher, mode): if isinstance(mode, GCM): -- cgit v1.2.3