Mac: use system hash functions

May perform better under emulation
This commit is contained in:
Floris Bos 2020-09-29 19:56:12 +02:00
parent 65f9b9c1fd
commit a6a4f0fc5b
2 changed files with 8 additions and 4 deletions

View file

@ -25,7 +25,7 @@ set(HEADERS config.h imagewriter.h networkaccessmanagerfactory.h nan.h drivelist
# Add dependencies # Add dependencies
if (APPLE) if (APPLE)
set_source_files_properties("icons/rpi-imager.icns" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") 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) dependencies/drivelist/src/darwin/list.mm dependencies/drivelist/src/darwin/REDiskList.m icons/rpi-imager.icns)
enable_language(OBJC C) enable_language(OBJC C)
elseif (UNIX) elseif (UNIX)

View file

@ -9,10 +9,15 @@
#include <QCryptographicHash> #include <QCryptographicHash>
#ifdef Q_OS_DARWIN #ifdef Q_OS_DARWIN
typedef QCryptographicHash AcceleratedCryptographicHash; #include <CommonCrypto/CommonDigest.h>
#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 #else
#include "openssl/sha.h" #include "openssl/sha.h"
#endif
class AcceleratedCryptographicHash class AcceleratedCryptographicHash
{ {
@ -27,5 +32,4 @@ protected:
SHA256_CTX _sha256; SHA256_CTX _sha256;
}; };
#endif
#endif // ACCELERATEDCRYPTOGRAPHICHASH_H #endif // ACCELERATEDCRYPTOGRAPHICHASH_H