disable hashed auth on windows

pull/1830/head
Jeff 2 years ago
parent 5050cd0299
commit ee12ba51d5

@ -243,7 +243,13 @@ if(WITH_HIVE)
endif() endif()
target_link_libraries(liblokinet PUBLIC cxxopts lokinet-platform lokinet-util lokinet-cryptography sqlite_orm ngtcp2_static) 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) if(BUILD_LIBLOKINET)

@ -13,7 +13,9 @@
#include <llarp/util/str.hpp> #include <llarp/util/str.hpp>
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
#ifndef _WIN32
#include <crypt.h> #include <crypt.h>
#endif
#include <llarp/util/str.hpp> #include <llarp/util/str.hpp>
@ -470,6 +472,11 @@ namespace llarp
bool bool
CryptoLibSodium::check_passwd_hash(std::string pwhash, std::string challenge) CryptoLibSodium::check_passwd_hash(std::string pwhash, std::string challenge)
{ {
#ifdef _WIN32
(void)pwhash;
(void)challenge;
return false;
#else
bool ret = false; bool ret = false;
auto pos = pwhash.find_last_of('$'); auto pos = pwhash.find_last_of('$');
auto settings = pwhash.substr(0, pos); auto settings = pwhash.substr(0, pos);
@ -480,6 +487,7 @@ namespace llarp
} }
sodium_memzero(&data, sizeof(data)); sodium_memzero(&data, sizeof(data));
return ret; return ret;
#endif
} }
} // namespace sodium } // namespace sodium

@ -49,6 +49,10 @@ namespace llarp::service
const auto itr = values.find(data); const auto itr = values.find(data);
if (itr == values.end()) if (itr == values.end())
throw std::invalid_argument("no such auth file type: " + data); 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; return itr->second;
} }

@ -48,6 +48,8 @@ TEST_CASE("PQ crypto")
REQUIRE(otherShared == shared); REQUIRE(otherShared == shared);
} }
#ifndef _WIN32
TEST_CASE("passwd hash valid") TEST_CASE("passwd hash valid")
{ {
llarp::sodium::CryptoLibSodium crypto; llarp::sodium::CryptoLibSodium crypto;
@ -88,3 +90,5 @@ TEST_CASE("passwd hash malformed")
for (const auto& hash : invalid_hashes) for (const auto& hash : invalid_hashes)
REQUIRE(not crypto.check_passwd_hash(hash, "stevejobs")); REQUIRE(not crypto.check_passwd_hash(hash, "stevejobs"));
} }
#endif

Loading…
Cancel
Save