Lifetimes of cryptographic hash functions
valerieaurora.org
valerieaurora.org
This would be if one cares about how violently you fall if SHA-2 is broken more, but I think you should care.
---
SHA-{1,2} are vulnerable to length extension attacks, because of the way their Merkle-Damgard construction works. Basically, if you have the result HASH(X), you can calculate HASH(X+P), knowing only 'HASH(X)', without knowing 'X' itself. This is problematic because it means you can effectively "extend" some cryptographically hashed data with an arbitrary suffix.
You can immunize SHA-2 in one of two ways to a length extension attack:
- Truncate the hash value. For example, use SHA-512, but truncate the result to 256 bits (this is called "SHA-512/256"). This works because the output of your HASH function which is 256-bits, cannot be reused as the initial starting state for a new round of HASH (e.g. SHA-512 needs a 512-bit starting value, but the output is only 256, so this makes it impossible)
- Although it is not standard SHA-2 anymore, you can use a trick from Neils Ferguson and John Kelsey (from 2001!) to immunize it -- simply XOR a constant into the final block round before running the final compression function. Unfortunately this suggestion was not adopted for SHA-2: http://www.cs.utsa.edu/~wagner/CS4363/SHS/dfips-180-2-commen...
Alternatively just use a modern hash design like BLAKE2, SHA-3, or a number of others -- these avoid the entire problem. I'd suggest just sticking to one of those two.
If I had to rank those three hash functions, SHA-2 wouldn't be in last place.
Another way to look at it is, not needing HMAC is a feature of SHA-3.
In any case: SHA-2 --- in any of its variants --- remains strong. JP Aumasson, one of the Blake2 designers, is fond of saying that SHA-2 will probably never be broken algorithmically.
[1]: Assuming you're running on a 64-bit platform...
I almost wish SHA-3 had been a dual pick between a fast software hash and a fast hardware hash. As it stands, Keccak being so slow in software is majorly limiting IMO. The more interesting aspect of SHA-3 is the sponge, so you can really turn Keccak into an entire swiss-army knife of crypto tools, if you know what you're doing.
But as it stands, if I have to pick a modern hash, I almost always pick BLAKE2 instead of SHA-3, primarily because I rarely need the sponge design and also because it's dramatically faster in software. Stuff like this is really important on my Cortex-M4...
I'd argue that for 99% of all users of cryptographic software, the difference in speed between SHA-2 and SHA-3 is irrelevant.
BLAKE2 is a fine hash too :]
You can concatenate hash functions, so you get at least the best security from both. But the question is: Why would you want to do any such thing? Just choose one of them. Both are safe.
I'm also not clear on what the chart claims is going on with RIPEMD-160.
There's no excuse for staying with SHA1 at this point.
[3] Google spent 6500 CPU years and 110 GPU years to convince everyone we need to stop using SHA-1 for security critical applications
I still see things that use 2-digit years, twenty years after the last millennium bug should have been fixed.
> Explain why a simple collision attack is still useless, it's really the second pre-image attack that counts
Why is this the "non-expert reaction?" It's correct, right?
And why go to the trouble of making a timeline with "Broken" and "Collision found" without a "Second pre-image found"?
I'm genuinely puzzled (and have asked it here on HN before [1]), but I unfortunately suspect that an honest answer lies somewhere along these lines: "Second pre-images are a hell of lot more difficult to find than collisions, so if we waited around for a second pre-image to be found we'd never get to dance around like headless chickens and talk about really scary shit (which typically requires a second pre-image) as 'now practical'. That would make the whole field a lot less sexy, and cut into our 'expert' consulting fees..."
1. https://news.ycombinator.com/item?id=13729492
EDIT: I'm of course not advocating staying with SHA-1. There's absolutely no good reason to. Even years ago when I was last involved in choosing a cryptographic hash function (even truncated) SHA-256 was obviously a much better choice.
People who understand things well enough will know what first collision means, so can moderate their response.
Others who are less familiar with the ridiculous levels of subtlety around this sort of thing are better off being given the simple message that sha1 is now legacy in all cases. Helps to avoid mistakes.
I'm more surprised though at the resentful attitude towards the actual truth (in the non-alternative sense): collisions are useless in many cases and the necessary second pre-image is much more difficult to find.
At least in a forum like HN I'd expect intellectual honesty to prevail.
EDIT: Removed the incorrect example out of pure shame! :P
I of course agree we should replace SHA-1. But I still think a more intellectually honest discussion is meaningful. For example, after reading the link you referred to I'm rather convinced that X.509 is pretty seriously flawed, and could easily be redesigned to be collision resistant. Why not talk about that? Why not do it?
Doing x509 still means having to parse ASN.1 though, and nobody seems to actually like it.
https://z.cash/technology/history-of-hash-function-attacks.h...
Specifically the section 'When collision attacks do matter' and the referenced write-up at
But isn't the real lesson here that X.509 is flawed?
Also, as the linked article says:
> The bottom line is that no widely-studied hash function has ever succumbed to a (second-)pre-image attack except for one.
And there are signatures that are provably resistant to collisions, shouldn't we move to such signatures?
I don't think that's the case
And there are signatures that are provably resistant to collisions, shouldn't we move to such signatures?
It's just much simpler to move to a better hash function.
I don't see how one excludes the other. :P
Isn't it rather obvious that no third party can attack this system even if they can create an SHA-256 collision?
Sure, you can dream up some weird scenario where someone could set up two servers with different RSA public keys that would hash to the same value, so that the client could be fooled into connecting to one when it thought it was connected to the other. But to me it seems quite obvious that that's outside the treat model / irrelevant.
Especially in situations where you don't trust what's giving you the hash (e.g. because you haven't authenticated them yet, or because the application inherently means you can't trust them even if you have authenticated them) then collision resistance most likely necessary.
Sure, there is broken, and then even-more broken, but SHA-1 is already, for most practical purposes, useless.