From ee12ba51d544ae9436595038d1bdfa7f7c22de18 Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 1 Apr 2022 13:18:18 -0400 Subject: [PATCH] disable hashed auth on windows --- llarp/CMakeLists.txt | 8 +++++++- llarp/crypto/crypto_libsodium.cpp | 8 ++++++++ llarp/service/auth.cpp | 4 ++++ test/crypto/test_llarp_crypto.cpp | 4 ++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index 7fc9aecb4..33474aca0 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -243,7 +243,13 @@ if(WITH_HIVE) endif() target_link_libraries(liblokinet PUBLIC cxxopts lokinet-platform lokinet-util lokinet-cryptography sqlite_orm ngtcp2_static) -target_link_libraries(liblokinet PRIVATE libunbound crypt) +target_link_libraries(liblokinet PRIVATE libunbound) +if(NOT WIN32) + pkg_check_modules(CRYPT libcrypt REQUIRED IMPORTED_TARGET) + add_library(libcrypt INTERFACE) + target_link_libraries(libcrypt INTERFACE PkgConfig::CRYPT) + target_link_libraries(liblokinet PRIVATE libcrypt) +endif() if(BUILD_LIBLOKINET) diff --git a/llarp/crypto/crypto_libsodium.cpp b/llarp/crypto/crypto_libsodium.cpp index d901b976e..9c51f8443 100644 --- a/llarp/crypto/crypto_libsodium.cpp +++ b/llarp/crypto/crypto_libsodium.cpp @@ -13,7 +13,9 @@ #include #include #include +#ifndef _WIN32 #include +#endif #include @@ -470,6 +472,11 @@ namespace llarp bool CryptoLibSodium::check_passwd_hash(std::string pwhash, std::string challenge) { +#ifdef _WIN32 + (void)pwhash; + (void)challenge; + return false; +#else bool ret = false; auto pos = pwhash.find_last_of('$'); auto settings = pwhash.substr(0, pos); @@ -480,6 +487,7 @@ namespace llarp } sodium_memzero(&data, sizeof(data)); return ret; +#endif } } // namespace sodium diff --git a/llarp/service/auth.cpp b/llarp/service/auth.cpp index c765ac7d2..af52361d4 100644 --- a/llarp/service/auth.cpp +++ b/llarp/service/auth.cpp @@ -49,6 +49,10 @@ namespace llarp::service const auto itr = values.find(data); if (itr == values.end()) throw std::invalid_argument("no such auth file type: " + data); +#ifdef _WIN32 + if (itr->second == AuthFileType::eAuthFileHashes) + throw std::invalid_argument("unsupported auth file type: " + data); +#endif return itr->second; } diff --git a/test/crypto/test_llarp_crypto.cpp b/test/crypto/test_llarp_crypto.cpp index cef34b931..5d9cf707b 100644 --- a/test/crypto/test_llarp_crypto.cpp +++ b/test/crypto/test_llarp_crypto.cpp @@ -48,6 +48,8 @@ TEST_CASE("PQ crypto") REQUIRE(otherShared == shared); } +#ifndef _WIN32 + TEST_CASE("passwd hash valid") { llarp::sodium::CryptoLibSodium crypto; @@ -88,3 +90,5 @@ TEST_CASE("passwd hash malformed") for (const auto& hash : invalid_hashes) REQUIRE(not crypto.check_passwd_hash(hash, "stevejobs")); } + +#endif