News for hackers. Stuff that matters.
Re:Linus on Git and SHA-1 by infinity0 on Saturday February 25, 2017 @05:58PM (#13734386)
> "A hash that is used for security is basically a statement of trust [..] In contrast, in a project like git, the hash isn't used for "trust". I don't pull on peoples trees because they have a hash of a4d442663580. Our trust is in people, and then we end up having lots of technology measures in place to secure the actual data."

This is horseshit, and Linus should not be saying these hugely misleading statements about security principles.

The point of a hash is to remove the need for trust between the trusted person who tells you the hash and the infrastructure you get the actual data that was hashed, from (edit: and, between you and the latter).

In other words, once you get a good non-colliding hash from a trusted person, then you don't need to worry about malicious infrastructure sending you bad data claiming to be the source of that hash.

Linus trusting Tytso to sign the commit object that references the SHA-1 of the tree object, says nothing about whether the infrastructure served him the tree object correctly. Sure, he might also trust the infrastructure providers, but when he says "trusts people" it does not sound like that is what he means. And even if he trusts the infrastructure providers, with a good hash HE DOESN'T HAVE TO.

The "trust" wording is serious horseshit.

(edit: there is also the case of people downloading "linux" from random git repos in the future. Right now if you GPG-sign a commit or tag, it has SHA-1 references to the tree object underneath it. Once SHA-1 is more broken it basically means you shouldn't trust random git repos across the internet to give you good content, even if it's "signed by Linus".)

Re:Linus on Git and SHA-1 by ploxiln on Saturday February 25, 2017 @09:33PM (#13735305)
You're saying Linus's statements are "hugely misleading", but it's just that you wish git were designed to be used differently. So, your argument is "horseshit".

Linus could have designed a cryptographically perfect system such that he could pull Tytso's signed commit from anywhere on the internet - but he didn't

Linus used sha1 as a useful tool for an effective DVCS with an initially simple implementation.

He still depends on the security of the kernel.org servers, his work computers, and the top submaintainer's work computers. His git trees and all the submaintainers he pulls from are hosted on kernel.org servers. Security of the kernel.org servers is taken very seriously, especially since the well-known break-in a few years ago. Now even two-factor auth is involved in all git pushes to kernel.org servers. Sub-maintainers make pull-requests by branch name - "please pull branch for-linus ...". More peripheral contributors submit their work via patches on LKML, no commit hashes involved.

Finally, no well-known SCM previous to git was based on perfect cryptographic proof of source history, or anything like that. It wasn't a big issue, and it's not the problem git focused on solving. Before git, we all used CVS, SVN, tarballs, and patches. And a significant portion of developers did not use any VCS at all. How could any of us have trusted any source code before 2005?! Somehow we did, though...

Re:Linus on Git and SHA-1 by paulddraper on Saturday February 25, 2017 @09:48PM (#13735353)
> Before git, we all used CVS, SVN, tarballs, and patches

Yeah, and that sucked.

Git is this close (I'm holding my fingers very close together) from providing cryptographic proof of source history. And that's why people think it should be included.

Re:Linus on Git and SHA-1 by kpcyrd on Sunday February 26, 2017 @12:47AM (#13735880)
> How could any of us have trusted any source code before 2005?! Somehow we did, though...

They used pgp to sign the tar ball, which was a way better idea since you could just use a different hash function for your signature after sha1 has been broken in 2005[1].

Everybody serious about security kept doing that, since signed git commits were just asking for trouble due to the hard dependency on sha1.

[1]: https://www.schneier.com/blog/archives/2005/02/sha1_broken.h...

Re:Linus on Git and SHA-1 by DannyBee on Sunday February 26, 2017 @01:16AM (#13735957)
"Finally, no well-known SCM previous to git was based on perfect cryptographic proof of source history, or anything like that."

This is actually false. Monotone, from which git takes a lot of cues (ask linus, or see wikipedia), was such a system.

Re:Linus on Git and SHA-1 by ploxiln on Sunday February 26, 2017 @12:06PM (#13738250)
Thus my qualification "well known". I was aware of monotone and Darcs ... but never used them, or knew anyone who did, or anyone who seriously considered it. I have no idea if Darcs is "cryptographically secure". But both of these were experimental and extremely slow at the time git was designed.
Re:Linus on Git and SHA-1 by DannyBee on Sunday February 26, 2017 @12:35PM (#13738444)
"Thus my qualification "well known"." So that, to you, means "i don't know anyone who used them"?

Because that's a pretty small definition of "well known". For reference:

Inside the VCS community, they were very well known. Graydon also went on to start Rust, of course. Outside of that, even to corporations I dealt with (i was working on SVN at the time), plenty knew it existed, a few evaluated it.

" But both of these were experimental and extremely slow at the time git was designed."

I feel like this is just you trying to say "well, they never would have worked anyway".

DARCS was slow and couldn't be fixed, monotone was actually not that bad, and could be made very fast if necessary.

Monotone was slow precisely because it cared about integrity. If you made git care about integrity and security in the same way ... it would be just as slow!

Saying they were "experimental" is silly. Monotone was self hosting and nobody had found data corruption or other issues in quite a while (IE > 1 year), AFAIK. This is much better than git was for a long time. To put this in perspective, i converted the gcc repository (hundreds of thousands of revisions, in fact, many more than the kernel at the time, and history going back to 1983) to monotone, and 1. the conversion worked with no issues 2. Speed was fine in most cases. If i worked hard, i could find issues, but ....

git was beyond experimental at the time it was designed (IE data loss and repeated crashes). But it's design is essentially that of monotone in a different container and with slightly different goals. (IE they precisely gave up the integrity part that monotone verified and cared about, and people are now complaining about).

In truth, if Linus had cared about cryptographic security, he probably would have just stuck with monotone and rewritten parts of it. But he didn't, so he gave that up in the name of speed.

Which is fine, but let's not pretend that Linus somehow has a monopoly on design, or even was the first to design a VCS that was like git.

Any of the distributed VCSen could have beaten git. They just didn't care about the tradeoffs that git was making (IE non-portability in favor of speed), and honestly, it's pretty obvious git would have been laughed out of existence if it hadn't been supported by someone so popular to so many people.

In fact, it was laughed out of existence, the past N times people had devised VCSen that favored speed over portability.

Git is interesting as an example of how good marketing with the right figures sometimes leads to winning in the marketplace for long enough that you can fix the rest of your serious issues (IE everyone else had the OS/2 problem). Even more interesting is that everyone else backfills history to make it seem like it was the best and clearly the right set of tradeoffs from the start. It wasn't. It may not even be now! It's like any other system. Please don't try to backfill history here. I was there, as were many others.

Re:Linus on Git and SHA-1 by ploxiln on Sunday February 26, 2017 @04:59PM (#13740198)
I didn't claim that Linus came up with the design from scratch, nor that git was less experimental than monotone in 2005. Just that no one used monotone, so git was not a reduction in safety/assurance compared to any in-use SCM. And as mentioned, it's goal was speed, not cryptographic assurance.

I also was surprised that git became so popular, I thought mercurial would win for "ease of use". But I've never been an advocate or influencer of popularity. I think that's mostly due to GitHub, which got it to a market-share tipping point.

Re:Linus on Git and SHA-1 by coldtea on Monday February 27, 2017 @04:47PM (#13748546)
>Inside the VCS community, they were very well known.

Inside the PL community, tons of obscure language with less than 10.000 users are "well known". Being known inside some niche's expert's a pretty low bar. The "VCS" community is insignificant in size compared to the developer community at large.

>Graydon also went on to start Rust, of course.

Which is irrelevant as to whether Darcs and Monotone are well known.

Re:Linus on Git and SHA-1 by yuhong on Sunday February 26, 2017 @02:05PM (#13739058)
Of note is that Monotone also used SHA-1 but it was released in 2003.
Re:Linus on Git and SHA-1 by infinity0 on Saturday February 25, 2017 @09:51PM (#13735368)
Why go through all the effort of securing kernel.org etc etc etc when a simple s/SHA1/SHA512/g on git would suffice? (Ignoring the non-git infrastructure there, for the purposes of this argument.) Not just for him, but for everyone in the world who can't download directly from kernel.org?

What's the point of GPG signing tags and commits and adding these as git features, when SHA1 pointers make it pointless?

If the cryptographic strength of the hash doesn't matter, why bother even talking about changing the hash from SHA1 to SHA3-256?

It's a huge shame because git is very close to being a cryptographically perfect system, but the original creator can't get his security reasoning correct, and does so so badly yet so publicly, and minions who don't know what they're talking about come flocking to defend this.

Re:Linus on Git and SHA-1 by kupiakos on Saturday February 25, 2017 @10:34PM (#13735507)
> when a simple s/SHA1/SHA512/g on git would suffice?

That's ignoring a huge amount of changes that have to be made to have this work properly. Hardcoded constants must be changed. Backwards compatibility needs to be maintained for Git to be a viable product. Scripts that depend on the current length/format of SHA1 hashes would be broken if everything were changed all of a sudden. That would be much, much worse than the current exploit.

I agree that his points are not all correct, but he is correct in that basically, you shouldn't have all of your security eggs in one basket. SHA1 is just one piece of their security infrastructure, and now that it's shown to be a little shaky, it can be argued that the others help keep it up while they repair it.

SHA1 pointers being "pointless" is also an overstatement. SHA1 isn't completely broken yet. It will be pointless in 3+ years, which is why they're performing the work of transitioning, although not easy. "Cryptographically perfect" wouldn't be occurring with SHA3-256 either. That'll be broken in 10+ years.

Security is, and always has been, along the lines of "good enough as far as we can see now", and when Git was made, it was good enough. Now it's not.

Re:Linus on Git and SHA-1 by infinity0 on Sunday February 26, 2017 @03:01AM (#13736205)
All git repos have "repositoryversionformat", you can bump it. And nobody is going to complain about having to do a fresh clone, given what just happened.

"Not having security eggs in one basket" is exactly irrelevant here. Upgrading the hash does not make the other parts of the system weaker, and should have been done years ago. Yes, SHA2 will also become weak eventually - so then you bump it again. The point is to choose the best one for that time of history, which he has been resisting doing for years, based on bullshit pseudo-arguments about "trust".

No, git uses hashes in the same way that most other security system use hashes. The "trust" comes at a different point of the system. No hashes by themselves are "trusted" anywhere by any system. Git is not special in this regard. I repeat, Linus is talking horseshit and this horsehit argument is unfortunately getting repeated and spread around because of his position in the community.

I said the use of GPG is pointless, not SHA1 pointers, especially given his "trust" arguments. To exaggerate slightly, just to show you the point: it's like locking up a crappy lock (SHA1) inside a really secure safe (GPG). But this crappy lock is what opens up the real safe where your actual money is kept (the tree objects). And then we have Linus talking shit on the side saying the keys are not so important, but what he really gets security from is his trust in the delivery company that ships the safe around.

Re:Linus on Git and SHA-1 by hannob on Sunday February 26, 2017 @05:01AM (#13736517)
> Yes, SHA2 will also become weak eventually - so then you bump it again.

I disagree here. I doubt SHA2 or any modern hash will become weak within our lifetime. JP Aumasson, who is one of the experts of the field, agrees with me on that: https://twitter.com/veorq/status/834872988445065218

Re:Linus on Git and SHA-1 by kaoD on Sunday February 26, 2017 @08:38AM (#13737144)
It's funny because in that Twitter thread this[0] is linked:

     Reactions to stages in the life cycle of cryptographic hash functions
     Stage               | Expert reaction                             | Programmer reaction                             | Non-expert ("slashdotter") reaction
    ---------------------+---------------------------------------------+-------------------------------------------------+----------------------------------------
      ...                |  ...                                        |  ...                                            |  ...
     General acceptance  | Top-level researchers begin serious work on | Even Microsoft is using the hash function now   | Flame anyone who suggests the function
                         | finding a weakness (and international fame) |                                                 | may be broken in our lifetime
Just to be clear: I don't doubt JP Aumasson's reasons to believe so. I doubt yours because as far as I can tell it's basically argument from authority ("JP Aumasson said so!")

[0] http://valerieaurora.org/hash.html

Re:Linus on Git and SHA-1 by bascule on Saturday February 25, 2017 @06:25PM (#13734512)
Yes, exactly.

If Linus truly doesn't care about security, then git could use any error correcting code that produces a uniform distribution of tags, such as CRC64. The size of the tag only affects the number of objects we'd expect to be able to commit before we see a collision: over 4 billion in the case of CRC64.

Linux mistakenly claims using a cryptographic hash function helps avoid non-malicious collisions, but this is not the case.

Where the choice of a cryptographic hash function matters is specifically if we expect an attacker to be trying to collide tags. CRC64 is a linear function of the input data and therefore fails miserably at preventing attackers from colliding tags, but still produces a uniform distribution of tags for non-malicious inputs.

git seems to be in the odd place where Linus argues he's using a cryptographic hash function but not for security purposes.

Re:Linus on Git and SHA-1 by snowwrestler on Sunday February 26, 2017 @12:23AM (#13735812)
Linus: "You can have people who try to be malicious... they won't succeed."

Linus talked about why git's use of a "strong hash" made it better than other source control options during his talk at Google in 2007.

https://youtu.be/4XpnKHJAok8

Edit: the whole talk is good but the discussion of using hashes starts at about 55 min.

Re:Linus on Git and SHA-1 by Anderkent on Saturday February 25, 2017 @07:47PM (#13734919)
Well, if the cost of computation is not too relevant, and if you don't explicitly need the ability to craft collisions, why would you use a non-cryptographic hash function?

Like, when I'm building a lookup index for files, I'm going to use sha-(something), because it's easy and well known. I don't particularly care about the security aspect; I care that everyone immediately knows the contract of sha-1.

Re:Linus on Git and SHA-1 by bascule on Saturday February 25, 2017 @08:15PM (#13735039)
There is nothing to be gained from using cryptographic primitives in a non-security context. You could just as easily use e.g. CRC32 for the case you're describing.

There is, however, a performance cost in using cryptographic primitives in non-security-related contexts. You may not care about performance, but it certainly matters for something like git.

Linus claims: "So in git, the hash is used for de-duplication and error detection, and the 'cryptographic' nature is mainly because a cryptographic hash is really good at those things."

CRC produces a distribution just as uniform as a cryptographic hash function, and it's faster to boot. If these are the only things he actually cares about, and he's explicitly discounting security, he's choosing a slower primitive for no reason.

He writes off CRC inexplicably earlier in the post:

"Other SCM's have used things like CRC's for error detection, although honestly the most common error handling method in most SCM's tends to be 'tough luck, maybe your data is there, maybe it isn't, I don't care'."

Linus seems to think that SHA1 has some sort of magic crypto sauce which magically makes the distribution it produces more uniform than CRC's. It doesn't. The only difference is SHA1 was originally designed to be resistant to preimage and collision attacks, both of which are irrelevant outside of a security context.

Re:Linus on Git and SHA-1 by pvg on Saturday February 25, 2017 @09:23PM (#13735273)
You can still make a not-totally-unreasonable argument that something like CRC64 is simply too small - that maybe the 1 in a million collision chance for a few million hashes is too high. The fast, keyed 'semi-cryptographic' big hashes that are common now weren't around when git was written so the easiest thing to reach for would have been something like SHA-1.
Re:Linus on Git and SHA-1 by bascule on Saturday February 25, 2017 @09:44PM (#13735337)
"maybe the 1 in a million collision chance for a few million hashes is too high"

Well, let's look at what the actual numbers are. There's a nice table on this page:

https://en.wikipedia.org/wiki/Birthday_attack

For a 64-bit tag, even with 6,100,000 objects we'd only have a 1 in 10 million chance of a collision, so a 64-bit tag is more than sufficient to meet your stated requirements.

Re:Linus on Git and SHA-1 by pvg on Saturday February 25, 2017 @11:02PM (#13735597)
No no, I don't have any requirements, I just did the numbers and missed a zero instead of sensibly looking at a table. But that doesn't change the argument much - if one in a million isn't crazy, one in ten million is not completely insane either. With a 64 bit hash, you probably should write code to deal with a potential collision. Beside the (tiny) chance, someone might legitimately plop some test vectors that collide into a repo, just like the webkit people did the other day. With SHA-1 (in 2005), you can just punt and spend the time you saved yelling at people complaining to you about the choice of SHA-1 on mailing lists. It seems like a pragmatic implementation decision for the time.

I'm not trying to defend Linus's somewhat confused explanations, it's just that git's 'security' requirements are somewhat woolly and one could reasonably get away with half-assing it a bit for a while.

Re:Linus on Git and SHA-1 by bascule on Saturday February 25, 2017 @11:46PM (#13735723)
If you feel CRC64 does not meet the requirements, use CRC128.

For what it's worth, I think CRC64 should be fine for git-like workloads (but would still recommend using a cryptographically secure hash function, because git's usage is security-critical despite Linus constantly insisting it's not).

Re:Linus on Git and SHA-1 by pvg on Saturday February 25, 2017 @11:54PM (#13735738)
Why would you do that? Even if you don't know exactly what you want, are wrong about whether it's the basis of 'trust', for the purposes of writing git, you'd just take SHA-1. Nothing terrible is going to happen if it's both overkill and you aren't really building a secure system. You seem to be arguing, if I'm understanding you right, that you should only use a cryptographically strong hash iff you need all its properties. That seems like a really odd angle.
Re:Linus on Git and SHA-1 by bascule on Sunday February 26, 2017 @12:47AM (#13735883)
I am likewise perplexed why "cryptographic hash functions are unnecessary in the absence of an attacker" is such a difficult concept for you to grasp.

It is not an "odd angle". It is literally the very purpose for which they were created in the first place: to defend against attacks (preimage, collision)

If there are no attackers, the cryptography buys you nothing and merely makes the system slower.

Again, to go back to the original point: Linus's argument is that cryptographic functions have unique properties that make them specifically useful in non-security contexts. He's wrong. They don't. The non-cryptographic constructions he namedropped then glossed over work fine in these contexts.

Re:Linus on Git and SHA-1 by pvg on Sunday February 26, 2017 @01:38AM (#13736017)
I am likewise perplexed why "cryptographic hash functions are unnecessary in the absence of an attacker" is such a difficult concept for you to grasp.

Well, if we're going to be dicks to each other about it I'll try to explain what I think appears to be difficult for you to grasp. :) If you were throwing together something like git in a hurry you'd want a hash that

Lets you not have to think about collisions at all even if:

The collisions are by mere chance

The collisions arise by non-malicious accident

The collisions arise from malicious inputs [obviously, that implies an attacker but it also falls under 'I just don't want to think about collisions']

And right there, you grab the first non-completely-broken, not-too-giant, not-too-slow crypto hash around and get on with whatever else you had in mind. And this, to me, seems like the right call, especially since if collisions did eventually pop up, it'll probably be one generative collision and your entire system won't suddenly implode just because it exists. You'll have some time to fix stuff.

Again, to go back to the original point: Linus's argument is that cryptographic functions have unique properties that make them specifically useful in non-security contexts. He's wrong. They don't. The non-cryptographic constructions he namedropped then glossed over work fine in these contexts.

No argument there. Maybe I misunderstood 'Linus said something wrong' as 'Linus did something horribly wrong' and we're arguing over nothing?

Re:Linus on Git and SHA-1 by ProblemFactory on Sunday February 26, 2017 @05:12AM (#13736541)
I recently worked on a project where I had to choose a hash function for non-cryptographic error checking. I investigated CRC in detail for it, even wrote two different implementations from scratch.

CRC-X is complicated to use and terrible choice.

First of all, it is not a single algorithm, it is a family of algorithms. For a CRC of size N, you have to also choose a N-bit polynomial, N-bit starting value, and N-bit output XOR value. There is no single standard, there are tens or hundreds of popular options [1]. The optimal polynomial depends on both the CRC size, and the length of the data you are feeding into it [2]. If you choose poor parameters, you will get terrible error detection characteristics (like allowing extra 0 bits at the start of data with no change to the checksum). If you choose good parameters, certain classes of common errors like zeroing out a block of more than N bits will still have much worse characteristics than 1 / 2^N random chance of collision.

Second, implementation in standard libraries is patchy. Most programming languages have some CRC32 implementation - but do not document what parameters they use, or use different notation for the same parameters (forward and reverse), or do not let you change the parameters, or do not let you change the CRC size, or all of these. There is no easy way to get a "standard CRC64 or CRC128" compatible across platforms without putting it together from github snippets and example code yourself.

Third, CRC is fast when implemented in hardware, but not that much faster than SHA-1 or SHA-512 in software. It's only 1.5-2.5x faster [3], and when you're doing one checksum per uploaded file or something, it really does not matter. It's going to be even slower when you don't have a suitable-length CRC available in optimised native code, and have to write it yourself in simple C or pure Python.

The obvious and simple solution is to pick a known popular cryptographic hash like (SHA-X) that is available in the standard library of every programming language under the exact same API and no parameters to configure, truncate its output to the digest size you want, and call it a day. No need to worry about error detection performance on specific error cases like long bursts of zeros, and you get some defense against malicious tampering as a free bonus.

[1] https://en.wikipedia.org/wiki/Cyclic_redundancy_check#Standa...

[2] http://repository.cmu.edu/cgi/viewcontent.cgi?article=1672&c...

[3] https://www.cryptopp.com/benchmarks.html

Re:Linus on Git and SHA-1 by manquer on Sunday February 26, 2017 @10:05AM (#13737509)
Would MD5 also not satisfy all the availablity and standardization problems you mentioned just as well as SHA-x ? and also meet other non security requirements of git just as well ?

So why SHA-1 over MD5 which probably is move available and order of magnitude faster ? what problems MD5 has outside of its security that SHA-1 does not ?

Re:Linus on Git and SHA-1 by pvg on Sunday February 26, 2017 @10:13AM (#13737541)
So why SHA-1 over MD5 which probably is more available and order of magnitude faster?

This actually ends up not being true. Try

    openssl speed md5
    openssl speed sha1 
On a somewhat recent Intel CPU.
Re:Linus on Git and SHA-1 by bascule on Sunday February 26, 2017 @05:35PM (#13740419)
I'm glad you've at least looked into this, but you have a number of things wrong:

  First of all, it is not a single algorithm, it is a family of algorithms
This argument holds for SHA1, but all modern cryptographic hash functions are also families. The SHA3 family has SHA3-224, SHA3-256, SHA3-384, SHA3-512, SHAKE128, and SHAKE256

  For a CRC of size N, you have to also choose a N-bit
  polynomial, N-bit starting value, and N-bit output XOR
  value. There is no single standard, there are tens or
  hundreds of popular options
Apparently you've never heard of CRC32C!

http://www.evanjones.ca/crc32c.html

  Most programming languages have some CRC32 implementation
  - but do not document what parameters they use, or use
  different notation for the same parameters (forward and   
  reverse), or do not let you change the parameters, or do   
  not let you change the CRC size, or all of these. There is 
  no easy way to get a "standard CRC64 or CRC128" compatible 
  across platforms without putting it together from github  
  snippets and example code yourself.
Here's CRC32C implementations in a handful of popular languages:

- C: https://software.intel.com/en-us/node/503522

- Java: http://download.java.net/java/jdk9/docs/api/java/util/zip/CR...

- JavaScript: https://www.npmjs.com/package/fast-crc32c https://www.npmjs.com/package/crc32c

- Go: https://github.com/jacobsa/gcloud/blob/master/gcs/gcsutil/cr...

- Python: https://github.com/ludios/pycrc32c

- Ruby: http://www.rubydoc.info/gems/digest-crc/0.4.1/Digest/CRC32c

And again, I'm not actually recommending git switch to CRC (as a fan of security, I would prefer they use an actual collision resistant hash function). But CRC better meets Linus's stated requirements:

  - CRC will be faster (much faster as in ~4X, your numbers seem off to me) in almost all cases
  - CRC will *not* fail to detect a bitflip, whereas there's a certain probability a random oracle-based construction will
Re:Linus on Git and SHA-1 by Dylan16807 on Sunday February 26, 2017 @03:53AM (#13736339)
> I am likewise perplexed why "cryptographic hash functions are unnecessary in the absence of an attacker" is such a difficult concept for you to grasp.

Because you can't seem to tell the difference between "unnecessary" and "shouldn't be done".

If I build a shed then using larger screws on the door might be unnecessary but it only costs me .2% more and I know it won't fall over.

Using a recent SHA function might be overkill in a non-crypto context but it's high-quality and fast. And there's existing libraries for whatever language you want. Why the hell would anyone use CRC128? I've never even heard of it before.

It's a good hash choice, no matter how unnecessary.

Re:Linus on Git and SHA-1 by bascule on Sunday February 26, 2017 @02:16PM (#13739139)
Clearly it's not, because it's both several times slower than the CRC family, and was known to have cryptographic flaws before git was even released. "The worst of both worlds" so to speak...
Re:Linus on Git and SHA-1 by CalChris on Saturday February 25, 2017 @09:57PM (#13735386)
> There is, however, a performance cost in using cryptographic primitives in non-security-related contexts. You may not care about performance, but it certainly matters for something like git.

The performance difference between SHA1 and SHA256 is less than 50%. Unless hashing is a significant percentage of git, which it isn't, this is an insignificant difference.

http://atodorov.org/blog/2013/02/05/performance-test-md5-sha...

Also, you can easily argue that version control is a security context.

Re:Linus on Git and SHA-1 by bascule on Saturday February 25, 2017 @10:05PM (#13735410)
I absolutely believe git should use a cryptographically secure hash function.

But you're completely missing my point, which is about Linus's claims that git's use of SHA1 isn't security-critical, but why he's using a cryptographically secure hash function anyway.

Re:Linus on Git and SHA-1 by knweiss on Sunday February 26, 2017 @05:14AM (#13736550)
There are better cryptographic hash functions (e.g. Blake2) than SHA1 that are even faster. Check out the "results" slide of this slide deck for the cycles per byte table: https://blake2.net/acns/slides.html
Re:Linus on Git and SHA-1 by beagle3 on Sunday February 26, 2017 @05:18AM (#13736555)
Probably not. It's just that CRC128/CRC160/CRC256 primitives are not as common as MD5/SHA1/SHA256.

I did not, from Linus' post, get the impression he believes SHA1 are more magical than CRC except in the "image / second primage" sense.

Re:Linus on Git and SHA-1 by logicallee on Saturday February 25, 2017 @08:35PM (#13735106)
>Linux mistakenly claims using a cryptographic hash function helps avoid non-malicious collisions, but this is not the case.

of course it does. It is using a different field (cryptography) as a CRC that "really, really won't collide" because there is a whole field (cryptography) that is completely busted if it does.

Let me put it this way. If I really, really need a random distribution of white noise, I might use a different field, cryptography, to provide it: because if the distribution is not effectively random and uniformly distributed, that field in some fundamental sense is broken: no information is supposed to make it into the ciphertext, it should be indistinguishable from white noise.

So encrypting your source of white noise for the sole purpose of making it statistically closer to noise is a perfectly valid choice.

Actually in your commment you said it yourself: in as little as four billion commits CRC64 expects to see a collision. That is tiny compared to the search space cryptographers work with.

If you look at the history of git there was originally no reason to use cryptographic functions except in the same way as the analogy I just made (for white noise): he borrowed a property from a different field from the one he was working in.

Re:Linus on Git and SHA-1 by bascule on Saturday February 25, 2017 @08:57PM (#13735191)
You seem to be operating under the same sort of "cryptographic hash functions are magic!" delusions as Linus.

CRC and SHA1 both produce a uniform distribution. SHA1 does not magically do this better because cryptography. The only things that make CRC and SHA1 are any different are:

  - SHA1 produces a longer tag (of course CRC256 is a thing)
  - SHA1 is hardened against preimage attacks
  - SHA1 was intended to be secure against collision attacks (not anymore!)
SHA1, truncated to 32 or 64-bits, will produce a distribution just as uniform as CRC.

In a non-security setting, we can pick the size of the tag based on the rough number of objects we'd like to be able to store before we'd expect to see a collision (i.e. the birthday bound). If that number is ~4 billion, then CRC64 is sufficient.

Re:Linus on Git and SHA-1 by azernik on Saturday February 25, 2017 @09:33PM (#13735307)
This should really be a top-level comment.