# HMAC of message hash

If I have a message m and want its HMAC, I can simply do HMAC(k, m). But sometimes I am not given m but the hash of m: H(m). If I do HMAC(k, H(m)) instead of HMAC(k, m), does this make it more or less secure?

HMAC hashes m when it is longer than block size. So I guess this question is only meaningful when m is equal or shorter than block size.

We can assume the hash function on m is the same one used in HMAC.

For instance, if you'd use MD5 for the HMAC then you'd still be secure, as HMAC(k, m) doesn't rely on collision resistance of the underlying hash function. However HMAC(k, MD5(m)) certainly does rely on it. So this latter scheme would be considered broken: an attacker can come up with m and m' that would be verified by the same HMAC if H(m) = H(m') after all.
I don't see how length extension attacks would apply to HMAC(k, H(m)). The key is not used in the hash calculation over the message, after all.