@@ -7,9 +7,10 @@ protoc = generator(protoc_bin,
7788 arguments : [' -I@CURRENT_SOURCE_DIR@/common' , ' --proto_path=@CURRENT_SOURCE_DIR@' , ' --cpp_out=@BUILD_DIR@' , ' @INPUT@' ])
99
10- use_bcrypt = get_option (' use_bcrypt' )
10+ use_crypto = get_option (' use_crypto' )
11+ use_crypto25519 = get_option (' use_crypto25519' )
1112
12- if not use_bcrypt
13+ if use_crypto == ' OpenSSL ' or use_crypto25519 == ' OpenSSL '
1314 min_libcrypto = dependency (' libcrypto' , version : ' >=1.1.0' )
1415 good_libcrypto = dependency (' libcrypto' , version : ' >=1.1.1' , required : false )
1516
@@ -19,6 +20,10 @@ if not use_bcrypt
1920 dependencies += [ min_libcrypto ]
2021 endif
2122
23+ if use_crypto25519 == ' OpenSSL' and not good_libcrypto.found()
24+ error (' This version of OpenSSL does not support ed25519/curve25519. Please use -Duse_crypto25519=Reference or upgrade OpenSSL to 1.1.1 or later.' )
25+ endif
26+
2227 code = ''' #include <openssl/evp.h>
2328 int main(int argc, char **argv) {
2429 EVP_MD_CTX_free(NULL);
@@ -83,26 +88,26 @@ sources = [
8388 ' vstdlib/strtools.cpp' ,
8489]
8590
86- if use_bcrypt
87- dependencies += [ c_compiler.find_library (' bcrypt' ) ]
88- sources += [ ' common/crypto_bcrypt.cpp' ]
89- cpp_flags += [ ' -DED25519_HASH_BCRYPT' , ' -DSTEAMNETWORKINGSOCKETS_CRYPTO_BCRYPT' ]
90- else
91+ if use_crypto == ' OpenSSL'
9192 cpp_flags += [ ' -DSTEAMNETWORKINGSOCKETS_CRYPTO_VALVEOPENSSL' ]
9293 sources += [
9394 ' common/opensslwrapper.cpp' ,
9495 ' common/crypto_openssl.cpp' ,
9596 ]
97+ endif
9698
97- # Use OpenSSL for 25519 if possible
98- if good_libcrypto.found()
99- cpp_flags += [ ' -DSTEAMNETWORKINGSOCKETS_CRYPTO_25519_OPENSSL' ]
100- sources += [ ' common/crypto_25519_openssl.cpp' ]
101- endif
99+ if use_crypto == ' BCrypt'
100+ dependencies += [ c_compiler.find_library (' bcrypt' ) ]
101+ cpp_flags += [ ' -DED25519_HASH_BCRYPT' , ' -DSTEAMNETWORKINGSOCKETS_CRYPTO_BCRYPT' ]
102+ sources += [ ' common/crypto_bcrypt.cpp' ]
103+ endif
104+
105+ if use_crypto25519 == ' OpenSSL'
106+ cpp_flags += [ ' -DSTEAMNETWORKINGSOCKETS_CRYPTO_25519_OPENSSL' ]
107+ sources += [ ' common/crypto_25519_openssl.cpp' ]
102108endif
103109
104- # Use reference 25519 crypto implementation?
105- if use_bcrypt or not good_libcrypto.found()
110+ if use_crypto25519 == ' Reference'
106111 cpp_flags += [ ' -DVALVE_CRYPTO_25519_DONNA' ]
107112 sources += [
108113 ' common/crypto_25519_donna.cpp' ,
0 commit comments