Skip to content

Commit 1d18997

Browse files
tacker66gitster
authored andcommitted
doc hash-function-transition: move rationale upwards
Move rationale for new hash function to beginning of document so that it appears before the concrete move to SHA-256 is described. Remove some of the details about SHA-1 weaknesses and add references to the details on how the new hash function was chosen instead. Signed-off-by: Thomas Ackermann <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cc9f091 commit 1d18997

File tree

1 file changed

+34
-42
lines changed

1 file changed

+34
-42
lines changed

Documentation/technical/hash-function-transition.txt

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,9 @@ researchers. On 23 February 2017 the SHAttered attack
3333

3434
Git v2.13.0 and later subsequently moved to a hardened SHA-1
3535
implementation by default, which isn't vulnerable to the SHAttered
36-
attack.
36+
attack, but SHA-1 is still weak.
3737

38-
Thus Git has in effect already migrated to a new hash that isn't SHA-1
39-
and doesn't share its vulnerabilities, its new hash function just
40-
happens to produce exactly the same output for all known inputs,
41-
except two PDFs published by the SHAttered researchers, and the new
42-
implementation (written by those researchers) claims to detect future
43-
cryptanalytic collision attacks.
44-
45-
Regardless, it's considered prudent to move past any variant of SHA-1
38+
Thus it's considered prudent to move past any variant of SHA-1
4639
to a new hash. There's no guarantee that future attacks on SHA-1 won't
4740
be published in the future, and those attacks may not have viable
4841
mitigations.
@@ -57,6 +50,38 @@ SHA-1 still possesses the other properties such as fast object lookup
5750
and safe error checking, but other hash functions are equally suitable
5851
that are believed to be cryptographically secure.
5952

53+
Choice of Hash
54+
--------------
55+
The hash to replace the hardened SHA-1 should be stronger than SHA-1
56+
was: we would like it to be trustworthy and useful in practice for at
57+
least 10 years.
58+
59+
Some other relevant properties:
60+
61+
1. A 256-bit hash (long enough to match common security practice; not
62+
excessively long to hurt performance and disk usage).
63+
64+
2. High quality implementations should be widely available (e.g., in
65+
OpenSSL and Apple CommonCrypto).
66+
67+
3. The hash function's properties should match Git's needs (e.g. Git
68+
requires collision and 2nd preimage resistance and does not require
69+
length extension resistance).
70+
71+
4. As a tiebreaker, the hash should be fast to compute (fortunately
72+
many contenders are faster than SHA-1).
73+
74+
There were several contenders for a successor hash to SHA-1, including
75+
SHA-256, SHA-512/256, SHA-256x16, K12, and BLAKE2bp-256.
76+
77+
In late 2018 the project picked SHA-256 as its successor hash.
78+
79+
See 0ed8d8da374 (doc hash-function-transition: pick SHA-256 as
80+
NewHash, 2018-08-04) and numerous mailing list threads at the time,
81+
particularly the one starting at
82+
https://lore.kernel.org/git/[email protected]/
83+
for more information.
84+
6085
Goals
6186
-----
6287
1. The transition to SHA-256 can be done one local repository at a time.
@@ -601,39 +626,6 @@ example:
601626

602627
git --output-format=sha1 log abac87a^{sha1}..f787cac^{sha256}
603628

604-
Choice of Hash
605-
--------------
606-
In early 2005, around the time that Git was written, Xiaoyun Wang,
607-
Yiqun Lisa Yin, and Hongbo Yu announced an attack finding SHA-1
608-
collisions in 2^69 operations. In August they published details.
609-
Luckily, no practical demonstrations of a collision in full SHA-1 were
610-
published until 10 years later, in 2017.
611-
612-
Git v2.13.0 and later subsequently moved to a hardened SHA-1
613-
implementation by default that mitigates the SHAttered attack, but
614-
SHA-1 is still believed to be weak.
615-
616-
The hash to replace this hardened SHA-1 should be stronger than SHA-1
617-
was: we would like it to be trustworthy and useful in practice for at
618-
least 10 years.
619-
620-
Some other relevant properties:
621-
622-
1. A 256-bit hash (long enough to match common security practice; not
623-
excessively long to hurt performance and disk usage).
624-
625-
2. High quality implementations should be widely available (e.g., in
626-
OpenSSL and Apple CommonCrypto).
627-
628-
3. The hash function's properties should match Git's needs (e.g. Git
629-
requires collision and 2nd preimage resistance and does not require
630-
length extension resistance).
631-
632-
4. As a tiebreaker, the hash should be fast to compute (fortunately
633-
many contenders are faster than SHA-1).
634-
635-
We choose SHA-256.
636-
637629
Transition plan
638630
---------------
639631
Some initial steps can be implemented independently of one another:

0 commit comments

Comments
 (0)