Skip to content

Commit 48b3693

Browse files
committed
Merge branch 'jk/sha1dc'
The "detect attempt to create collisions" variant of SHA-1 implementation by Marc Stevens (CWI) and Dan Shumow (Microsoft) has been integrated and made the default. * jk/sha1dc: Makefile: make DC_SHA1 the default t0013: add a basic sha1 collision detection test Makefile: add DC_SHA1 knob sha1dc: disable safe_hash feature sha1dc: adjust header includes for git sha1dc: add collision-detecting sha1 implementation
2 parents fa13fd1 + e6b07da commit 48b3693

File tree

9 files changed

+2405
-2
lines changed

9 files changed

+2405
-2
lines changed

Makefile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ all::
140140
# Define PPC_SHA1 environment variable when running make to make use of
141141
# a bundled SHA1 routine optimized for PowerPC.
142142
#
143+
# Define DC_SHA1 to unconditionally enable the collision-detecting sha1
144+
# algorithm. This is slower, but may detect attempted collision attacks.
145+
# Takes priority over other *_SHA1 knobs.
146+
#
147+
# Define OPENSSL_SHA1 environment variable when running make to link
148+
# with the SHA1 routine from openssl library.
149+
#
143150
# Define SHA1_MAX_BLOCK_SIZE to limit the amount of data that will be hashed
144151
# in one call to the platform's SHA1_Update(). e.g. APPLE_COMMON_CRYPTO
145152
# wants 'SHA1_MAX_BLOCK_SIZE=1024L*1024L*1024L' defined.
@@ -1383,6 +1390,10 @@ ifdef APPLE_COMMON_CRYPTO
13831390
SHA1_MAX_BLOCK_SIZE = 1024L*1024L*1024L
13841391
endif
13851392

1393+
ifdef OPENSSL_SHA1
1394+
EXTLIBS += $(LIB_4_CRYPTO)
1395+
BASIC_CFLAGS += -DSHA1_OPENSSL
1396+
else
13861397
ifdef BLK_SHA1
13871398
LIB_OBJS += block-sha1/sha1.o
13881399
BASIC_CFLAGS += -DSHA1_BLK
@@ -1395,8 +1406,11 @@ ifdef APPLE_COMMON_CRYPTO
13951406
COMPAT_CFLAGS += -DCOMMON_DIGEST_FOR_OPENSSL
13961407
BASIC_CFLAGS += -DSHA1_APPLE
13971408
else
1398-
EXTLIBS += $(LIB_4_CRYPTO)
1399-
BASIC_CFLAGS += -DSHA1_OPENSSL
1409+
DC_SHA1 := YesPlease
1410+
LIB_OBJS += sha1dc/sha1.o
1411+
LIB_OBJS += sha1dc/ubc_check.o
1412+
BASIC_CFLAGS += -DSHA1_DC
1413+
endif
14001414
endif
14011415
endif
14021416
endif
@@ -2223,6 +2237,7 @@ GIT-BUILD-OPTIONS: FORCE
22232237
@echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@+
22242238
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
22252239
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
2240+
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
22262241
ifdef TEST_OUTPUT_DIRECTORY
22272242
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
22282243
endif

hash.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <CommonCrypto/CommonDigest.h>
88
#elif defined(SHA1_OPENSSL)
99
#include <openssl/sha.h>
10+
#elif defined(SHA1_DC)
11+
#include "sha1dc/sha1.h"
1012
#else /* SHA1_BLK */
1113
#include "block-sha1/sha1.h"
1214
#endif

sha1dc/LICENSE.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
MIT License
2+
3+
Copyright (c) 2017:
4+
Marc Stevens
5+
Cryptology Group
6+
Centrum Wiskunde & Informatica
7+
P.O. Box 94079, 1090 GB Amsterdam, Netherlands
8+
9+
10+
Dan Shumow
11+
Microsoft Research
12+
13+
14+
Permission is hereby granted, free of charge, to any person obtaining a copy
15+
of this software and associated documentation files (the "Software"), to deal
16+
in the Software without restriction, including without limitation the rights
17+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18+
copies of the Software, and to permit persons to whom the Software is
19+
furnished to do so, subject to the following conditions:
20+
21+
The above copyright notice and this permission notice shall be included in all
22+
copies or substantial portions of the Software.
23+
24+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+
SOFTWARE.

0 commit comments

Comments
 (0)