git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Hash algorithm analysis

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Sep 18, 2018, 16:50 UTC
Message-ID
<CA+55aFyYyh0EYSotDYMv+mk+QbRghQnn3MK7oRn=131VDm=HfQ@mail.gmail.com>
In-Reply-To
<64c1fc82-8830-bd62-7cc6-ef76ad06f6d5@noekeon.org>
On Tue, Sep 18, 2018 at 8:18 AM Joan Daemen <jda@noekeon.org> wrote:
>
> 3) The relatively large state in the sponge construction increases the generic strength against attacks when the input contains redundancy or
> has a certain form. For instance, if the input is restricted to be text in ASCII (such as source code), then the collision-resistance grows
> higher than the nominal 2^{c/2}. Such an effect does not exist with narrow-pipe Merkle-Damgård. (This may be what Linus had intuitively in mind.)
Answering to just this part:

No, what I had in mind was literally just exactly the kind of attack that SHA1 broke for - attacking the internal state vector directly, and not paying any penalty for it, because the stat size is the same as the final hash size.

The length extension attack is just the simplest and most trivial version of that kind of attack - because the internal state vector *is* the result, and you just continue using it.

But that trivial length extension thing not the real problem, it's just the absolutely simplest symptom of the real problem.

I think that the model where the internal state of the hash is the same width as the final result is simply broken. It was what broke SHA1, and that problem is shared with SHA2.

"Length extension" is just the simplest way to say "broken by design", imho.

Because the length extension attack is just the most trivial attack, but it isn't the fundamental problem. It was just the first and the cheapest attack found, but it was also the most special-cased and least interesting. You need to have a very special case (with that secret at the beginning etc) to make the pure length extension attack interesting. And git has no secrets, so in that sense "length extension" by itself is totally immaterial. But the basic problem of internal hash size obviously wasn't.

So I would say that length extension is a direct result of the _real_ problem, which is that the hash exposes _all_ of the internal data.

That is what makes length extension possible - because you can just continue from a known state, and there is absolutely nothing hidden - and yes, that's a really easy special case where you don't even need to actually break the hash at all.

But I argue that it's _also_ one big part of what made SHAttered practical, and I think the underlying problem is exactly the same. When the internal state is the same size as the hash, you can attack the internal state itself for basically the same cost as attacking the whole hash.

So you can pick-and-choose the weakest point.

Which is basically exactly what SHAttered did. No, it wasn't the trivial "just add to the end", but it used the exact same underlying weakness as one part of the attack.

*This* is why I dislike SHA2. It has basically the exact same basic weakness that we already know SHA1 fell for. The hashing details are different, and hopefully that means that there aren't the same kind of patterns that can be generated to do the "attack the internal hash state" part, but I don't understand why people seem to ignore that other fundamental issue.

Something like SHA-512/256 would have been better, but I think almost nobody does that in hardware, which was one of the big advantages of plain SHA2.

The main reason I think SHA2 is acceptable is simply that 256 bits is a lot. So even if somebody comes up with a shortcut that weakens it by tens of bits, nobody really cares. Plus I'm obviously not a cryptographer, so I didn't feel like I was going to fight it a lot.

But yes, I'd have probably gone with any of the other alternatives, because I think it's a bit silly that we're switching hashes to another hash that has (at least in part) the *exact* same issue as the one people call broken.

