ddnet/cmake/FindCrypto.cmake
heinrich5991 ca8fcc823c Use more secure hash function for map downloads
SHA256 was chosen because it is reasonably standard, the file names
don't explode in length (this rules out SHA512) and it is supported by
basically all versions of OpenSSL (this rules out SHA512/256 and SHA3).

The protocol is changed in a backward compatible way: The supporting
server sends the SHA256 corresponding to the map in the `MAP_DETAILS`
message prior to sending the `MAP_CHANGE` message. The client saves the
SHA256 obtained from the `MAP_DETAILS` message until the next
`MAP_CHANGE` message.

For servers not supporting this protocol, the client falls back to
simply opening maps like in the previous scheme.

Remove the `map_version` tool, it is not being used and would have been
a little bit effort to update.

Use the OpenSSL implementation of SHA256 if it is supported, otherwise
fall back to a public domain one.

Fix #1127.
2018-06-24 17:04:50 +02:00

20 lines
538 B
CMake

if(NOT PREFER_BUNDLED_LIBS)
find_package(OpenSSL)
if(OPENSSL_FOUND)
set(CRYPTO_FOUND ON)
set(CRYPTO_BUNDLED OFF)
set(CRYPTO_LIBRARY ${OPENSSL_CRYPTO_LIBRARY})
set(CRYPTO_INCLUDEDIR ${OPENSSL_INCLUDE_DIR})
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Crypto DEFAULT_MSG CRYPTO_LIBRARY CRYPTO_INCLUDEDIR)
mark_as_advanced(CRYPTO_LIBRARY CRYPTO_INCLUDEDIR)
if(CRYPTO_FOUND)
set(CRYPTO_LIBRARIES ${CRYPTO_LIBRARY})
set(CRYPTO_INCLUDE_DIRS ${CRYPTO_INCLUDEDIR})
endif()