3 ms·
> SHA-2, SHA-3, BLAKE2b, Skein, Whirlpool, etc.: We don't have any collisions for these, so it doesn't get any better than that. There are important difference
by espadrine 7y ago
> SHA-2, SHA-3, BLAKE2b, Skein, Whirlpool, etc.: We don't have any collisions for these, so it doesn't get any better than that.
There are important differences; some of those primitives are definitely more trustworthy than others.
SHA-2 and Whirlpool use the old Merkle–Damgård construction, which has fallen out of favor because of unfortunate properties.
They are vulnerable to length extension attacks, such that it can be misused. For instance, if you want to use it as a keyed hash, you cannot just do sha2(key + message) (where + is concatenation). You have to use something like HMAC for that.
Skein is much better, but has a bit of an aged design now, and an insane 72 rounds. It doesn’t have as much love as BLAKE2 for instance, which makes it unlikely that people will build things competitive with BLAKE3 with it.
SHA-3, BLAKE2b and BLAKE3 are the best. Like Skein, they are not vulnerable to length extension attacks, so they have a trivial keyed hash function construction.
SHA-3 in particular has an elegant new design, the Sponge construction, which yields precise cryptographic protections in terms of the number of bits of security. It has displaced Merkle–Damgård as The Way We Do Things™ now; many modern hashes use it, eg Gimli relied on it to make comparisons.
One of the great things about this form is that it makes it a XOF: you can make your hash as long as you desire. (BLAKE also shares this property, but with a different construction.)
However, SHA-3 is slow, so if you want speed, use BLAKE2b (or Kangaroo12) over SHA-3, and BLAKE3 over them both.
If you want to be conservative about security and don't care about speed, a safe bet is still SHA-512/256, which is safe against length extension attacks.
- lucb1e 7y agoThat was informative, thanks! It matched my gut feeling about the algorithms and I knew some of these things, but not everything :) > a safe bet is still SHA-512/256, which is safe against length extension attacks. I would like to add here that this does not mean "SHA-512 or SHA-256" (I remembered that SHA-256 was not length-extension resistant and looked up the details). Instead, it means the version of SHA-512 that gets truncated to 256 bits. This is apparently relatively new (or at least added after I last read up on SHA-2): > In March 2012, the standard was updated in FIPS PUB 180-4, adding the hash functions SHA-512/224 and SHA-512/256, and describing a method for generating initial values for truncated versions of SHA-512. -- https://en.wikipedia.org/wiki/SHA-2#Hash_standard https://en.wikipedia.org/wiki/SHA-2#Hash_standard I feel like that notation could have been chosen better by NIST.
- nayuki 7y agoThe hash function "SHA-512/256" has different initial constants than "SHA-512", so it is not equivalent to truncating a "SHA-512" hash value. SHA-224 and SHA-384 are somewhat resistant to length-extension attacks because they output a truncated state. Yeah, the slash in the names are an unfortunate choice that hurts clarity.
- deleted 7y ago[deleted]