From 785ecb8a7858edfb88747623b7437da0c02b5317 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 2 Feb 2021 23:11:23 +0100 Subject: [PATCH] Switch from openssl/libcrypto to mbedtls --- .github/workflows/build.yml | 13 +++- CMakeLists.txt | 8 +- cmake/build_helpers.cmake | 8 +- dist/Brewfile | 2 +- dist/ImHex-9999.ebuild | 2 +- dist/get_deps_archlinux.sh | 2 +- dist/get_deps_debian.sh | 2 +- dist/get_deps_fedora.sh | 2 +- dist/get_deps_msys2.sh | 2 +- include/helpers/crypto.hpp | 20 ++--- include/views/view_hashes.hpp | 2 +- source/helpers/crypto.cpp | 126 ++++++++++++++++---------------- source/views/view_hashes.cpp | 61 ++++++---------- source/views/view_hexeditor.cpp | 2 +- 14 files changed, 124 insertions(+), 128 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee20b10a7..1f84299f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: libglfw3-dev \ libglm-dev \ libmagic-dev \ - libssl-dev \ + libmbedtls-dev \ libcapstone-dev \ python3-dev \ libfreetype-dev \ @@ -92,7 +92,7 @@ jobs: mingw-w64-${{ matrix.arch }}-glfw mingw-w64-${{ matrix.arch }}-glm mingw-w64-${{ matrix.arch }}-file - mingw-w64-${{ matrix.arch }}-openssl + mingw-w64-${{ matrix.arch }}-mbedtls mingw-w64-${{ matrix.arch }}-polly mingw-w64-${{ matrix.arch }}-python mingw-w64-${{ matrix.arch }}-dlfcn @@ -155,7 +155,14 @@ jobs: run: | mkdir build cd build - CC=$(brew --prefix llvm)/bin/clang CXX=$(brew --prefix llvm)/bin/clang++ PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig":"$(brew --prefix)/lib/pkgconfig" cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCREATE_BUNDLE=ON -DCREATE_PACKAGE=ON .. + CC=$(brew --prefix llvm)/bin/clang \ + CXX=$(brew --prefix llvm)/bin/clang++ \ + PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig":"$(brew --prefix)/lib/pkgconfig" \ + cmake \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ + -DCREATE_BUNDLE=ON \ + -DCREATE_PACKAGE=ON \ + .. make -j 4 package - name: 📦 Upload DMG diff --git a/CMakeLists.txt b/CMakeLists.txt index 08f4b8501..cc21f786e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ add_subdirectory(external/llvm) add_subdirectory(plugins/libimhex) # Add include directories -include_directories(include ${CRYPTO_INCLUDE_DIRS} ${CAPSTONE_INCLUDE_DIRS} ${MAGIC_INCLUDE_DIRS} ${Python_INCLUDE_DIRS}) +include_directories(include ${MBEDTLS_INCLUDE_DIRS} ${CAPSTONE_INCLUDE_DIRS} ${MAGIC_INCLUDE_DIRS} ${Python_INCLUDE_DIRS}) addVersionDefines() configurePackageCreation() @@ -66,12 +66,12 @@ add_executable(imhex ${application_type} ) set_target_properties(imhex PROPERTIES CXX_VISIBILITY_PRESET hidden) -target_link_directories(imhex PRIVATE ${CRYPTO_LIBRARY_DIRS} ${CAPSTONE_LIBRARY_DIRS} ${MAGIC_LIBRARY_DIRS}) +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 libcrypto.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 libmbedx509.a libmbedcrypto.a libcapstone.a LLVMDemangle libimhex ${Python_LIBRARIES} wsock32 ws2_32) elseif (UNIX) - target_link_libraries(imhex magic crypto ${CMAKE_DL_LIBS} capstone LLVMDemangle libimhex ${Python_LIBRARIES} dl) + target_link_libraries(imhex magic mbedtls ${CMAKE_DL_LIBS} capstone LLVMDemangle libimhex ${Python_LIBRARIES} dl) endif() createPackage() \ No newline at end of file diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 09371210f..53471bf28 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -36,11 +36,11 @@ macro(findLibraries) # Find packages find_package(PkgConfig REQUIRED) - pkg_search_module(CRYPTO libcrypto) - if(NOT CRYPTO_FOUND) - find_library(CRYPTO crypto REQUIRED) + pkg_search_module(MBEDTLS libmbedtls) + if(NOT MBEDTLS_FOUND) + find_library(MBEDTLS mbedtls REQUIRED) else() - set(CRYPTO_INCLUDE_DIRS ${CRYPTO_INCLUDEDIR}) + set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_INCLUDEDIR}) endif() pkg_search_module(CAPSTONE REQUIRED capstone) diff --git a/dist/Brewfile b/dist/Brewfile index 8fde92a01..42db16207 100644 --- a/dist/Brewfile +++ b/dist/Brewfile @@ -1,5 +1,5 @@ brew "glfw3" -brew "openssl@1.1" +brew "mbedtls" brew "capstone" brew "nlohmann-json" brew "glm" diff --git a/dist/ImHex-9999.ebuild b/dist/ImHex-9999.ebuild index fc2efd827..716470c52 100644 --- a/dist/ImHex-9999.ebuild +++ b/dist/ImHex-9999.ebuild @@ -25,7 +25,7 @@ RDEPEND="${DEPEND} ${PYTHON_DEPS} media-libs/glfw sys-apps/file - dev-libs/openssl + dev-libs/mbedtls dev-libs/capstone sys-devel/llvm dev-cpp/nlohmann_json diff --git a/dist/get_deps_archlinux.sh b/dist/get_deps_archlinux.sh index 863401fc3..ee0dd12eb 100755 --- a/dist/get_deps_archlinux.sh +++ b/dist/get_deps_archlinux.sh @@ -5,7 +5,7 @@ pacman -S --needed \ gcc \ glfw \ file \ - openssl \ + mbedtls \ capstone \ glm \ python3 \ diff --git a/dist/get_deps_debian.sh b/dist/get_deps_debian.sh index d115cce18..a87a19f64 100755 --- a/dist/get_deps_debian.sh +++ b/dist/get_deps_debian.sh @@ -19,7 +19,7 @@ apt install \ libglfw3-dev \ libglm-dev \ libjsoncpp-dev \ - libssl-dev \ + libmbedtls-dev \ libstdc++-10-dev \ python3-dev \ libfreetype-dev diff --git a/dist/get_deps_fedora.sh b/dist/get_deps_fedora.sh index f9640c03f..940cba29a 100755 --- a/dist/get_deps_fedora.sh +++ b/dist/get_deps_fedora.sh @@ -8,6 +8,6 @@ dnf install \ glfw-devel \ glm-devel \ mesa-libGL-devel \ - openssl-devel \ + mbedtls-devel \ python-devel \ freetype-devel diff --git a/dist/get_deps_msys2.sh b/dist/get_deps_msys2.sh index 7fa515af0..e290a0b5c 100755 --- a/dist/get_deps_msys2.sh +++ b/dist/get_deps_msys2.sh @@ -8,7 +8,7 @@ pacman -S --needed \ mingw-w64-x86_64-glfw \ mingw-w64-x86_64-glm \ mingw-w64-x86_64-file \ - mingw-w64-x86_64-openssl \ + mingw-w64-x86_64-mbedtls \ mingw-w64-x86_64-polly \ mingw-w64-x86_64-python \ mingw-w64-x86_64-freetype \ diff --git a/include/helpers/crypto.hpp b/include/helpers/crypto.hpp index c6fd83b68..3637448a7 100644 --- a/include/helpers/crypto.hpp +++ b/include/helpers/crypto.hpp @@ -7,20 +7,22 @@ #include #include -namespace hex { +namespace hex::prv { class Provider; } - namespace prv { class Provider; } +namespace hex::crypt { + + void initialize(); + void exit(); u16 crc16(prv::Provider* &data, u64 offset, size_t size, u16 polynomial, u16 init); u32 crc32(prv::Provider* &data, u64 offset, size_t size, u32 polynomial, u32 init); - std::array md4(prv::Provider* &data, u64 offset, size_t size); - std::array md5(prv::Provider* &data, u64 offset, size_t size); - std::array sha1(prv::Provider* &data, u64 offset, size_t size); - std::array sha224(prv::Provider* &data, u64 offset, size_t size); - std::array sha256(prv::Provider* &data, u64 offset, size_t size); - std::array sha384(prv::Provider* &data, u64 offset, size_t size); - std::array sha512(prv::Provider* &data, u64 offset, size_t size); + std::array md5(prv::Provider* &data, u64 offset, size_t size); + std::array sha1(prv::Provider* &data, u64 offset, size_t size); + std::array sha224(prv::Provider* &data, u64 offset, size_t size); + std::array sha256(prv::Provider* &data, u64 offset, size_t size); + std::array sha384(prv::Provider* &data, u64 offset, size_t size); + std::array sha512(prv::Provider* &data, u64 offset, size_t size); std::vector decode64(const std::vector &input); std::vector encode64(const std::vector &input); diff --git a/include/views/view_hashes.hpp b/include/views/view_hashes.hpp index 43dd6a474..77c96135a 100644 --- a/include/views/view_hashes.hpp +++ b/include/views/view_hashes.hpp @@ -22,7 +22,7 @@ namespace hex { u64 m_hashRegion[2] = { 0 }; bool m_shouldMatchSelection = false; - static constexpr const char* HashFunctionNames[] = { "CRC16", "CRC32", "MD4", "MD5", "SHA-1", "SHA-224", "SHA-256", "SHA-384", "SHA-512" }; + static constexpr const char* HashFunctionNames[] = { "CRC16", "CRC32", "MD5", "SHA-1", "SHA-224", "SHA-256", "SHA-384", "SHA-512" }; }; } \ No newline at end of file diff --git a/source/helpers/crypto.cpp b/source/helpers/crypto.cpp index e634572bb..c047d4e8d 100644 --- a/source/helpers/crypto.cpp +++ b/source/helpers/crypto.cpp @@ -2,16 +2,16 @@ #include -#include -#include -#include - -#include +#include +#include +#include +#include +#include #include #include -namespace hex { +namespace hex::crypt { u16 crc16(prv::Provider* &data, u64 offset, size_t size, u16 polynomial, u16 init) { const auto table = [polynomial] { @@ -85,134 +85,134 @@ namespace hex { return ~c; } - std::array md4(prv::Provider* &data, u64 offset, size_t size) { - std::array result = { 0 }; + std::array md5(prv::Provider* &data, u64 offset, size_t size) { + std::array result = { 0 }; - MD4_CTX ctx; + mbedtls_md5_context ctx; + mbedtls_md5_init(&ctx); - MD4_Init(&ctx); + mbedtls_md5_starts_ret(&ctx); std::array buffer = { 0 }; for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) { const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset); data->read(offset + bufferOffset, buffer.data(), readSize); - MD4_Update(&ctx, buffer.data(), readSize); + mbedtls_md5_update_ret(&ctx, buffer.data(), readSize); } - MD4_Final(reinterpret_cast(result.data()), &ctx); + mbedtls_md5_finish_ret(&ctx, result.data()); + + mbedtls_md5_free(&ctx); return result; } - std::array md5(prv::Provider* &data, u64 offset, size_t size) { - std::array result = { 0 }; + std::array sha1(prv::Provider* &data, u64 offset, size_t size) { + std::array result = { 0 }; - MD5_CTX ctx; + mbedtls_sha1_context ctx; + mbedtls_sha1_init(&ctx); - MD5_Init(&ctx); + mbedtls_sha1_starts_ret(&ctx); std::array buffer = { 0 }; for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) { const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset); data->read(offset + bufferOffset, buffer.data(), readSize); - MD5_Update(&ctx, buffer.data(), readSize); + mbedtls_sha1_update_ret(&ctx, buffer.data(), readSize); } - MD5_Final(reinterpret_cast(result.data()), &ctx); + mbedtls_sha1_finish_ret(&ctx, result.data()); + + mbedtls_sha1_free(&ctx); return result; } - std::array sha1(prv::Provider* &data, u64 offset, size_t size) { - std::array result = { 0 }; + std::array sha224(prv::Provider* &data, u64 offset, size_t size) { + std::array result = { 0 }; - SHA_CTX ctx; + mbedtls_sha256_context ctx; + mbedtls_sha256_init(&ctx); + + mbedtls_sha256_starts_ret(&ctx, true); - SHA1_Init(&ctx); std::array buffer = { 0 }; for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) { const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset); data->read(offset + bufferOffset, buffer.data(), readSize); - SHA1_Update(&ctx, buffer.data(), readSize); + mbedtls_sha256_update_ret(&ctx, buffer.data(), readSize); } - SHA1_Final(reinterpret_cast(result.data()), &ctx); + mbedtls_sha256_finish_ret(&ctx, result.data()); + + mbedtls_sha256_free(&ctx); return result; } - std::array sha224(prv::Provider* &data, u64 offset, size_t size) { - std::array result = { 0 }; + std::array sha256(prv::Provider* &data, u64 offset, size_t size) { + std::array result = { 0 }; - SHA256_CTX ctx; + mbedtls_sha256_context ctx; + mbedtls_sha256_init(&ctx); - SHA224_Init(&ctx); + mbedtls_sha256_starts_ret(&ctx, false); std::array buffer = { 0 }; for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) { const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset); data->read(offset + bufferOffset, buffer.data(), readSize); - SHA224_Update(&ctx, buffer.data(), readSize); + mbedtls_sha256_update_ret(&ctx, buffer.data(), readSize); } - SHA224_Final(reinterpret_cast(result.data()), &ctx); + mbedtls_sha256_finish_ret(&ctx, result.data()); + + mbedtls_sha256_free(&ctx); return result; } - std::array sha256(prv::Provider* &data, u64 offset, size_t size) { - std::array result = { 0 }; + std::array sha384(prv::Provider* &data, u64 offset, size_t size) { + std::array result = { 0 }; - SHA256_CTX ctx; + mbedtls_sha512_context ctx; + mbedtls_sha512_init(&ctx); - SHA256_Init(&ctx); + mbedtls_sha512_starts_ret(&ctx, true); std::array buffer = { 0 }; for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) { const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset); data->read(offset + bufferOffset, buffer.data(), readSize); - SHA256_Update(&ctx, buffer.data(), readSize); + mbedtls_sha512_update_ret(&ctx, buffer.data(), readSize); } - SHA256_Final(reinterpret_cast(result.data()), &ctx); + mbedtls_sha512_finish_ret(&ctx, result.data()); + + mbedtls_sha512_free(&ctx); return result; } - std::array sha384(prv::Provider* &data, u64 offset, size_t size) { - std::array result = { 0 }; + std::array sha512(prv::Provider* &data, u64 offset, size_t size) { + std::array result = { 0 }; - SHA512_CTX ctx; + mbedtls_sha512_context ctx; + mbedtls_sha512_init(&ctx); - SHA384_Init(&ctx); + mbedtls_sha512_starts_ret(&ctx, false); std::array buffer = { 0 }; for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) { const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset); data->read(offset + bufferOffset, buffer.data(), readSize); - SHA384_Update(&ctx, buffer.data(), readSize); + mbedtls_sha512_update_ret(&ctx, buffer.data(), readSize); } - SHA384_Final(reinterpret_cast(result.data()), &ctx); + mbedtls_sha512_finish_ret(&ctx, result.data()); - return result; - } - - std::array sha512(prv::Provider* &data, u64 offset, size_t size) { - std::array result = { 0 }; - - SHA512_CTX ctx; - - SHA512_Init(&ctx); - - std::array buffer = { 0 }; - for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) { - const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset); - data->read(offset + bufferOffset, buffer.data(), readSize); - SHA512_Update(&ctx, buffer.data(), readSize); - } - - SHA512_Final(reinterpret_cast(result.data()), &ctx); + mbedtls_sha512_free(&ctx); return result; } @@ -221,7 +221,8 @@ namespace hex { size_t outputSize = (3 * input.size()) / 4; std::vector output(outputSize + 1, 0x00); - if (EVP_DecodeBlock(output.data(), reinterpret_cast(input.data()), input.size()) != outputSize) + size_t written = 0; + if (mbedtls_base64_decode(output.data(), output.size(), &written, reinterpret_cast(input.data()), input.size())) return { }; return output; @@ -231,7 +232,8 @@ namespace hex { size_t outputSize = 4 * ((input.size() + 2) / 3); std::vector output(outputSize + 1, 0x00); - if (EVP_EncodeBlock(output.data(), reinterpret_cast(input.data()), input.size()) != outputSize) + size_t written = 0; + if (mbedtls_base64_encode(output.data(), output.size(), &written, reinterpret_cast(input.data()), input.size())) return { }; return output; diff --git a/source/views/view_hashes.cpp b/source/views/view_hashes.cpp index 848cabde2..851288d94 100644 --- a/source/views/view_hashes.cpp +++ b/source/views/view_hashes.cpp @@ -32,9 +32,10 @@ namespace hex { } - static void formatBigHexInt(auto dataArray, char *buffer, size_t bufferSize) { + template + static void formatBigHexInt(std::array dataArray, char *buffer, size_t bufferSize) { for (int i = 0; i < dataArray.size(); i++) - snprintf(buffer + 8 * i, bufferSize - 8 * i, "%08X", hex::changeEndianess(dataArray[i], std::endian::big)); + snprintf(buffer + 2 * i, bufferSize - 2 * i, "%02X", dataArray[i]); } void ViewHashes::drawContent() { @@ -83,7 +84,7 @@ namespace hex { static u16 result = 0; if (this->m_shouldInvalidate) - result = crc16(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1, polynomial, init); + result = crypt::crc16(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1, polynomial, init); char buffer[sizeof(result) * 2 + 1]; snprintf(buffer, sizeof(buffer), "%04X", result); @@ -108,7 +109,7 @@ namespace hex { static u32 result = 0; if (this->m_shouldInvalidate) - result = crc32(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1, polynomial, init); + result = crypt::crc32(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1, polynomial, init); char buffer[sizeof(result) * 2 + 1]; snprintf(buffer, sizeof(buffer), "%08X", result); @@ -118,12 +119,12 @@ namespace hex { ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly); } break; - case 2: // MD4 + case 2: // MD5 { - static std::array result; + static std::array result = { 0 }; if (this->m_shouldInvalidate) - result = md4(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); + result = crypt::md5(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); char buffer[sizeof(result) * 2 + 1]; formatBigHexInt(result, buffer, sizeof(buffer)); @@ -134,12 +135,12 @@ namespace hex { ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly); } break; - case 3: // MD5 + case 3: // SHA-1 { - static std::array result = { 0 }; + static std::array result = { 0 }; if (this->m_shouldInvalidate) - result = md5(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); + result = crypt::sha1(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); char buffer[sizeof(result) * 2 + 1]; formatBigHexInt(result, buffer, sizeof(buffer)); @@ -150,12 +151,12 @@ namespace hex { ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly); } break; - case 4: // SHA-1 + case 4: // SHA-224 { - static std::array result = { 0 }; + static std::array result = { 0 }; if (this->m_shouldInvalidate) - result = sha1(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); + result = crypt::sha224(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); char buffer[sizeof(result) * 2 + 1]; formatBigHexInt(result, buffer, sizeof(buffer)); @@ -166,12 +167,12 @@ namespace hex { ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly); } break; - case 5: // SHA-224 + case 5: // SHA-256 { - static std::array result = { 0 }; + static std::array result; if (this->m_shouldInvalidate) - result = sha224(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); + result = crypt::sha256(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); char buffer[sizeof(result) * 2 + 1]; formatBigHexInt(result, buffer, sizeof(buffer)); @@ -182,12 +183,12 @@ namespace hex { ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly); } break; - case 6: // SHA-256 + case 6: // SHA-384 { - static std::array result; + static std::array result; if (this->m_shouldInvalidate) - result = sha256(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); + result = crypt::sha384(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); char buffer[sizeof(result) * 2 + 1]; formatBigHexInt(result, buffer, sizeof(buffer)); @@ -198,28 +199,12 @@ namespace hex { ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly); } break; - case 7: // SHA-384 + case 7: // SHA-512 { - static std::array result; + static std::array result; if (this->m_shouldInvalidate) - result = sha384(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); - - char buffer[sizeof(result) * 2 + 1]; - formatBigHexInt(result, buffer, sizeof(buffer)); - - ImGui::NewLine(); - ImGui::TextUnformatted("Result"); - ImGui::Separator(); - ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly); - } - break; - case 8: // SHA-512 - { - static std::array result; - - if (this->m_shouldInvalidate) - result = sha512(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); + result = crypt::sha512(provider, this->m_hashRegion[0], this->m_hashRegion[1] - this->m_hashRegion[0] + 1); char buffer[sizeof(result) * 2 + 1]; formatBigHexInt(result, buffer, sizeof(buffer)); diff --git a/source/views/view_hexeditor.cpp b/source/views/view_hexeditor.cpp index 3bf2a143b..563563bbf 100644 --- a/source/views/view_hexeditor.cpp +++ b/source/views/view_hexeditor.cpp @@ -367,7 +367,7 @@ namespace hex { this->loadFromFile(path, base64); if (!base64.empty()) { - this->m_dataToSave = decode64(base64); + this->m_dataToSave = crypt::decode64(base64); if (this->m_dataToSave.empty()) View::showErrorPopup("File is not in a valid Base64 format!");