# Question about keyed hash functions

Maybe the answer to my question is obvious, but I have doubt...

I have noticed that hash functions are studied in two forms, keyed hash functions or unkeyed. In general, lecture notes present hash function without key.

Is there a key generation algorithm for a keyed hash function?

• Typically, one would expect a keyed hash function to take an arbitrary (possibly fixed length) binary string as the key; what that function does with the key is going to be awfully specific to the function. Jul 4, 2015 at 16:34
• keyed hash functions...could it be that you're hinting at hmacs, or are you specifically asking about non-HMAC hash functions (which are rarely keyed, unless some individual implementation requires it while excluding/ignoring HMAC for whatever reason)? In the later (non-HMAC) case, the comment by Poncho pretty much wraps things up. Jul 4, 2015 at 17:45
• @poncho Thank you for your comments. I'm referring to non hmac algorithms. In general, for a signature (or encryption) algorithm, there is a key generation function. That's why I wonder if there is such a generation function for hashing. So, is there such a key generation algorithm for a keyed hash function ? Jul 5, 2015 at 18:28
• Public key algorithms (such as signature and public key encryption, which you appear to be referring to) need to generate two keys, which are related (but not in an obvious way; at least, from the public key, you can't easily derive the private key); hence they need a procedure to generate those two keys. Symmetric algorithms (such as a keyed hash) only need one key, and are generally arranged so that an arbitrary bit string works (and hence there is no specific 'key generation' algorithm needed) Jul 5, 2015 at 19:36
• @poncho Note that this is generally the case for symmetric schemes, and in fact, it can even be proven that without loss of generality it can be defined this way (at the cost of efficiency in encryption/decryption since the actual key has to be sampled from scratch each time). However, there are lattice-based symmetric encryption schemes with homomorphic properties. These do have keys that have a specific format... Again, this is the exception though and not the rule. Jul 6, 2015 at 20:11