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

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

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

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

Loading…
Cancel
Save