diff --git a/src/Config.h b/src/Config.h index b10e69c2..837c49a0 100644 --- a/src/Config.h +++ b/src/Config.h @@ -35,7 +35,7 @@ #define VER_LAMEXP_MINOR_LO 5 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 2 -#define VER_LAMEXP_BUILD 1945 +#define VER_LAMEXP_BUILD 1948 #define VER_LAMEXP_CONFG 1934 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/FileHash.cpp b/src/FileHash.cpp index f3ed1507..8d6a08ce 100644 --- a/src/FileHash.cpp +++ b/src/FileHash.cpp @@ -23,7 +23,7 @@ #include "FileHash.h" //MUtils -#include +#include #include static const char *g_blnk = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; @@ -32,38 +32,28 @@ static const char *g_salt = "ee9f7bdabc170763d2200a7e3030045aafe380011aefc1730e5 QByteArray FileHash::computeHash(QFile &file) { - QByteArray hash = QByteArray::fromHex(g_blnk).toHex(); + QByteArray result; if(file.isOpen() && file.reset()) { - MUtils::Hash::Keccak keccak; + QScopedPointer hash(MUtils::Hash::create(MUtils::Hash::HASH_KECCAK_384)); const QByteArray data = file.readAll(); if (data.size() >= 16) { const QByteArray seed = QByteArray::fromHex(g_seed); const QByteArray salt = QByteArray::fromHex(g_salt); - if (keccak.init(MUtils::Hash::Keccak::hb384)) + + bool okay[3]; + okay[0] = hash->update(seed); + okay[1] = hash->update(data); + okay[2] = hash->update(salt); + + if (okay[0] && okay[1] && okay[2]) { - bool ok = true; - ok = ok && keccak.addData(seed); - ok = ok && keccak.addData(data); - ok = ok && keccak.addData(salt); - if (ok) - { - const QByteArray digest = keccak.finalize(); - if (!digest.isEmpty()) hash = digest.toHex(); - } + result = hash->digest(true); } } } - return hash; -} - -void FileHash::selfTest(void) -{ - if(!MUtils::Hash::Keccak::selfTest()) - { - MUTILS_THROW("QKeccakHash self-test has failed!"); - } + return result.isEmpty() ? QByteArray::fromHex(g_blnk).toHex() : result; } diff --git a/src/FileHash.h b/src/FileHash.h index f0d5c046..87daf710 100644 --- a/src/FileHash.h +++ b/src/FileHash.h @@ -25,13 +25,7 @@ #include #include -class FileHash +namespace FileHash { -public: - static QByteArray computeHash(QFile &file); - static void selfTest(void); -private: - FileHash() {} - ~FileHash() {}; -}; - + QByteArray computeHash(QFile &file); +} diff --git a/src/Main.cpp b/src/Main.cpp index 4e24121c..8d546cd9 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -209,9 +209,10 @@ static int lamexp_main(int &argc, char **argv) const MUtils::CPUFetaures::cpu_info_t cpuFeatures = MUtils::CPUFetaures::detect(); qDebug(" CPU vendor id : %s (Intel=%s)", cpuFeatures.idstr, MUTILS_BOOL2STR(cpuFeatures.vendor & MUtils::CPUFetaures::VENDOR_INTEL)); qDebug("CPU brand string : %s", cpuFeatures.brand); - qDebug(" CPU signature : Family=%d Model=%d Stepping=%d", cpuFeatures.family, cpuFeatures.model, cpuFeatures.stepping); - qDebug("CPU capabilities : CMOV=%s MMX=%s SSE=%s SSE2=%s SSE3=%s SSSE3=%s", MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_CMOV), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_MMX), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE2), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE3), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSSE3)); - qDebug("CPU capabilities : SSE4.1=%s SSE4.2=%s AVX=%s EM64T/AMD64=%s", MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE4), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE42), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_AVX), MUTILS_BOOL2STR(cpuFeatures.x64)); + qDebug(" CPU signature : Family=%d, Model=%d, Stepping=%d", cpuFeatures.family, cpuFeatures.model, cpuFeatures.stepping); + qDebug("CPU architecture : %s", cpuFeatures.x64 ? "x64 (64-Bit)" : "x86 (32-Bit)"); + qDebug("CPU capabilities : CMOV=%s, MMX=%s, SSE=%s, SSE2=%s, SSE3=%s, SSSE3=%s", MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_CMOV), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_MMX), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE2), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE3), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSSE3)); + qDebug("CPU capabilities : SSE4.1=%s, SSE4.2=%s, AVX=%s, AVX2=%s, FMA3=%s, LZCNT=%s", MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE41), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE42), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_AVX), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_AVX2), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_FMA3), MUTILS_BOOL2STR(cpuFeatures.features & MUtils::CPUFetaures::FLAG_LZCNT)); qDebug(" Number of CPU's : %d\n", cpuFeatures.count); //Initialize Qt diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp index 65fd527c..f29a4cc5 100644 --- a/src/Thread_Initialization.cpp +++ b/src/Thread_Initialization.cpp @@ -422,9 +422,6 @@ double InitializationThread::doInit(const size_t threadCount) QScopedPointer pool(new QThreadPool()); pool->setMaxThreadCount((threadCount > 0) ? threadCount : qBound(2U, cores2threads(m_cpuFeatures.count), EXPECTED_TOOL_COUNT)); - /* qWarning("Using %u threads for extraction.", pool->maxThreadCount()); */ - - FileHash::selfTest(); ExtractorTask::clearFlags(); //Start the timer @@ -741,8 +738,6 @@ void InitializationThread::selfTest(void) { const unsigned int cpu[7] = {CPU_TYPE_X86_GEN, CPU_TYPE_X86_SSE, CPU_TYPE_X86_AVX, CPU_TYPE_X64_GEN, CPU_TYPE_X64_SSE, CPU_TYPE_X64_AVX, 0 }; - FileHash::selfTest(); - for(size_t k = 0; cpu[k]; k++) { qDebug("[TEST]");