how does hkdf generate 2 keys?

Hi I am new to cryptography and am confused as to how HKDF generates two separate keys from one single key/password. Is it as follows?

Key 1: HKDF-Extract(salt, IKM) -> PRK

Key 2: HKDF-Expand(PRK, info, L) -> OKM

OR is it that

Key 1: HKDF-Extract(salt, IKM) -> PRK

Key 2: SHA-512(PRK)

Where Key 2 would be HMAC-key?

Could it be that one key is derived using pb-kdf and hmac-key is derived using hkdf?

The extract and expand steps of HKDF are just two phases of one algorithm run. The PRK created my the extract step is not meant to be used as a key (even though it would not be a problem securitywise).

So if you need to derive two keys from one IKM value, you run the whole algorithm (that is: extract & expand) once with an appropriate info string (like "key1", for instance) and then you run the whole thing a second time with the same salt and IKM but a different info string (like "key2").

OK I think I found my answer. It depends on how you use it. So in my case i am using codeIgnitor library which generates two keys as follows:

Key 1: hkdf(key, 'sha512', NULL, key.length, 'encryption') Key 2: hkdf(key, 'sha512', NULL, NULL, 'authentication')

where Parameters are:

$key (string) – Input key material$digest (string) – A SHA-2 family digest algorithm

$salt (string) – Optional salt$length (int) – Optional output length

\$info (string) – Optional context/application-specific info