Adapt for latest MUtils changes.

This commit is contained in:
LoRd_MuldeR 2016-12-26 00:58:49 +01:00
parent 96a62e7ac1
commit 13cc4c2adf
5 changed files with 20 additions and 40 deletions

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 5 #define VER_LAMEXP_MINOR_LO 5
#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 2 #define VER_LAMEXP_PATCH 2
#define VER_LAMEXP_BUILD 1945 #define VER_LAMEXP_BUILD 1948
#define VER_LAMEXP_CONFG 1934 #define VER_LAMEXP_CONFG 1934
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -23,7 +23,7 @@
#include "FileHash.h" #include "FileHash.h"
//MUtils //MUtils
#include <MUtils/Hash_Keccak.h> #include <MUtils/Hash.h>
#include <MUtils/Exception.h> #include <MUtils/Exception.h>
static const char *g_blnk = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; static const char *g_blnk = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
@ -32,38 +32,28 @@ static const char *g_salt = "ee9f7bdabc170763d2200a7e3030045aafe380011aefc1730e5
QByteArray FileHash::computeHash(QFile &file) QByteArray FileHash::computeHash(QFile &file)
{ {
QByteArray hash = QByteArray::fromHex(g_blnk).toHex(); QByteArray result;
if(file.isOpen() && file.reset()) if(file.isOpen() && file.reset())
{ {
MUtils::Hash::Keccak keccak; QScopedPointer<MUtils::Hash::Hash> hash(MUtils::Hash::create(MUtils::Hash::HASH_KECCAK_384));
const QByteArray data = file.readAll(); const QByteArray data = file.readAll();
if (data.size() >= 16) if (data.size() >= 16)
{ {
const QByteArray seed = QByteArray::fromHex(g_seed); const QByteArray seed = QByteArray::fromHex(g_seed);
const QByteArray salt = QByteArray::fromHex(g_salt); 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; result = hash->digest(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();
}
} }
} }
} }
return hash; return result.isEmpty() ? QByteArray::fromHex(g_blnk).toHex() : result;
}
void FileHash::selfTest(void)
{
if(!MUtils::Hash::Keccak::selfTest())
{
MUTILS_THROW("QKeccakHash self-test has failed!");
}
} }

View File

@ -25,13 +25,7 @@
#include <QFile> #include <QFile>
#include <QByteArray> #include <QByteArray>
class FileHash namespace FileHash
{ {
public: QByteArray computeHash(QFile &file);
static QByteArray computeHash(QFile &file); }
static void selfTest(void);
private:
FileHash() {}
~FileHash() {};
};

View File

@ -209,9 +209,10 @@ static int lamexp_main(int &argc, char **argv)
const MUtils::CPUFetaures::cpu_info_t cpuFeatures = MUtils::CPUFetaures::detect(); 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 vendor id : %s (Intel=%s)", cpuFeatures.idstr, MUTILS_BOOL2STR(cpuFeatures.vendor & MUtils::CPUFetaures::VENDOR_INTEL));
qDebug("CPU brand string : %s", cpuFeatures.brand); qDebug("CPU brand string : %s", cpuFeatures.brand);
qDebug(" CPU signature : Family=%d Model=%d Stepping=%d", cpuFeatures.family, cpuFeatures.model, cpuFeatures.stepping); 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 architecture : %s", cpuFeatures.x64 ? "x64 (64-Bit)" : "x86 (32-Bit)");
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 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); qDebug(" Number of CPU's : %d\n", cpuFeatures.count);
//Initialize Qt //Initialize Qt

View File

@ -422,9 +422,6 @@ double InitializationThread::doInit(const size_t threadCount)
QScopedPointer<QThreadPool> pool(new QThreadPool()); QScopedPointer<QThreadPool> pool(new QThreadPool());
pool->setMaxThreadCount((threadCount > 0) ? threadCount : qBound(2U, cores2threads(m_cpuFeatures.count), EXPECTED_TOOL_COUNT)); 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(); ExtractorTask::clearFlags();
//Start the timer //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 }; 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++) for(size_t k = 0; cpu[k]; k++)
{ {
qDebug("[TEST]"); qDebug("[TEST]");