Score:1

Why does HMAC use the hash twice?

cn flag

According to the HMAC specification in RFC2104, an HMAC is computed in the following way:

HMAC(K, text) = H(K XOR opad, H(K XOR ipad, text))

where H is the underlying hash function, , is concatenation and K has the length of one block.

Now I wonder, what is the benefit of applying the hash function twice here, that is, why wouldn't it be defined like this:

HMAC'(K, text) = H(K XOR ipad, text)

Are there attacks, that are possible against HMAC', but not against HMAC?

kelalaka avatar
in flag
Does this answer your question? [Why is $H(k\mathbin\Vert x)$ not a secure MAC construction?](https://crypto.stackexchange.com/questions/1070/why-is-hk-mathbin-vert-x-not-a-secure-mac-construction). Note that ipad doesn't provide any any hardness at all in your scheme.
DannyNiu avatar
vu flag
I agree with the linked duplicate. While the question ask different things, the answer and reasoning is applicable in both cases.
kelalaka avatar
in flag
And another highly related one [Why does HMAC use two different keys?](https://crypto.stackexchange.com/q/15734/18298)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.