aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-11-13 09:35:23 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2013-11-13 09:35:23 -0800
commit063a3a25630df98f4524fdc54a55cef670810d9f (patch)
treeaf6fa583f318d2d35af1ae5654d9f08d636a1a09 /cryptography
parent4826ec6e7602a3d2bca687afadb97a04a5e85ff2 (diff)
downloadcryptography-063a3a25630df98f4524fdc54a55cef670810d9f.tar.gz
cryptography-063a3a25630df98f4524fdc54a55cef670810d9f.tar.bz2
cryptography-063a3a25630df98f4524fdc54a55cef670810d9f.zip
Remove the hash and hmac specific classes, now that the logic is the Context classes they don't really add value
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/bindings/openssl/backend.py34
-rw-r--r--cryptography/hazmat/primitives/hashes.py2
-rw-r--r--cryptography/hazmat/primitives/hmac.py2
3 files changed, 12 insertions, 26 deletions
diff --git a/cryptography/hazmat/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py
index 71bb9fcd..ff2c939c 100644
--- a/cryptography/hazmat/bindings/openssl/backend.py
+++ b/cryptography/hazmat/bindings/openssl/backend.py
@@ -64,8 +64,6 @@ class Backend(object):
self._ensure_ffi_initialized()
self.ciphers = Ciphers(self)
- self.hashes = Hashes(self)
- self.hmacs = HMACs(self)
@classmethod
def _ensure_ffi_initialized(cls):
@@ -123,6 +121,16 @@ class Backend(object):
"""
return self.ffi.string(self.lib.OPENSSL_VERSION_TEXT).decode("ascii")
+ def create_hmac_ctx(self, key, algorithm):
+ return _HMACContext(self, key, algorithm)
+
+ def hash_supported(self, algorithm):
+ digest = self.lib.EVP_get_digestbyname(algorithm.name.encode("ascii"))
+ return digest != self.ffi.NULL
+
+ def create_hash_ctx(self, algorithm):
+ return _HashContext(self, algorithm)
+
class GetCipherByName(object):
def __init__(self, fmt):
@@ -310,20 +318,6 @@ class _HashContext(object):
return self._backend.ffi.buffer(buf)[:]
-class Hashes(object):
- def __init__(self, backend):
- self._backend = backend
-
- def supported(self, algorithm):
- digest = self._backend.lib.EVP_get_digestbyname(
- algorithm.name.encode("ascii")
- )
- return digest != self._backend.ffi.NULL
-
- def create_ctx(self, algorithm):
- return _HashContext(self._backend, algorithm)
-
-
@interfaces.register(interfaces.HashContext)
class _HMACContext(object):
def __init__(self, backend, key, algorithm, ctx=None):
@@ -376,12 +370,4 @@ class _HMACContext(object):
return self._backend.ffi.buffer(buf)[:]
-class HMACs(object):
- def __init__(self, backend):
- self._backend = backend
-
- def create_ctx(self, key, algorithm):
- return _HMACContext(self._backend, key, algorithm)
-
-
backend = Backend()
diff --git a/cryptography/hazmat/primitives/hashes.py b/cryptography/hazmat/primitives/hashes.py
index 6ae622cd..3bd3ad46 100644
--- a/cryptography/hazmat/primitives/hashes.py
+++ b/cryptography/hazmat/primitives/hashes.py
@@ -32,7 +32,7 @@ class Hash(object):
self._backend = backend
if ctx is None:
- self._ctx = self._backend.hashes.create_ctx(self.algorithm)
+ self._ctx = self._backend.create_hash_ctx(self.algorithm)
else:
self._ctx = ctx
diff --git a/cryptography/hazmat/primitives/hmac.py b/cryptography/hazmat/primitives/hmac.py
index 0f1b4fac..1a67b332 100644
--- a/cryptography/hazmat/primitives/hmac.py
+++ b/cryptography/hazmat/primitives/hmac.py
@@ -32,7 +32,7 @@ class HMAC(object):
self._backend = backend
self._key = key
if ctx is None:
- self._ctx = self._backend.hmacs.create_ctx(key, self.algorithm)
+ self._ctx = self._backend.create_hmac_ctx(key, self.algorithm)
else:
self._ctx = ctx