def concat_sha256(secret, dk_len, other_info):
    """
    The Concat KDF, using SHA256 as the hash function.

    Note: Does not validate that otherInfo meets the requirements of
    SP800-56A.

    :param secret: The shared secret value
    :param dk_len: Length of key to be derived, in bits
    :param other_info: Other info to be incorporated (see SP800-56A)
    :return: The derived key
    """
    dkm = b''
    dk_bytes = int(ceil(dk_len / 8.0))
    counter = 0
    while len(dkm) < dk_bytes:
        counter += 1
        counter_bytes = struct.pack("!I", counter)
        digest = hashes.Hash(hashes.SHA256(), backend=default_backend())
        digest.update(counter_bytes)
        digest.update(secret)
        digest.update(other_info)
        dkm += digest.finalize()
    return dkm[:dk_bytes]
def concat_sha256 ( secret , dk_len , other_info ) : dkm = b'' dk_bytes = int ( ceil ( dk_len / 8.0 ) ) counter = 0 while len ( dkm ) < dk_bytes : counter += 1 counter_bytes = struct . pack ( "!I" , counter ) digest = hashes . Hash ( hashes . SHA256 ( ) , backend = default_backend ( ) ) digest . update ( counter_bytes ) digest . update ( secret ) digest . update ( other_info ) dkm += digest . finalize ( ) return dkm [ : dk_bytes ]
The Concat KDF, using SHA256 as the hash function.

    Note: Does not validate that otherInfo meets the requirements of
    SP800-56A.

    :param secret: The shared secret value
    :param dk_len: Length of key to be derived, in bits
    :param other_info: Other info to be incorporated (see SP800-56A)
    :return: The derived key