make more platforms ignore libcrypt

pull/1830/head
Jeff 2 years ago
parent ee12ba51d5
commit 7a8410b375

@ -244,11 +244,13 @@ 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) target_link_libraries(liblokinet PRIVATE libunbound)
if(NOT WIN32) pkg_check_modules(CRYPT libcrypt IMPORTED_TARGET)
pkg_check_modules(CRYPT libcrypt REQUIRED IMPORTED_TARGET) if(CRYPT_FOUND AND NOT WIN32 AND NOT ANDROID)
add_definitions(-DHAVE_CRYPT)
add_library(libcrypt INTERFACE) add_library(libcrypt INTERFACE)
target_link_libraries(libcrypt INTERFACE PkgConfig::CRYPT) target_link_libraries(libcrypt INTERFACE PkgConfig::CRYPT)
target_link_libraries(liblokinet PRIVATE libcrypt) target_link_libraries(liblokinet PRIVATE libcrypt)
message(STATUS "using libcrypt ${CRYPT_VERSION}")
endif() endif()

@ -13,7 +13,7 @@
#include <llarp/util/str.hpp> #include <llarp/util/str.hpp>
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
#ifndef _WIN32 #ifdef HAVE_CRYPT
#include <crypt.h> #include <crypt.h>
#endif #endif
@ -472,12 +472,10 @@ 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)pwhash;
(void)challenge; (void)challenge;
return false;
#else
bool ret = false; bool ret = false;
#ifdef HAVE_CRYPT
auto pos = pwhash.find_last_of('$'); auto pos = pwhash.find_last_of('$');
auto settings = pwhash.substr(0, pos); auto settings = pwhash.substr(0, pos);
crypt_data data{}; crypt_data data{};
@ -486,8 +484,8 @@ namespace llarp
ret = ptr == pwhash; ret = ptr == pwhash;
} }
sodium_memzero(&data, sizeof(data)); sodium_memzero(&data, sizeof(data));
return ret;
#endif #endif
return ret;
} }
} // namespace sodium } // namespace sodium

@ -49,7 +49,7 @@ 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 #ifndef HAVE_CRYPT
if (itr->second == AuthFileType::eAuthFileHashes) if (itr->second == AuthFileType::eAuthFileHashes)
throw std::invalid_argument("unsupported auth file type: " + data); throw std::invalid_argument("unsupported auth file type: " + data);
#endif #endif

@ -48,7 +48,7 @@ TEST_CASE("PQ crypto")
REQUIRE(otherShared == shared); REQUIRE(otherShared == shared);
} }
#ifndef _WIN32 #ifdef HAVE_CRYPT
TEST_CASE("passwd hash valid") TEST_CASE("passwd hash valid")
{ {

Loading…
Cancel
Save