@@ -4,23 +4,6 @@ include(CheckSymbolExists)
44include (CMakePushCheckState)
55
66find_package (Protobuf REQUIRED)
7- if (NOT USE_BCRYPT)
8- find_package (OpenSSL REQUIRED)
9-
10- # Ensure the OpenSSL version is recent enough. We need a bunch of EVP
11- # functionality.
12- cmake_push_check_state()
13- set (CMAKE_REQUIRED_LIBRARIES OpenSSL::Crypto)
14- check_symbol_exists(EVP_MD_CTX_free openssl/evp.h OPENSSL_NEW_ENOUGH)
15- if (NOT OPENSSL_NEW_ENOUGH)
16- message (FATAL_ERROR "Your OpenSSL version appears to be too old. Check that you're using OpenSSL 1.1.0 or later." )
17- endif ()
18- cmake_pop_check_state()
19- cmake_push_check_state()
20- set (CMAKE_REQUIRED_LIBRARIES OpenSSL::Crypto)
21- check_symbol_exists(EVP_PKEY_get_raw_public_key openssl/evp.h OPENSSL_HAS_25519_RAW)
22- cmake_pop_check_state()
23- endif ()
247find_package (Threads REQUIRED)
258
269set (GNS_PROTOS
@@ -53,7 +36,7 @@ set(GNS_SRCS
5336 "vstdlib/strtools.cpp"
5437)
5538
56- if (USE_BCRYPT )
39+ if (USE_CRYPTO STREQUAL "BCrypt" )
5740 set (GNS_CRYPTO_DEFINES ${GNS_CRYPTO_DEFINES} STEAMNETWORKINGSOCKETS_CRYPTO_BCRYPT ED25519_HASH_BCRYPT)
5841 set (GNS_SRCS ${GNS_SRCS}
5942 "common/crypto_bcrypt.cpp"
@@ -64,18 +47,18 @@ else()
6447 "common/crypto_openssl.cpp"
6548 "common/opensslwrapper.cpp"
6649 )
50+ endif ()
6751
68- # Use OpenSSL for 25519 if possible
69- if (OPENSSL_HAS_25519_RAW)
70- set (GNS_CRYPTO_DEFINES ${GNS_CRYPTO_DEFINES} STEAMNETWORKINGSOCKETS_CRYPTO_25519_OPENSSL)
71- set (GNS_SRCS ${GNS_SRCS}
72- "common/crypto_25519_openssl.cpp"
73- )
74- endif ()
52+ # Use OpenSSL for 25519 if possible
53+ if (USE_CRYPTO25519 STREQUAL "OpenSSL" )
54+ set (GNS_CRYPTO_DEFINES ${GNS_CRYPTO_DEFINES} STEAMNETWORKINGSOCKETS_CRYPTO_25519_OPENSSL)
55+ set (GNS_SRCS ${GNS_SRCS}
56+ "common/crypto_25519_openssl.cpp"
57+ )
7558endif ()
7659
7760# Use reference 25519 crypto implementation?
78- if (USE_BCRYPT OR NOT OPENSSL_HAS_25519_RAW )
61+ if (USE_CRYPTO25519 STREQUAL "Reference" )
7962 set (GNS_CRYPTO_DEFINES ${GNS_CRYPTO_DEFINES} VALVE_CRYPTO_25519_DONNA)
8063 set (GNS_SRCS ${GNS_SRCS}
8164 "common/crypto_25519_donna.cpp"
@@ -98,14 +81,20 @@ set(GNS_COMMON_FLAGS
9881 -fvisibility=hidden
9982 -fno-strict-aliasing
10083 -Wall
101- #-Wextra
10284 -Wno-unknown-pragmas
10385 -Wno-sign-compare
10486 -Wno-unused-local-typedef
10587 -Wno-unused-const-variable
10688 -Wno-nested-anon-types
10789)
10890
91+ if (USE_CRYPTO25519 STREQUAL "Reference" )
92+ # We don't use some of the 25519 functions with static linkage. Silence
93+ # -Wunused-function if we're including the reference ed25519/curve25519
94+ # stuff.
95+ set (GNS_COMMON_FLAGS ${GNS_COMMON_FLAGS} -Wno-unused-function)
96+ endif ()
97+
10998if (WERROR)
11099 set (GNS_COMMON_FLAGS
111100 ${GNS_COMMON_FLAGS}
@@ -158,7 +147,7 @@ macro(gamenetworkingsockets_common GNS_TARGET)
158147 Threads::Threads
159148 )
160149
161- if (NOT USE_BCRYPT )
150+ if (USE_CRYPTO STREQUAL "OpenSSL" OR USE_CRYPTO25519 STREQUAL "OpenSSL" )
162151 target_link_libraries (${GNS_TARGET} PUBLIC
163152 OpenSSL::Crypto
164153 )
@@ -240,7 +229,7 @@ macro(gamenetworkingsockets_common GNS_TARGET)
240229 target_compile_options (${GNS_TARGET} PRIVATE -fno-stack-protector)
241230 endif ()
242231 target_link_libraries (${GNS_TARGET} PUBLIC ws2_32 crypt32)
243- if (USE_BCRYPT )
232+ if (USE_CRYPTO STREQUAL "BCrypt" )
244233 target_link_libraries (${GNS_TARGET} PUBLIC bcrypt)
245234 endif ()
246235 else ()
0 commit comments