From a6a4f0fc5b628811499a9163a5a4b487041f9c36 Mon Sep 17 00:00:00 2001 From: Floris Bos Date: Tue, 29 Sep 2020 19:56:12 +0200 Subject: [PATCH] Mac: use system hash functions May perform better under emulation --- CMakeLists.txt | 2 +- acceleratedcryptographichash.h | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 566b16d..38d9bfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ set(HEADERS config.h imagewriter.h networkaccessmanagerfactory.h nan.h drivelist # Add dependencies if (APPLE) set_source_files_properties("icons/rpi-imager.icns" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") - set(DEPENDENCIES mac/macfile.cpp mac/macfile.h dependencies/mountutils/src/darwin/functions.cpp + set(DEPENDENCIES acceleratedcryptographichash.cpp mac/macfile.cpp mac/macfile.h dependencies/mountutils/src/darwin/functions.cpp dependencies/drivelist/src/darwin/list.mm dependencies/drivelist/src/darwin/REDiskList.m icons/rpi-imager.icns) enable_language(OBJC C) elseif (UNIX) diff --git a/acceleratedcryptographichash.h b/acceleratedcryptographichash.h index 598dfa6..fa917e2 100644 --- a/acceleratedcryptographichash.h +++ b/acceleratedcryptographichash.h @@ -9,10 +9,15 @@ #include #ifdef Q_OS_DARWIN -typedef QCryptographicHash AcceleratedCryptographicHash; +#include +#define SHA256_CTX CC_SHA256_CTX +#define SHA256_DIGEST_LENGTH CC_SHA256_DIGEST_LENGTH +#define SHA256_Init CC_SHA256_Init +#define SHA256_Update CC_SHA256_Update +#define SHA256_Final CC_SHA256_Final #else - #include "openssl/sha.h" +#endif class AcceleratedCryptographicHash { @@ -27,5 +32,4 @@ protected: SHA256_CTX _sha256; }; -#endif #endif // ACCELERATEDCRYPTOGRAPHICHASH_H