mirror of https://github.com/WerWolv/ImHex.git
Fixed build on Unix, move crypto wrapper to libimhex
This commit is contained in:
parent
8c306a5d3d
commit
ac019a7d7e
|
@ -38,7 +38,6 @@ add_executable(imhex ${application_type}
|
|||
source/main.cpp
|
||||
source/window.cpp
|
||||
|
||||
source/helpers/crypto.cpp
|
||||
source/helpers/patches.cpp
|
||||
source/helpers/project_file_handler.cpp
|
||||
source/helpers/loader_script_handler.cpp
|
||||
|
@ -69,7 +68,7 @@ set_target_properties(imhex PROPERTIES CXX_VISIBILITY_PRESET hidden)
|
|||
target_link_directories(imhex PRIVATE ${MBEDTLS_LIBRARY_DIRS} ${CAPSTONE_LIBRARY_DIRS} ${MAGIC_LIBRARY_DIRS})
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(imhex libdl.a libmagic.a libgnurx.a libtre.a libintl.a libiconv.a libshlwapi.a libmbedx509.a libmbedcrypto.a libcapstone.a LLVMDemangle libimhex ${Python_LIBRARIES} wsock32 ws2_32)
|
||||
target_link_libraries(imhex libdl.a libmagic.a libgnurx.a libtre.a libintl.a libiconv.a libshlwapi.a libcapstone.a LLVMDemangle libimhex ${Python_LIBRARIES} wsock32 ws2_32)
|
||||
elseif (UNIX)
|
||||
target_link_libraries(imhex magic mbedtls ${CMAKE_DL_LIBS} capstone LLVMDemangle libimhex ${Python_LIBRARIES} dl)
|
||||
endif()
|
||||
|
|
|
@ -36,7 +36,7 @@ macro(findLibraries)
|
|||
# Find packages
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_search_module(MBEDTLS libmbedtls)
|
||||
pkg_search_module(MBEDTLS mbedtls)
|
||||
if(NOT MBEDTLS_FOUND)
|
||||
find_library(MBEDTLS mbedtls REQUIRED)
|
||||
else()
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "math_evaluator.hpp"
|
||||
|
||||
#include <hex/helpers/crypto.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
class NodeInteger : public dp::Node {
|
||||
|
|
|
@ -19,8 +19,10 @@ add_library(libimhex SHARED
|
|||
source/api/event.cpp
|
||||
source/api/imhex_api.cpp
|
||||
source/api/content_registry.cpp
|
||||
|
||||
source/helpers/utils.cpp
|
||||
source/helpers/shared_data.cpp
|
||||
source/helpers/crypto.cpp
|
||||
|
||||
source/lang/pattern_language.cpp
|
||||
source/lang/preprocessor.cpp
|
||||
|
@ -36,4 +38,9 @@ add_library(libimhex SHARED
|
|||
)
|
||||
|
||||
target_include_directories(libimhex PUBLIC include)
|
||||
target_link_libraries(libimhex PUBLIC imgui nlohmann_json)
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(libimhex PUBLIC imgui nlohmann_json libmbedcrypto.a)
|
||||
else ()
|
||||
target_link_libraries(libimhex PUBLIC imgui nlohmann_json mbedcrypto)
|
||||
endif ()
|
|
@ -26,4 +26,6 @@ namespace hex::crypt {
|
|||
|
||||
std::vector<u8> decode64(const std::vector<u8> &input);
|
||||
std::vector<u8> encode64(const std::vector<u8> &input);
|
||||
|
||||
std::vector<u8> aesCtrDecrypt(const std::vector<u8> &key, std::array<u8, 8> nonce, std::array<u8, 8> iv, const std::vector<u8> &input);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#include "helpers/crypto.hpp"
|
||||
#include <hex/helpers/crypto.hpp>
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
|||
#include <mbedtls/sha1.h>
|
||||
#include <mbedtls/sha256.h>
|
||||
#include <mbedtls/sha512.h>
|
||||
#include <mbedtls/aes.h>
|
||||
#include <mbedtls/cipher.h>
|
||||
|
||||
#include <array>
|
||||
#include <span>
|
||||
|
@ -239,4 +241,24 @@ namespace hex::crypt {
|
|||
return output;
|
||||
}
|
||||
|
||||
std::vector<u8> aesCtrDecrypt(const std::vector<u8> &key, std::array<u8, 8> nonce, std::array<u8, 8> iv, const std::vector<u8> &input) {
|
||||
std::vector<u8> output(input.size());
|
||||
mbedtls_cipher_context_t ctx;
|
||||
|
||||
mbedtls_cipher_setup(&ctx, mbedtls_cipher_info_from_type(MBEDTLS_CIPHER_AES_128_CTR));
|
||||
|
||||
mbedtls_cipher_setkey(&ctx, key.data(), key.size() * 8, MBEDTLS_DECRYPT);
|
||||
|
||||
std::array<u8, 16> nonceCounter = { 0 };
|
||||
std::copy(nonce.begin(), nonce.end(), nonceCounter.begin());
|
||||
std::copy(iv.begin(), iv.end(), nonceCounter.begin() + 8);
|
||||
|
||||
size_t outputSize = output.size();
|
||||
mbedtls_cipher_crypt(&ctx, nonceCounter.data(), nonceCounter.size(), input.data(), input.size(), output.data(), &outputSize);
|
||||
|
||||
mbedtls_cipher_free(&ctx);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
#include "helpers/crypto.hpp"
|
||||
#include <hex/helpers/crypto.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include "providers/file_provider.hpp"
|
||||
#include <hex/helpers/crypto.hpp>
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "helpers/crypto.hpp"
|
||||
#include "providers/file_provider.hpp"
|
||||
#include "helpers/patches.hpp"
|
||||
#include "helpers/project_file_handler.hpp"
|
||||
#include "helpers/loader_script_handler.hpp"
|
||||
|
|
Loading…
Reference in New Issue