hkdf Algorithm

the first phase takes the input keying material and" extracts" from it a fixed-length pseudorandom key, and then the second phase" expands" this key into several additional pseudorandom keys (the output of the KDF).It can be used, for example, to convert shared secrets exchanged via Diffie – Hellman into key material suitable for purpose in encryption, integrity checking or authentication. It was initially proposed by its writers as a building block in various protocols and applications, as well as to discourage the proliferation of multiple KDF mechanisms.

hkdf source code, pseudocode and analysis