aboutsummaryrefslogtreecommitdiffstats
path: root/tests/primitives/utils.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2013-10-18 21:42:57 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2013-10-18 21:43:17 -0500
commitc179407406f0ef5c2b7b5b6316521408ba3803b3 (patch)
treef2cdb7322fdf3e6bd0428644dfd54587e0ef4516 /tests/primitives/utils.py
parent3069921d3f1fe201f86e69bc50bf270708f2272a (diff)
downloadcryptography-c179407406f0ef5c2b7b5b6316521408ba3803b3.tar.gz
cryptography-c179407406f0ef5c2b7b5b6316521408ba3803b3.tar.bz2
cryptography-c179407406f0ef5c2b7b5b6316521408ba3803b3.zip
ripemd160 support + long string hash test
* Note that the long string hash test for RIPEMD160 adds a vector in the test. You can verify this vector (for b"a" * 1000000) on the RIPE homepage: http://homes.esat.kuleuven.be/~bosselae/ripemd160.html
Diffstat (limited to 'tests/primitives/utils.py')
-rw-r--r--tests/primitives/utils.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/primitives/utils.py b/tests/primitives/utils.py
index 0d4c0eb3..8b32700b 100644
--- a/tests/primitives/utils.py
+++ b/tests/primitives/utils.py
@@ -95,3 +95,26 @@ def base_hash_test(api, hash_cls, digest_size, block_size, only_if,
m_copy = m.copy()
assert m != m_copy
assert m._ctx != m_copy._ctx
+
+
+def generate_long_string_hash_test(hash_factory, md, only_if=lambda api: True,
+ skip_message=None):
+ def test_long_string_hash(self):
+ for api in _ALL_APIS:
+ yield(
+ long_string_hash_test,
+ api,
+ hash_factory,
+ md,
+ only_if,
+ skip_message
+ )
+ return test_long_string_hash
+
+
+def long_string_hash_test(api, hash_factory, md, only_if, skip_message):
+ if not only_if(api):
+ pytest.skip(skip_message)
+ m = hash_factory(api)
+ m.update(b"a" * 1000000)
+ assert m.hexdigest() == md.lower()