(And yes, the hashing details are different, so it's "exactly the same" only wrt that internal state part - not the bitpattern finding part that made the attack on the internal state much cheaper. Real cryptographers obviously found that "figure out the weakness of the hashing" to be the more interesting and novel part over the trivial internal hash size part).

That said..

The real reason I think SHA2 is the right choice was simply that there needs to be a decision, and none of the choices were *wrong*. Sometimes just the _act_ of making a decision is more important than _what_ the decision is.

And hey, it is also likely that the reason _I_ get hung up on just the size of the internal state is that exactly because I am _not_ a cryptographer, that kind of high-level stuff is the part I understand. When you start talking about why the exact rules of Merkle–Damgård constructions work, my eyes just glaze over.

So I'm probably - no, certainly - myopic and looking at only one part of the issue to begin with.

The end result is that I argued for more bits in the internal state (and apparently wide vs narrow is the technical term), and I would have seen parallel algorithms as a bonus for the large-file case. None of which argued for SHA2.

But see above on why I think SHA2 is if not *the* right choice, at least *a* right choice.

                    Linus
Previous: Jonathan NiederNext: Ævar Arnfjörð Bjarmason
Message 43 of 66 in “State of NewHash work, future directions, and discussion”
  1. brian m. carlsonJun 9, 2018
  2. Ævar Arnfjörð BjarmasonJun 9, 2018
  3. Hash algorithm analysisbrian m. carlson, Jun 9, 2018
  4. Jonathan NiederJun 11, 2018
  5. Linus TorvaldsJun 11, 2018
  6. Ævar Arnfjörð BjarmasonJun 11, 2018
  7. David LangJun 12, 2018
  8. Linus TorvaldsJun 12, 2018
  9. brian m. carlsonJun 11, 2018
  10. Gilles Van AsscheJun 12, 2018
  11. brian m. carlsonJun 13, 2018
  12. Gilles Van AsscheJun 15, 2018
  13. brian m. carlsonJul 20, 2018
  14. Jonathan NiederJul 21, 2018
  15. Ævar Arnfjörð BjarmasonJul 21, 2018
  16. brian m. carlsonJul 21, 2018
  17. Johannes SchindelinJul 21, 2018
  18. Linus TorvaldsJul 21, 2018
  19. brian m. carlsonJul 21, 2018
  20. Eric DeplagneJul 22, 2018
  21. brian m. carlsonJul 22, 2018
  22. Eric DeplagneJul 22, 2018
  23. Johannes SchindelinJul 26, 2018
  24. Joan DaemenJul 22, 2018
  25. Adam LangleyJul 22, 2018
  26. Johannes SchindelinJul 26, 2018
  27. demerphqJul 23, 2018
  28. Sitaram ChamartyJul 23, 2018
  29. demerphqJul 23, 2018
  30. Linus TorvaldsJul 23, 2018
  31. Stefan BellerJul 23, 2018
  32. Jonathan NiederJul 23, 2018
  33. Edward ThomsonJul 24, 2018
  34. Linus TorvaldsJul 24, 2018
  35. Jonathan NiederJul 24, 2018
  36. Junio C HamanoJul 24, 2018
  37. brian m. carlsonJul 24, 2018
  38. Johannes SchindelinJul 30, 2018
  39. Dan ShumowJul 30, 2018
  40. Jonathan NiederAug 3, 2018
  41. Joan DaemenSep 18, 2018
  42. Jonathan NiederSep 18, 2018
  43. Linus TorvaldsSep 18, 2018
  44. 0/2 document that NewHash is now SHA-256Ævar Arnfjörð Bjarmason, Jul 25, 2018
  45. 1/2 doc hash-function-transition: note the lack of a changelogÆvar Arnfjörð Bjarmason, Jul 25, 2018
  46. 2/2 doc hash-function-transition: pick SHA-256 as NewHashÆvar Arnfjörð Bjarmason, Jul 25, 2018
  47. Junio C HamanoJul 25, 2018
  48. Jonathan NiederJul 25, 2018
  49. Junio C HamanoJul 25, 2018
  50. 2/2 doc hash-function-transition: pick SHA-256 as NewHashÆvar Arnfjörð Bjarmason, Jul 26, 2018
  51. Jonathan NiederAug 3, 2018
  52. Junio C HamanoAug 3, 2018
  53. Linus TorvaldsAug 3, 2018
  54. Linus TorvaldsAug 3, 2018
  55. Ævar Arnfjörð BjarmasonAug 3, 2018
  56. Jonathan NiederAug 4, 2018
  57. brian m. carlsonAug 3, 2018
  58. brian m. carlsonJul 25, 2018
  59. Ævar Arnfjörð BjarmasonJun 11, 2018
  60. Johannes SchindelinJun 21, 2018
  61. brian m. carlsonJun 21, 2018
  62. Duy NguyenJun 11, 2018
  63. brian m. carlsonJun 12, 2018
  64. Jonathan NiederJun 11, 2018
  65. brian m. carlsonJun 12, 2018
  66. Jonathan NiederJun 12, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.