How to use HMAC for authenticating multiple messages The standard HMAC function, $H(K, m)$, authenticates a single message $m$.

Instead, I'd like to authenticate 2 messages, like this: $$H'(K, m_1, m_2)$$

The simplest solution, $H(K, m_1||m_2)$, confuses e.g. "ab"+"cd" or "abc"+"d" as messages.

Would this be secure instead: $H(H(K, m_1), m_2)$?
If the hashing function $H$ is secure, then $H(H(K, m_1), m_2)$ is secure. But at the cost of applying $H$ twice.