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 binascii 8 9from cryptography.hazmat.backends import default_backend 10from cryptography.hazmat.primitives import hashes 11from cryptography.hazmat.primitives.kdf.hkdf import HKDF 12 13IKM = binascii.unhexlify(b"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b") 14L = 1200 15OKM = HKDF( 16 algorithm=hashes.SHA256(), length=L, salt=None, info=None, 17 backend=default_backend() 18).derive(IKM) 19 20 21def _build_vectors(): 22 output = [] 23 output.append("COUNT = 0") 24 output.append("Hash = SHA-256") 25 output.append("IKM = " + binascii.hexlify(IKM).decode("ascii")) 26 output.append("salt = ") 27 output.append("info = ") 28 output.append("L = {}".format(L)) 29 output.append("OKM = " + binascii.hexlify(OKM).decode("ascii")) 30 return "\n".join(output) 31 32 33def _write_file(data, filename): 34 with open(filename, 'w') as f: 35 f.write(data) 36 37 38if __name__ == '__main__': 39 _write_file(_build_vectors(), 'hkdf.txt') 40