aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-03-16 08:04:10 -0430
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-03-16 08:04:10 -0430
commit77fdd4e4559c30ee0155430f6fe192311b5eae8b (patch)
tree22351055cf68c4306926d3dfff3430d21f68c376 /cryptography
parente2083365826c231f0a11efb7555280b4a1579a9e (diff)
parentf575ec18b36fd87ff54d63ed959781070efdf053 (diff)
downloadcryptography-77fdd4e4559c30ee0155430f6fe192311b5eae8b.tar.gz
cryptography-77fdd4e4559c30ee0155430f6fe192311b5eae8b.tar.bz2
cryptography-77fdd4e4559c30ee0155430f6fe192311b5eae8b.zip
Merge pull request #805 from Ayrx/add-backend-check-to-hmac
Added backend check to hmac primitives
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/primitives/hmac.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/cryptography/hazmat/primitives/hmac.py b/cryptography/hazmat/primitives/hmac.py
index 76d658aa..18cf7f09 100644
--- a/cryptography/hazmat/primitives/hmac.py
+++ b/cryptography/hazmat/primitives/hmac.py
@@ -16,13 +16,21 @@ from __future__ import absolute_import, division, print_function
import six
from cryptography import utils
-from cryptography.exceptions import AlreadyFinalized, InvalidSignature
+from cryptography.exceptions import (
+ AlreadyFinalized, InvalidSignature, UnsupportedInterface
+)
+
+from cryptography.hazmat.backends.interfaces import HMACBackend
from cryptography.hazmat.primitives import constant_time, interfaces
@utils.register_interface(interfaces.HashContext)
class HMAC(object):
def __init__(self, key, algorithm, backend, ctx=None):
+ if not isinstance(backend, HMACBackend):
+ raise UnsupportedInterface(
+ "Backend object does not implement HMACBackend")
+
if not isinstance(algorithm, interfaces.HashAlgorithm):
raise TypeError("Expected instance of interfaces.HashAlgorithm.")
self.algorithm = algorithm