<s> from cryptography . hazmat . primitives import hashes <EOL> from cryptography . hazmat . primitives . kdf . hkdf import HKDF <EOL> from cryptography . hazmat . backends import default_backend <EOL> backend = default_backend ( ) <EOL> def derive_key ( key_material , info , algorithm = None , length = None ) : <EOL> if algorithm is None : <EOL> algorithm = hashes . SHA512 ( ) <EOL> if length is None : <EOL> length = algorithm . digest_size <EOL> hkdf = HKDF ( algorithm , length , b'<STR_LIT>' , info , backend ) <EOL> return hkdf . derive ( key_material ) </s>
