Hot answers tagged length-extension
13
SHA-1 processes data by 512-bit blocks (64 bytes). For a given input message m, it first appends some bits (at least 65, at most 576) so that the total length is a multiple of 512. Let's call p the added bits (that's the padding). The padding bits depend only on the length of m (these bits include an encoding of that length, but they do not depend on the ...
7
You're missing the most important strength of HMAC: it comes with a proof of security (under some plausible assumptions). The outer key plays an important role in the proofs. The best place to learn more is to read the HMAC papers:
Message authentication using hash functions: The HMAC construction, Mihir Bellare, Ran Canetti, Hugo Kawczyk, CryptoBytes ...
4
As a Skein co-author, one of the properties of the UBI chaining mode is to give you HMAC-like properties in one pass. Skein itself consists of the Threefish tweakable block cipher, the UBI chaining mode, and some proofs that extend tweakable block cipher theory into a tweakable hash function theory that reduces the security of the hash function to the ...
3
The key to understanding hash extension attacks is to understand that the hash output isn't just the output of the machine generating the hash, it's also the state of the machine up till that point. In other words, just the hash output alone contains enough information for you to keep going and append more content to the hashed input.
The catch is that ...
3
How does the length extension attack against $H(k||m)$ work?
For Merkle-Damgård hashes, if you know $H(x)$ but not $x$ you can still choose an $e$ and then compute $H(x||p||e)$. With $x=k||m$ you can compute $H((k||m||p)||e)=H(k||(m||p||e))$ which is a valid authentication tag for $m||p||e$.
Why doesn't it work against $H(m||k)$?
With a length extension ...
2
I'm putting another answer in because as good as D.W.'s answer is (I up-voted it), it doesn't really answer your question.
You said:
But the simple construction Hash(Hash(key|message)) would offer those properties too.
But the construction you gave -- Hash(Hash(key|message)) -- has a weakness that HMAC does not.
One of those properties was ...
1
First of all, let us explore what a "length extension attack" is; it might not be exactly what you assumed it was.
Suppose we were given the MD5 hash of a bytestring we'll call $A$; we may have no idea what the string $A$ consists of, but we do know its length.
Then, we can create a bytestring $B$ (which depends on the length of $A$, but not any of its ...
Only top voted, non community-wiki answers of a minimum length are eligible