diff options
Diffstat (limited to 'cryptography/hazmat/bindings/openssl/backend.py')
-rw-r--r-- | cryptography/hazmat/bindings/openssl/backend.py | 34 |
1 files changed, 10 insertions, 24 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() |