path: root/sha1dc/ubc_check.h
diff options
authorJeff King <>2017-03-16 22:07:31 (GMT)
committerJunio C Hamano <>2017-03-16 22:16:40 (GMT)
commit28dc98e343ca4eb370a29ceec4c19beac9b5c01e (patch)
tree5624dd8c50f29c6781d5225f9b757926c695e07d /sha1dc/ubc_check.h
parentf18f816cb1586e9aab3e30a7144768e0d282d305 (diff)
sha1dc: add collision-detecting sha1 implementation
This is pulled straight from: with no modifications yet (though I've pulled in only the subset of files necessary for Git to use). This is commit 007905a93c973f55b2daed6585f9f6c23545bf66. Further updates can be done like: git checkout -b vendor-sha1dc $this_commit cp /path/to/sha1dc/{LICENSE.txt,lib/*} sha1dc/ git add -A sha1dc git commit -m "update sha1dc" git checkout -b update-sha1dc origin git merge vendor-sha1dc Thanks to both Marc and Dan for making the code fit our needs by doing both optimization work, cutting down on the object size, and doing some syntactic changes to work better with git. And to Linus for kicking off the "diet" work that removed some of the unused code. The license of the sha1dc code is the MIT license, which is obviously compatible with the GPLv2 of git. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'sha1dc/ubc_check.h')
1 files changed, 46 insertions, 0 deletions
diff --git a/sha1dc/ubc_check.h b/sha1dc/ubc_check.h
new file mode 100644
index 0000000..b349bed
--- /dev/null
+++ b/sha1dc/ubc_check.h
@@ -0,0 +1,46 @@
+* Copyright 2017 Marc Stevens <>, Dan Shumow <>
+* Distributed under the MIT Software License.
+* See accompanying file LICENSE.txt or copy at
+// this file was generated by the 'parse_bitrel' program in the tools section
+// using the data files from directory 'tools/data/3565'
+// sha1_dvs contains a list of SHA-1 Disturbance Vectors (DV) to check
+// dvType, dvK and dvB define the DV: I(K,B) or II(K,B) (see the paper)
+// dm[80] is the expanded message block XOR-difference defined by the DV
+// testt is the step to do the recompression from for collision detection
+// maski and maskb define the bit to check for each DV in the dvmask returned by ubc_check
+// ubc_check takes as input an expanded message block and verifies the unavoidable bitconditions for all listed DVs
+// it returns a dvmask where each bit belonging to a DV is set if all unavoidable bitconditions for that DV have been met
+// thus one needs to do the recompression check for each DV that has its bit set
+#ifndef UBC_CHECK_H
+#define UBC_CHECK_H
+#if defined(__cplusplus)
+extern "C" {
+#include <stdint.h>
+#define DVMASKSIZE 1
+typedef struct { int dvType; int dvK; int dvB; int testt; int maski; int maskb; uint32_t dm[80]; } dv_info_t;
+extern dv_info_t sha1_dvs[];
+void ubc_check(const uint32_t W[80], uint32_t dvmask[DVMASKSIZE]);
+#define CHECK_DVMASK(_DVMASK) (0 != _DVMASK[0])
+#if defined(__cplusplus)
+#endif /* UBC_CHECK_H */