diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-12-27 16:33:14 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-12-27 16:33:14 -0600 |
commit | b078d8e1f446a1d2d13453e65e37fbaf4f6b17f2 (patch) | |
tree | 9d0245225f32a2faf38a430c6cfd0cbddaadb8a0 /tests/hazmat/primitives/utils.py | |
parent | ec49550b1f29c52164a3f4bca7779e7dc23d397f (diff) | |
download | cryptography-b078d8e1f446a1d2d13453e65e37fbaf4f6b17f2.tar.gz cryptography-b078d8e1f446a1d2d13453e65e37fbaf4f6b17f2.tar.bz2 cryptography-b078d8e1f446a1d2d13453e65e37fbaf4f6b17f2.zip |
re-add some removed generators to simplify patch
Diffstat (limited to 'tests/hazmat/primitives/utils.py')
-rw-r--r-- | tests/hazmat/primitives/utils.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py index 3c962752..cdcf84cb 100644 --- a/tests/hazmat/primitives/utils.py +++ b/tests/hazmat/primitives/utils.py @@ -149,6 +149,12 @@ def hash_test(backend, algorithm, params): assert m.finalize() == binascii.unhexlify(expected_md) +def generate_base_hash_test(algorithm, digest_size, block_size): + def test_base_hash(self, backend): + base_hash_test(backend, algorithm, digest_size, block_size) + return test_base_hash + + def base_hash_test(backend, algorithm, digest_size, block_size): m = hashes.Hash(algorithm, backend=backend) assert m.algorithm.digest_size == digest_size @@ -176,6 +182,20 @@ def long_string_hash_test(backend, algorithm, md): assert m.finalize() == binascii.unhexlify(md.lower().encode("ascii")) +def generate_base_hmac_test(hash_cls): + def test_base_hmac(self, backend): + base_hmac_test(backend, hash_cls) + return test_base_hmac + + +def base_hmac_test(backend, algorithm): + key = b"ab" + h = hmac.HMAC(binascii.unhexlify(key), algorithm, backend=backend) + h_copy = h.copy() + assert h != h_copy + assert h._ctx != h_copy._ctx + + def generate_hmac_test(param_loader, path, file_names, algorithm): all_params = _load_all_params(path, file_names, param_loader) |