aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cryptography/hazmat/bindings/interfaces.py72
-rw-r--r--cryptography/hazmat/bindings/openssl/backend.py13
2 files changed, 15 insertions, 70 deletions
diff --git a/cryptography/hazmat/bindings/interfaces.py b/cryptography/hazmat/bindings/interfaces.py
index 43563d13..ffcd5f14 100644
--- a/cryptography/hazmat/bindings/interfaces.py
+++ b/cryptography/hazmat/bindings/interfaces.py
@@ -18,17 +18,9 @@ import abc
import six
-class CiphersProviderBackend(six.with_metaclass(abc.ABCMeta)):
- @abc.abstractproperty
- def ciphers(self):
- """
- An instance of CiphersProvider
- """
-
-
-class CiphersProvider(six.with_metaclass(abc.ABCMeta)):
+class CipherBackend(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
- def supported(self, cipher, mode):
+ def cipher_supported(self, cipher, mode):
"""
"""
@@ -38,76 +30,30 @@ class CiphersProvider(six.with_metaclass(abc.ABCMeta)):
"""
@abc.abstractmethod
- def create_encrypt_ctx(self, cipher, mode):
- """
- """
-
- @abc.abstractmethod
- def create_decrypt_ctx(self, cipher, mode):
- """
- """
-
-
-class HashesProviderBackend(six.with_metaclass(abc.ABCMeta)):
- @abc.abstractproperty
- def hashes(self):
- """
- An instance of HashesProvider
- """
-
-
-class HashesProvider(six.with_metaclass(abc.ABCMeta)):
- @abc.abstractmethod
- def supported(self, algorithm):
- """
- """
-
- @abc.abstractmethod
- def create_ctx(self, algorithm):
- """
- """
-
- @abc.abstractmethod
- def update_ctx(self, ctx, data):
- """
- """
-
- @abc.abstractmethod
- def finalize_ctx(self, ctx, digest_size):
+ def create_symmetric_encryption_ctx(self, cipher, mode):
"""
"""
@abc.abstractmethod
- def copy_ctx(self, ctx):
+ def create_symmetric_decryption_ctx(self, cipher, mode):
"""
"""
-class HMACsProviderBackend(six.with_metaclass(abc.ABCMeta)):
- @abc.abstractproperty
- def hmacs(self):
- """
- An instance of HMACsProvider
- """
-
-
-class HMACsProvider(six.with_metaclass(abc.ABCMeta)):
+class HashBackend(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
- def create_ctx(self, key, algorithm):
+ def hash_supported(self, algorithm):
"""
"""
@abc.abstractmethod
- def update_ctx(self, ctx, data):
+ def create_hash_ctx(self, algorithm):
"""
"""
- @abc.abstractmethod
- def finalize_ctx(self, ctx, digest_size):
- """
- """
+class HMACBackend(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
- def copy_ctx(self, ctx):
+ def create_hmac_ctx(self, key, algorithm):
"""
"""
diff --git a/cryptography/hazmat/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py
index a7c0741c..db4d18e7 100644
--- a/cryptography/hazmat/bindings/openssl/backend.py
+++ b/cryptography/hazmat/bindings/openssl/backend.py
@@ -21,8 +21,7 @@ import cffi
from cryptography import utils
from cryptography.exceptions import UnsupportedAlgorithm
from cryptography.hazmat.bindings.interfaces import (
- CiphersProviderBackend, CiphersProvider, HashesProviderBackend,
- HashesProvider, HMACsProviderBackend, HMACsProvider
+ CipherBackend, HashBackend, HMACBackend
)
from cryptography.hazmat.primitives import interfaces
from cryptography.hazmat.primitives.ciphers.algorithms import (
@@ -33,9 +32,9 @@ from cryptography.hazmat.primitives.ciphers.modes import (
)
-@utils.register_interface(CiphersProviderBackend)
-@utils.register_interface(HashesProviderBackend)
-@utils.register_interface(HMACsProviderBackend)
+@utils.register_interface(CipherBackend)
+@utils.register_interface(HashBackend)
+@utils.register_interface(HMACBackend)
class Backend(object):
"""
OpenSSL API wrapper.
@@ -275,7 +274,7 @@ class _CipherContext(object):
return self._backend.ffi.buffer(buf)[:outlen[0]]
-@interfaces.register(interfaces.HashContext)
+@utils.register_interface(interfaces.HashContext)
class _HashContext(object):
def __init__(self, backend, algorithm, ctx=None):
self.algorithm = algorithm
@@ -318,7 +317,7 @@ class _HashContext(object):
return self._backend.ffi.buffer(buf)[:]
-@interfaces.register(interfaces.HashContext)
+@utils.register_interface(interfaces.HashContext)
class _HMACContext(object):
def __init__(self, backend, key, algorithm, ctx=None):
self.algorithm = algorithm