aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_hashes.py
diff options
context:
space:
mode:
authorJulian Krause <julian.krause@gmail.com>2013-12-25 12:58:40 -0800
committerJulian Krause <julian.krause@gmail.com>2013-12-25 12:58:40 -0800
commite62760af74ebb8b08d7670dfaff177cdeb679f0f (patch)
tree70e51d6aadff7d1ec204793b12de221610204254 /tests/hazmat/primitives/test_hashes.py
parentc91fe6a21fbae3107de7b2e53b7343cd67ac8c6d (diff)
parent0865a8b81075bfe073aba56e03cc57c30bfffe00 (diff)
downloadcryptography-e62760af74ebb8b08d7670dfaff177cdeb679f0f.tar.gz
cryptography-e62760af74ebb8b08d7670dfaff177cdeb679f0f.tar.bz2
cryptography-e62760af74ebb8b08d7670dfaff177cdeb679f0f.zip
Merge branch 'master' of https://github.com/pyca/cryptography into verify
Conflicts: tests/hazmat/primitives/test_hashes.py tests/hazmat/primitives/test_hmac.py
Diffstat (limited to 'tests/hazmat/primitives/test_hashes.py')
-rw-r--r--tests/hazmat/primitives/test_hashes.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/hazmat/primitives/test_hashes.py b/tests/hazmat/primitives/test_hashes.py
index cd58b065..69d0773a 100644
--- a/tests/hazmat/primitives/test_hashes.py
+++ b/tests/hazmat/primitives/test_hashes.py
@@ -19,12 +19,21 @@ import pytest
import six
-from cryptography.exceptions import AlreadyFinalized, InvalidSignature
-from cryptography.hazmat.primitives import hashes
+from cryptography import utils
+from cryptography.exceptions import (
+ AlreadyFinalized, UnsupportedAlgorithm, InvalidSignature
+)
+from cryptography.hazmat.primitives import hashes, interfaces
from .utils import generate_base_hash_test
+@utils.register_interface(interfaces.HashAlgorithm)
+class UnsupportedDummyHash(object):
+ name = "unsupported-dummy-hash"
+
+
+@pytest.mark.hash
class TestHashContext(object):
def test_hash_reject_unicode(self, backend):
m = hashes.Hash(hashes.SHA1(), backend=backend)
@@ -80,7 +89,12 @@ class TestHashContext(object):
with pytest.raises(TypeError):
h.verify(six.u(''))
+ def test_unsupported_hash(self, backend):
+ with pytest.raises(UnsupportedAlgorithm):
+ hashes.Hash(UnsupportedDummyHash(), backend)
+
+@pytest.mark.hash
class TestSHA1(object):
test_SHA1 = generate_base_hash_test(
hashes.SHA1(),
@@ -91,6 +105,7 @@ class TestSHA1(object):
)
+@pytest.mark.hash
class TestSHA224(object):
test_SHA224 = generate_base_hash_test(
hashes.SHA224(),
@@ -101,6 +116,7 @@ class TestSHA224(object):
)
+@pytest.mark.hash
class TestSHA256(object):
test_SHA256 = generate_base_hash_test(
hashes.SHA256(),
@@ -111,6 +127,7 @@ class TestSHA256(object):
)
+@pytest.mark.hash
class TestSHA384(object):
test_SHA384 = generate_base_hash_test(
hashes.SHA384(),
@@ -121,6 +138,7 @@ class TestSHA384(object):
)
+@pytest.mark.hash
class TestSHA512(object):
test_SHA512 = generate_base_hash_test(
hashes.SHA512(),
@@ -131,6 +149,7 @@ class TestSHA512(object):
)
+@pytest.mark.hash
class TestRIPEMD160(object):
test_RIPEMD160 = generate_base_hash_test(
hashes.RIPEMD160(),
@@ -141,6 +160,7 @@ class TestRIPEMD160(object):
)
+@pytest.mark.hash
class TestWhirlpool(object):
test_Whirlpool = generate_base_hash_test(
hashes.Whirlpool(),
@@ -151,6 +171,7 @@ class TestWhirlpool(object):
)
+@pytest.mark.hash
class TestMD5(object):
test_MD5 = generate_base_hash_test(
hashes.MD5(),