diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hazmat/primitives/test_hkdf_vectors.py | 6 | ||||
-rw-r--r-- | tests/hazmat/primitives/utils.py | 30 |
2 files changed, 15 insertions, 21 deletions
diff --git a/tests/hazmat/primitives/test_hkdf_vectors.py b/tests/hazmat/primitives/test_hkdf_vectors.py index d2ac79a8..5af4c14e 100644 --- a/tests/hazmat/primitives/test_hkdf_vectors.py +++ b/tests/hazmat/primitives/test_hkdf_vectors.py @@ -20,7 +20,7 @@ import pytest from cryptography.hazmat.primitives import hashes from .utils import generate_hkdf_test -from ...utils import load_hkdf_vectors +from ...utils import load_nist_vectors @pytest.mark.supported( @@ -30,7 +30,7 @@ from ...utils import load_hkdf_vectors @pytest.mark.hash class TestHKDFSHA1(object): test_HKDFSHA1 = generate_hkdf_test( - load_hkdf_vectors, + load_nist_vectors, os.path.join("KDF"), ["rfc-5869-HKDF-SHA1.txt"], hashes.SHA1() @@ -44,7 +44,7 @@ class TestHKDFSHA1(object): @pytest.mark.hash class TestHKDFSHA256(object): test_HKDFSHA1 = generate_hkdf_test( - load_hkdf_vectors, + load_nist_vectors, os.path.join("KDF"), ["rfc-5869-HKDF-SHA256.txt"], hashes.SHA256() diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py index 963838eb..9e9088a3 100644 --- a/tests/hazmat/primitives/utils.py +++ b/tests/hazmat/primitives/utils.py @@ -306,45 +306,39 @@ def aead_tag_exception_test(backend, cipher_factory, mode_factory): def hkdf_derive_test(backend, algorithm, params): - ikm, salt, info, length, prk, expected_okm = params - okm = hkdf_derive( - binascii.unhexlify(ikm), - length, - binascii.unhexlify(salt), - binascii.unhexlify(info), + binascii.unhexlify(params["ikm"]), + int(params["l"]), + binascii.unhexlify(params["salt"]), + binascii.unhexlify(params["info"]), algorithm, backend=backend ) - assert binascii.hexlify(okm) == expected_okm + assert okm == binascii.unhexlify(params["okm"]) def hkdf_extract_test(backend, algorithm, params): - ikm, salt, info, length, expected_prk, okm = params - prk = hkdf_extract( algorithm, - binascii.unhexlify(ikm), - binascii.unhexlify(salt), + binascii.unhexlify(params["ikm"]), + binascii.unhexlify(params["salt"]), backend=backend ) - assert prk == binascii.unhexlify(expected_prk) + assert prk == binascii.unhexlify(params["prk"]) def hkdf_expand_test(backend, algorithm, params): - ikm, salt, info, length, prk, expected_okm = params - okm = hkdf_expand( algorithm, - binascii.unhexlify(prk), - binascii.unhexlify(info), - length, + binascii.unhexlify(params["prk"]), + binascii.unhexlify(params["info"]), + int(params["l"]), backend=backend ) - assert okm == binascii.unhexlify(expected_okm) + assert okm == binascii.unhexlify(params["okm"]) def generate_hkdf_test(param_loader, path, file_names, algorithm): |