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

[PATCH 1/3] sha1dc: update from upstream

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 6, 2017, 15:12 UTC
Message-ID
<20170606151231.25172-2-avarab@gmail.com>
In-Reply-To
<20170606151231.25172-1-avarab@gmail.com>

Update sha1dc from the latest version by the upstream maintainer[1].

See commit a0103914c2 ("sha1dc: update from upstream", 2017-05-20) for the latest update. That update was done sans some whitespace changes by upstream, which is why the diff here isn't the same as the upstream cc46554..e139984.

It also brings in a change[2] upstream made which should hopefully address the breakage in 2.13.1 on Cygwin, see [3]. Cygwin defines both _BIG_ENDIAN and _LITTLE_ENDIAN.

Adam Dinwoodie reports on the mailing list that that upstream commit fixes the issue on Cygwin[4].

1. https://github.com/cr-marcstevens/sha1collisiondetection/commit/e1399840b501a68ac6c8d7ed9a5cb1455480200e
2. https://github.com/cr-marcstevens/sha1collisiondetection/commit/a24eef58c0684078405f8c7a89f9b78271432005
3. <20170606100355.GC25777@dinwoodie.org> (https://public-inbox.org/git/20170606100355.GC25777@dinwoodie.org/)
4. <20170606124323.GD25777@dinwoodie.org> (https://public-inbox.org/git/20170606124323.GD25777@dinwoodie.org/)
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 sha1dc/sha1.c | 30 ++++++++++++++++++++++++------
 sha1dc/sha1.h |  6 +++---
 2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/sha1dc/sha1.c b/sha1dc/sha1.c
index 3dff80ac72..facea1bb56 100644
--- a/sha1dc/sha1.c
+++ b/sha1dc/sha1.c
@@ -35,15 +35,33 @@
 #ifdef SHA1DC_BIGENDIAN
 #undef SHA1DC_BIGENDIAN
 #endif
-#if (!defined SHA1DC_FORCE_LITTLEENDIAN) && \
-    ((defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || \
-    (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)) || \
-    defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) ||  defined(__AARCH64EB__) || \
-    defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) || defined(SHA1DC_FORCE_BIGENDIAN))
 
+#if (defined(_BYTE_ORDER) || defined(__BYTE_ORDER) || defined(__BYTE_ORDER__))
+
+#if ((defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)) || \
+     (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || \
+     (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)) )
 #define SHA1DC_BIGENDIAN
+#endif
+
+#else
+
+#if (defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN) || defined(__BIG_ENDIAN__) || \
+     defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
+     defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || \
+     defined(__sparc))
+#define SHA1DC_BIGENDIAN
+#endif
 
-#endif /*ENDIANNESS SELECTION*/
+#endif
+
+#if (defined(SHA1DC_FORCE_LITTLEENDIAN) && defined(SHA1DC_BIGENDIAN))
+#undef SHA1DC_BIGENDIAN
+#endif
+#if (defined(SHA1DC_FORCE_BIGENDIAN) && !defined(SHA1DC_BIGENDIAN))
+#define SHA1DC_BIGENDIAN
+#endif
+/*ENDIANNESS SELECTION*/
 
 #if (defined SHA1DC_FORCE_UNALIGNED_ACCESS || \
      defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || \
diff --git a/sha1dc/sha1.h b/sha1dc/sha1.h
index a0ff5d1305..1e4e94be54 100644
--- a/sha1dc/sha1.h
+++ b/sha1dc/sha1.h
@@ -61,9 +61,9 @@ void SHA1DCInit(SHA1_CTX*);
     Function to enable safe SHA-1 hashing:
     Collision attacks are thwarted by hashing a detected near-collision block 3 times.
     Think of it as extending SHA-1 from 80-steps to 240-steps for such blocks:
-	The best collision attacks against SHA-1 have complexity about 2^60,
-	thus for 240-steps an immediate lower-bound for the best cryptanalytic attacks would be 2^180.
-	An attacker would be better off using a generic birthday search of complexity 2^80.
+        The best collision attacks against SHA-1 have complexity about 2^60,
+        thus for 240-steps an immediate lower-bound for the best cryptanalytic attacks would be 2^180.
+        An attacker would be better off using a generic birthday search of complexity 2^80.
 
    Enabling safe SHA-1 hashing will result in the correct SHA-1 hash for messages where no collision attack was detected,
    but it will result in a different SHA-1 hash for messages where a collision attack was detected.
-- 
2.13.0.506.g27d5fe0cd
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 14 of 26 in “Git v2.13.1 SHA1 very broken”
  1. Adam DinwoodieJun 5, 2017
  2. Ævar Arnfjörð BjarmasonJun 5, 2017
  3. Ramsay JonesJun 5, 2017
  4. Ramsay JonesJun 6, 2017
  5. Junio C HamanoJun 6, 2017
  6. Adam DinwoodieJun 6, 2017
  7. Junio C HamanoJun 6, 2017
  8. Adam DinwoodieJun 6, 2017
  9. Continous Integration (was: RE: Git v2.13.1 SHA1 very broken)Jason Pyeron, Jun 6, 2017
  10. Lars SchneiderJun 6, 2017
  11. Adam DinwoodieJul 2, 2017
  12. Johannes SchindelinJul 3, 2017
  13. 0/3 update sha1dcÆvar Arnfjörð Bjarmason, Jun 6, 2017
  14. 1/3 sha1dc: update from upstreamÆvar Arnfjörð Bjarmason, Jun 6, 2017
  15. 2/3 sha1dc: optionally use sha1collisiondetection as a submoduleÆvar Arnfjörð Bjarmason, Jun 6, 2017
  16. Stefan BellerJun 6, 2017
  17. Ævar Arnfjörð BjarmasonJun 6, 2017
  18. Stefan BellerJun 6, 2017
  19. 3/3 sha1collisiondetection: automatically enable when submodule is populatedÆvar Arnfjörð Bjarmason, Jun 6, 2017
  20. Stefan BellerJun 6, 2017
  21. Ævar Arnfjörð BjarmasonJun 6, 2017
  22. sha1dc: ignore indent-with-non-tab whitespace violationsJeff King, Jun 6, 2017
  23. Ævar Arnfjörð BjarmasonJun 6, 2017
  24. Stefan BellerJun 6, 2017
  25. Liam R. HowlettJun 13, 2017
  26. Morten WelinderJun 6, 2017

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.