8000 cmake: warn for not using sha1dc · libgit2/libgit2@b027a22 · GitHub
[go: up one dir, main page]

Skip to content

Commit b027a22

Browse files
committed
cmake: warn for not using sha1dc
git's hash algorithm is sha1dc, it is not sha1. Per Linus: > Honestly, git has effectively already moved from SHA1 to SHA1DC. > > So the actual known attack and weakness of SHA1 should simply not be > part of the discussion for the next hash. You can basically say "we're > _already_ on the second hash, we just picked one that was so > compatible with SHA1 that nobody even really noticed. Warn users who try to compile with SHA1 instead of SHA1DC.
1 parent dc81659 commit b027a22

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,9 @@ endif()
150150

151151
feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
152152
feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
153+
154+
# warn for not using sha1dc
155+
156+
foreach(WARNING ${WARNINGS})
157+
message(WARNING ${WARNING})
158+
endforeach()

cmake/SelectHashes.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,10 @@ endif()
112112

113113
add_feature_info(SHA1 ON "using ${USE_SHA1}")
114114
add_feature_info(SHA256 ON "using ${USE_SHA256}")
115+
116+
# warn for users who do not use sha1dc
117+
118+
if(NOT "${USE_SHA1}" STREQUAL "CollisionDetection")
119+
list(APPEND WARNINGS "SHA1 support is set to ${USE_SHA1} which is not recommended - git's hash algorithm is sha1dc, it is *not* SHA1. Using SHA1 may leave you and your users susceptible to SHAttered-style attacks.")
120+
set(WARNINGS ${WARNINGS} PARENT_SCOPE)
121+
endif()

0 commit comments

Comments
 (0)
0