diff options
author | David Reid <dreid@dreid.org> | 2013-11-15 15:30:20 -0800 |
---|---|---|
committer | David Reid <dreid@dreid.org> | 2013-11-18 09:57:19 -0800 |
commit | df3a462da843955f658d5ab3174799368d57f16b (patch) | |
tree | 7988dd9b98f2db4dcd583456839bbe7fcdb1968f | |
parent | 92ec09ec0b127b67b794c250aa4d32c063ab66aa (diff) | |
download | cryptography-df3a462da843955f658d5ab3174799368d57f16b.tar.gz cryptography-df3a462da843955f658d5ab3174799368d57f16b.tar.bz2 cryptography-df3a462da843955f658d5ab3174799368d57f16b.zip |
Change interface names to fit in the new smaller interface surface and
correct method names on interfaces.
-rw-r--r-- | cryptography/hazmat/bindings/interfaces.py | 72 | ||||
-rw-r--r-- | cryptography/hazmat/bindings/openssl/backend.py | 13 |
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 |