diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-26 09:31:06 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-26 09:31:06 -0800 |
commit | e60e1d782cb7c1abe68811092f7db342ed14b81f (patch) | |
tree | 555ed6a8cecd2759fd22dfbb41f6d61fd46b7788 /cryptography | |
parent | 90501724c5b3d73fea5a4242fa09c32277c6c210 (diff) | |
parent | 6dc73a9bd475dfb7a3c18c65afaeb644cce3749f (diff) | |
download | cryptography-e60e1d782cb7c1abe68811092f7db342ed14b81f.tar.gz cryptography-e60e1d782cb7c1abe68811092f7db342ed14b81f.tar.bz2 cryptography-e60e1d782cb7c1abe68811092f7db342ed14b81f.zip |
Merge pull request #227 from dreid/explicit-backend-in-hazmat
Explicit backend
Diffstat (limited to 'cryptography')
-rw-r--r-- | cryptography/hazmat/bindings/__init__.py | 5 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/ciphers/base.py | 7 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/hashes.py | 6 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/hmac.py | 6 |
4 files changed, 7 insertions, 17 deletions
diff --git a/cryptography/hazmat/bindings/__init__.py b/cryptography/hazmat/bindings/__init__.py index eb828999..bd158198 100644 --- a/cryptography/hazmat/bindings/__init__.py +++ b/cryptography/hazmat/bindings/__init__.py @@ -14,7 +14,10 @@ from cryptography.hazmat.bindings import openssl -_default_backend = openssl.backend _ALL_BACKENDS = [ openssl.backend ] + + +def default_backend(): + return openssl.backend diff --git a/cryptography/hazmat/primitives/ciphers/base.py b/cryptography/hazmat/primitives/ciphers/base.py index 3d733afc..48e6da6f 100644 --- a/cryptography/hazmat/primitives/ciphers/base.py +++ b/cryptography/hazmat/primitives/ciphers/base.py @@ -19,12 +19,7 @@ from cryptography.hazmat.primitives import interfaces class Cipher(object): - def __init__(self, algorithm, mode, backend=None): - if backend is None: - from cryptography.hazmat.bindings import ( - _default_backend as backend, - ) - + def __init__(self, algorithm, mode, backend): if not isinstance(algorithm, interfaces.CipherAlgorithm): raise TypeError("Expected interface of interfaces.CipherAlgorithm") diff --git a/cryptography/hazmat/primitives/hashes.py b/cryptography/hazmat/primitives/hashes.py index 93fc8c42..bee188b3 100644 --- a/cryptography/hazmat/primitives/hashes.py +++ b/cryptography/hazmat/primitives/hashes.py @@ -22,15 +22,11 @@ from cryptography.hazmat.primitives import interfaces @utils.register_interface(interfaces.HashContext) class Hash(object): - def __init__(self, algorithm, backend=None, ctx=None): + def __init__(self, algorithm, backend, ctx=None): if not isinstance(algorithm, interfaces.HashAlgorithm): raise TypeError("Expected instance of interfaces.HashAlgorithm.") self.algorithm = algorithm - if backend is None: - from cryptography.hazmat.bindings import _default_backend - backend = _default_backend - self._backend = backend if ctx is None: diff --git a/cryptography/hazmat/primitives/hmac.py b/cryptography/hazmat/primitives/hmac.py index 08dfae01..618bccc5 100644 --- a/cryptography/hazmat/primitives/hmac.py +++ b/cryptography/hazmat/primitives/hmac.py @@ -22,15 +22,11 @@ from cryptography.hazmat.primitives import interfaces @utils.register_interface(interfaces.HashContext) class HMAC(object): - def __init__(self, key, algorithm, ctx=None, backend=None): + def __init__(self, key, algorithm, backend, ctx=None): if not isinstance(algorithm, interfaces.HashAlgorithm): raise TypeError("Expected instance of interfaces.HashAlgorithm.") self.algorithm = algorithm - if backend is None: - from cryptography.hazmat.bindings import _default_backend - backend = _default_backend - self._backend = backend self._key = key if ctx is None: |