def HKDF_expand(PRK, info, L, hashmod=hashlib.sha256):
    """HKDF-Expand; see RFC-5869 for the details."""
    if isinstance(info, text_type):
        info = info.encode("utf-8")
    digest_size = hashmod().digest_size
    N = int(math.ceil(L * 1.0 / digest_size))
    assert N <= 255
    T = b""
    output = []
    for i in xrange(1, N + 1):
        data = T + info + chr(i).encode("utf-8")
        T = python_hmac.new(PRK, data, hashmod).digest()
        output.append(T)
    return b"".join(output)[:L]
dataset/ETHPy150Open spiral-project/daybed/daybed/tokens.py/HKDF_expand/original