sha1dc: build git plumbing code more explicitly
The plumbing code between sha1dc and git is defined in sha1dc_git.[ch], but these aren't compiled / included directly but only via the indirect inclusion from sha1dc code. This is slightly confusing when you try to trace the build flow. This patch brings the following changes for simplification: - Make sha1dc_git.c stand-alone and build from Makefile - sha1dc_git.h is the common header to include further sha1.h depending on the build condition - Move comments for plumbing codes from the header to definitions This is also meant as a preliminary work for further plumbing with external sha1dc shlib. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Takashi Iwai committed
Aug 15, 2017 at 14:04 UTC
36f048c5e488005da0a9dfba6b617c7c9951c7cf
4 files changed
+16
-22
Makefile
+2
-3
@@ -1472,6 +1472,8 @@ ifdef APPLE_COMMON_CRYPTO
1472
BASIC_CFLAGS += -DSHA1_APPLE
1473
else
1474
DC_SHA1 := YesPlease
1475
+ BASIC_CFLAGS += -DSHA1_DC
1476
+ LIB_OBJS += sha1dc_git.o
1477
ifdef DC_SHA1_SUBMODULE
1478
LIB_OBJS += sha1collisiondetection/lib/sha1.o
1479
LIB_OBJS += sha1collisiondetection/lib/ubc_check.o
@@ -1481,12 +1483,9 @@ else
1483
LIB_OBJS += sha1dc/ubc_check.o
1484
endif
1485
BASIC_CFLAGS += \
1484
- -DSHA1_DC \
1486
-DSHA1DC_NO_STANDARD_INCLUDES \
1487
-DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 \
1488
-DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"cache.h\"" \
1488
- -DSHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C="\"sha1dc_git.c\"" \
1489
- -DSHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H="\"sha1dc_git.h\"" \
1489
-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="\"git-compat-util.h\""
1490
endif
1491
endif
hash.h
+1
-5
@@ -8,11 +8,7 @@
8
#elif defined(SHA1_OPENSSL)
9
#include <openssl/sha.h>
10
#elif defined(SHA1_DC)
11
-#ifdef DC_SHA1_SUBMODULE
12
-#include "sha1collisiondetection/lib/sha1.h"
13
-#else
14
-#include "sha1dc/sha1.h"
15
-#endif
11
+#include "sha1dc_git.h"
12
#else /* SHA1_BLK */
13
#include "block-sha1/sha1.h"
14
#endif
sha1dc_git.c
+6
-3
@@ -1,8 +1,8 @@
1
+#include "cache.h"
2
+
3
/*
2
- * This code is included at the end of sha1dc/sha1.c with the
3
- * SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C macro.
4
+ * Same as SHA1DCFinal, but convert collision attack case into a verbose die().
5
*/
5
-
6
void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)
7
{
8
if (!SHA1DCFinal(hash, ctx))
@@ -11,6 +11,9 @@ void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)
11
sha1_to_hex(hash));
12
}
13
14
+/*
15
+ * Same as SHA1DCUpdate, but adjust types to match git's usual interface.
16
+ */
17
void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)
18
{
19
const char *data = vdata;
sha1dc_git.h
+7
-11
@@ -1,16 +1,12 @@
1
-/*
2
- * This code is included at the end of sha1dc/sha1.h with the
3
- * SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H macro.
4
- */
1
+/* Plumbing with collition-detecting SHA1 code */
2
6
-/*
7
- * Same as SHA1DCFinal, but convert collision attack case into a verbose die().
8
- */
9
-void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);
3
+#ifdef DC_SHA1_SUBMODULE
4
+#include "sha1collisiondetection/lib/sha1.h"
5
+#else
6
+#include "sha1dc/sha1.h"
7
+#endif
8
11
-/*
12
- * Same as SHA1DCUpdate, but adjust types to match git's usual interface.
13
- */
9
+void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);
10
void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);
11
12
#define platform_SHA_CTX SHA1_CTX