aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-03-16 08:03:21 -0430
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-03-16 08:03:21 -0430
commite2083365826c231f0a11efb7555280b4a1579a9e (patch)
tree8efa000377e25dc9b99fb77dcc03b7ba663395ae /cryptography
parent3fb221f1fb02ffed7a558bd06ba41bb75c329fc5 (diff)
parentb018dbc6a3a5cb0c4697f8623ddb021cebc27330 (diff)
downloadcryptography-e2083365826c231f0a11efb7555280b4a1579a9e.tar.gz
cryptography-e2083365826c231f0a11efb7555280b4a1579a9e.tar.bz2
cryptography-e2083365826c231f0a11efb7555280b4a1579a9e.zip
Merge pull request #804 from Ayrx/add-backend-check-to-hashes
Added backend check to hash primitives
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/primitives/hashes.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/cryptography/hazmat/primitives/hashes.py b/cryptography/hazmat/primitives/hashes.py
index bee188b3..409f564e 100644
--- a/cryptography/hazmat/primitives/hashes.py
+++ b/cryptography/hazmat/primitives/hashes.py
@@ -16,13 +16,18 @@ from __future__ import absolute_import, division, print_function
import six
from cryptography import utils
-from cryptography.exceptions import AlreadyFinalized
+from cryptography.exceptions import AlreadyFinalized, UnsupportedInterface
+from cryptography.hazmat.backends.interfaces import HashBackend
from cryptography.hazmat.primitives import interfaces
@utils.register_interface(interfaces.HashContext)
class Hash(object):
def __init__(self, algorithm, backend, ctx=None):
+ if not isinstance(backend, HashBackend):
+ raise UnsupportedInterface(
+ "Backend object does not implement HashBackend")
+
if not isinstance(algorithm, interfaces.HashAlgorithm):
raise TypeError("Expected instance of interfaces.HashAlgorithm.")
self.algorithm = algorithm