1# This file is dual licensed under the terms of the Apache License, Version 2# 2.0, and the BSD License. See the LICENSE file in the root of this repository 3# for complete details. 4 5from __future__ import absolute_import, division, print_function 6 7import os 8 9import pytest 10 11from cryptography.hazmat.backends.interfaces import HMACBackend 12from cryptography.hazmat.primitives import hashes 13 14from .utils import generate_hkdf_test 15from ...utils import load_nist_vectors 16 17 18@pytest.mark.supported( 19 only_if=lambda backend: backend.hmac_supported(hashes.SHA1()), 20 skip_message="Does not support SHA1." 21) 22@pytest.mark.requires_backend_interface(interface=HMACBackend) 23class TestHKDFSHA1(object): 24 test_HKDFSHA1 = generate_hkdf_test( 25 load_nist_vectors, 26 os.path.join("KDF"), 27 ["rfc-5869-HKDF-SHA1.txt"], 28 hashes.SHA1() 29 ) 30 31 32@pytest.mark.supported( 33 only_if=lambda backend: backend.hmac_supported(hashes.SHA256()), 34 skip_message="Does not support SHA256." 35) 36@pytest.mark.requires_backend_interface(interface=HMACBackend) 37class TestHKDFSHA256(object): 38 test_HKDFSHA1 = generate_hkdf_test( 39 load_nist_vectors, 40 os.path.join("KDF"), 41 ["rfc-5869-HKDF-SHA256.txt"], 42 hashes.SHA256() 43 ) 44