3
$\begingroup$

This was mentioned in the comments to another question:

To clarify: This is about key-stretching KDFs. Not the kind for diversifying keys (eg. HKDF)

and

There are two kinds of KDF, the slow, strengthening kind fed by a password(e.g. PBKDF2), and a fast one that only derives secondary keys from a master key(e.g. HMAC). The second one obviously shouldn't be used for password hashing.

Now Wikipedia on HKDF seems to think that it is exactly suitable for things like stretching keys:

2./ To "expand" the generated output or an already reasonably random input such as an existing shared key into a larger cryptographically independent output, thereby producing multiple keys deterministicly from that initial shared key, so that the same process may produce those same secret keys safely on multiple devices as long as the same inputs are utilised.

Basically, what I would like to know is where exactly the differences between these two classes of KDFs lie. They both need to produce random looking output and cannot be invertible.

$\endgroup$

1 Answer 1

4
$\begingroup$

Deriving multiple keys from a strong source key material (which is what HKDF is for) is not key stretching.

The important bit from from the Wikipedia excerpt is this one:

2./ To "expand" the generated output or an already reasonably random input such as an existing shared key into a larger cryptographically independent output, thereby producing multiple keys deterministicly from that initial shared key, so that the same process may produce those same secret keys safely on multiple devices as long as the same inputs are utilised.

As CodesInChaos' comment on the original post you referenced states, there the two types are "fast" and "slow".

Fast KDFs are designed to securely derive multiple keys from source key material that is already strong, with high entropy. HKDF is one of these.

Key-streching or password-stretching is a term used to indicate the the source key material is weak, or low entropy, and a slow KDF needs to be used to create a key while simultaneously protecting (as best it can) the low entropy source material. PBKDF2 is one of these.

If you attempt to use a fast KDF (like HKDF) with low entropy source material like a password, you create similar problems to those you have with using fast hash functions to protect passwords for authentication. Because passwords are predictable, the ultimate set of hashes (or keys) that will be created from will be much smaller than the full keyspace. A fast KDF would let an attacker test far too many candidates far too quickly, making it much more likely that the correct key will be discovered, and so is not in fact suitable for key-stretching.

$\endgroup$
2
  • $\begingroup$ I think it would be clearer to just say it's fast vs slow. The remarks about entropy seem fishy to me. As long as the KDF is .deterministic I don't think the entropy can increase. It just takes longer to guess. Am I wrong? $\endgroup$
    – Elias
    Oct 25, 2016 at 15:26
  • $\begingroup$ @Elias No, you're right. The appearance of the final key material should be more uniformly random, but since entropy is a product of the generation process, there will be no more entropy when using a deterministic KDF as you point out. I've updated my answer. $\endgroup$
    – Xander
    Oct 25, 2016 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.