diff options
author | Donald Stufft <donald@stufft.io> | 2013-10-19 19:49:18 -0700 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2013-10-19 19:49:18 -0700 |
commit | 1caf8ab5ec72d8373bc9af7a9f7b63c2ac0826f7 (patch) | |
tree | 6a07f51334f49e419a7d56019affe4acea430375 | |
parent | 9f9f550a1803fbeb930ff4debfc825bfba0819ca (diff) | |
parent | 79ff8bf91838e0e98ec75b467c0650968bf4f626 (diff) | |
download | cryptography-1caf8ab5ec72d8373bc9af7a9f7b63c2ac0826f7.tar.gz cryptography-1caf8ab5ec72d8373bc9af7a9f7b63c2ac0826f7.tar.bz2 cryptography-1caf8ab5ec72d8373bc9af7a9f7b63c2ac0826f7.zip |
Merge pull request #128 from reaperhulk/hash-saga-whirlpool
Hash Saga Part 6 (Whirlpool support)
-rw-r--r-- | cryptography/primitives/hashes.py | 6 | ||||
-rw-r--r-- | tests/primitives/test_hash_vectors.py | 22 | ||||
-rw-r--r-- | tests/primitives/test_hashes.py | 10 |
3 files changed, 38 insertions, 0 deletions
diff --git a/cryptography/primitives/hashes.py b/cryptography/primitives/hashes.py index affca564..06d90a90 100644 --- a/cryptography/primitives/hashes.py +++ b/cryptography/primitives/hashes.py @@ -76,3 +76,9 @@ class RIPEMD160(BaseHash): name = "ripemd160" digest_size = 20 block_size = 64 + + +class Whirlpool(BaseHash): + name = "whirlpool" + digest_size = 64 + block_size = 64 diff --git a/tests/primitives/test_hash_vectors.py b/tests/primitives/test_hash_vectors.py index 51c4b85d..52c972a3 100644 --- a/tests/primitives/test_hash_vectors.py +++ b/tests/primitives/test_hash_vectors.py @@ -109,3 +109,25 @@ class TestRIPEMD160(object): only_if=lambda api: api.supports_hash(hashes.RIPEMD160), skip_message="Does not support RIPEMD160", ) + + +class TestWhirlpool(object): + test_whirlpool = generate_hash_test( + load_hash_vectors_from_file, + os.path.join("ISO", "whirlpool"), + [ + "iso-test-vectors.txt", + ], + hashes.Whirlpool, + only_if=lambda api: api.supports_hash(hashes.Whirlpool), + skip_message="Does not support Whirlpool", + ) + + test_whirlpool_long_string = generate_long_string_hash_test( + hashes.Whirlpool, + ("0c99005beb57eff50a7cf005560ddf5d29057fd86b2" + "0bfd62deca0f1ccea4af51fc15490eddc47af32bb2b" + "66c34ff9ad8c6008ad677f77126953b226e4ed8b01"), + only_if=lambda api: api.supports_hash(hashes.Whirlpool), + skip_message="Does not support Whirlpool", + ) diff --git a/tests/primitives/test_hashes.py b/tests/primitives/test_hashes.py index bfb45037..982fc7cd 100644 --- a/tests/primitives/test_hashes.py +++ b/tests/primitives/test_hashes.py @@ -76,3 +76,13 @@ class TestRIPEMD160(object): only_if=lambda api: api.supports_hash(hashes.RIPEMD160), skip_message="Does not support RIPEMD160", ) + + +class TestWhirlpool(object): + test_Whirlpool = generate_base_hash_test( + hashes.Whirlpool, + digest_size=64, + block_size=64, + only_if=lambda api: api.supports_hash(hashes.Whirlpool), + skip_message="Does not support Whirlpool", + ) |