Skip to content

Commit 2db8732

Browse files
committed
Merge branch 'ab/sha1dc'
The "collission-detecting" implementation of SHA-1 hash we borrowed from is replaced by directly binding the upstream project as our submodule. Glitches on minority platforms are still being worked out. * ab/sha1dc: sha1collisiondetection: automatically enable when submodule is populated sha1dc: optionally use sha1collisiondetection as a submodule
2 parents d73b46c + cac87dc commit 2db8732

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "sha1collisiondetection"]
2+
path = sha1collisiondetection
3+
url = https://github.com/cr-marcstevens/sha1collisiondetection.git
4+
branch = master

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ all::
162162
# algorithm. This is slower, but may detect attempted collision attacks.
163163
# Takes priority over other *_SHA1 knobs.
164164
#
165+
# Define DC_SHA1_SUBMODULE in addition to DC_SHA1 to use the
166+
# sha1collisiondetection shipped as a submodule instead of the
167+
# non-submodule copy in sha1dc/. This is an experimental option used
168+
# by the git project to migrate to using sha1collisiondetection as a
169+
# submodule.
170+
#
165171
# Define OPENSSL_SHA1 environment variable when running make to link
166172
# with the SHA1 routine from openssl library.
167173
#
@@ -1004,6 +1010,10 @@ EXTLIBS =
10041010

10051011
GIT_USER_AGENT = git/$(GIT_VERSION)
10061012

1013+
ifeq ($(wildcard sha1collisiondetection/lib/sha1.h),sha1collisiondetection/lib/sha1.h)
1014+
DC_SHA1_SUBMODULE = auto
1015+
endif
1016+
10071017
include config.mak.uname
10081018
-include config.mak.autogen
10091019
-include config.mak
@@ -1449,8 +1459,14 @@ ifdef APPLE_COMMON_CRYPTO
14491459
BASIC_CFLAGS += -DSHA1_APPLE
14501460
else
14511461
DC_SHA1 := YesPlease
1462+
ifdef DC_SHA1_SUBMODULE
1463+
LIB_OBJS += sha1collisiondetection/lib/sha1.o
1464+
LIB_OBJS += sha1collisiondetection/lib/ubc_check.o
1465+
BASIC_CFLAGS += -DDC_SHA1_SUBMODULE
1466+
else
14521467
LIB_OBJS += sha1dc/sha1.o
14531468
LIB_OBJS += sha1dc/ubc_check.o
1469+
endif
14541470
BASIC_CFLAGS += \
14551471
-DSHA1_DC \
14561472
-DSHA1DC_NO_STANDARD_INCLUDES \

hash.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
#elif defined(SHA1_OPENSSL)
99
#include <openssl/sha.h>
1010
#elif defined(SHA1_DC)
11+
#ifdef DC_SHA1_SUBMODULE
12+
#include "sha1collisiondetection/lib/sha1.h"
13+
#else
1114
#include "sha1dc/sha1.h"
15+
#endif
1216
#else /* SHA1_BLK */
1317
#include "block-sha1/sha1.h"
1418
#endif

sha1collisiondetection

Submodule sha1collisiondetection added at 19d97bf

0 commit comments

Comments
 (0)