aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_pbkdf2hmac.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hazmat/primitives/test_pbkdf2hmac.py')
-rw-r--r--tests/hazmat/primitives/test_pbkdf2hmac.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/hazmat/primitives/test_pbkdf2hmac.py b/tests/hazmat/primitives/test_pbkdf2hmac.py
index 6ad225a8..62ca0921 100644
--- a/tests/hazmat/primitives/test_pbkdf2hmac.py
+++ b/tests/hazmat/primitives/test_pbkdf2hmac.py
@@ -18,11 +18,13 @@ import six
from cryptography import utils
from cryptography.exceptions import (
- InvalidKey, UnsupportedAlgorithm, AlreadyFinalized
+ AlreadyFinalized, InvalidKey, _Reasons
)
+from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes, interfaces
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
-from cryptography.hazmat.backends import default_backend
+
+from ...utils import raises_unsupported_algorithm
@utils.register_interface(interfaces.HashAlgorithm)
@@ -48,7 +50,7 @@ class TestPBKDF2HMAC(object):
kdf.verify(b"password", key)
def test_unsupported_algorithm(self):
- with pytest.raises(UnsupportedAlgorithm):
+ with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_HASH):
PBKDF2HMAC(DummyHash(), 20, b"salt", 10, default_backend())
def test_invalid_key(self):
@@ -67,3 +69,10 @@ class TestPBKDF2HMAC(object):
kdf = PBKDF2HMAC(hashes.SHA1(), 20, b"salt", 10, default_backend())
with pytest.raises(TypeError):
kdf.derive(six.u("unicode here"))
+
+
+def test_invalid_backend():
+ pretend_backend = object()
+
+ with raises_unsupported_algorithm(_Reasons.BACKEND_MISSING_INTERFACE):
+ PBKDF2HMAC(hashes.SHA1(), 20, b"salt", 10, pretend_backend)