mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2025-02-13 09:34:56 +00:00
fixed Whirlpool crash on Pentium 2 machines
This commit is contained in:
parent
2345ab6d80
commit
ae88c18bf7
4
config.h
4
config.h
@ -260,7 +260,7 @@ NAMESPACE_END
|
||||
#define CRYPTOPP_DISABLE_SSE2
|
||||
#endif
|
||||
|
||||
#if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(CRYPTOPP_MSVC6PP_OR_LATER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
|
||||
#if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
|
||||
#define CRYPTOPP_X86_ASM_AVAILABLE
|
||||
|
||||
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300)
|
||||
@ -339,6 +339,8 @@ NAMESPACE_END
|
||||
#define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
|
||||
#endif
|
||||
|
||||
#define CRYPTOPP_VERSION 552
|
||||
|
||||
// ***************** determine availability of OS features ********************
|
||||
|
||||
#ifndef NO_OS_DEPENDENCE
|
||||
|
15
cpu.cpp
15
cpu.cpp
@ -145,7 +145,7 @@ static bool TrySSE2()
|
||||
}
|
||||
|
||||
bool g_x86DetectionDone = false;
|
||||
bool g_hasSSE2 = false, g_hasSSSE3 = false, g_hasMMX = false, g_isP4 = false;
|
||||
bool g_hasISSE = false, g_hasSSE2 = false, g_hasSSSE3 = false, g_hasMMX = false, g_isP4 = false;
|
||||
word32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE;
|
||||
|
||||
void DetectX86Features()
|
||||
@ -161,6 +161,19 @@ void DetectX86Features()
|
||||
g_hasSSE2 = TrySSE2();
|
||||
g_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9));
|
||||
|
||||
if ((cpuid1[3] & (1 << 25)) != 0)
|
||||
g_hasISSE = true;
|
||||
else
|
||||
{
|
||||
word32 cpuid2[4];
|
||||
CpuId(0x080000000, cpuid2);
|
||||
if (cpuid2[0] >= 0x080000001)
|
||||
{
|
||||
CpuId(0x080000001, cpuid2);
|
||||
g_hasISSE = (cpuid2[3] & (1 << 22)) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::swap(cpuid[2], cpuid[3]);
|
||||
if (memcmp(cpuid+1, "GenuineIntel", 12) == 0)
|
||||
{
|
||||
|
11
cpu.h
11
cpu.h
@ -16,6 +16,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
||||
// these should not be used directly
|
||||
extern CRYPTOPP_DLL bool g_x86DetectionDone;
|
||||
extern CRYPTOPP_DLL bool g_hasSSE2;
|
||||
extern CRYPTOPP_DLL bool g_hasISSE;
|
||||
extern CRYPTOPP_DLL bool g_hasMMX;
|
||||
extern CRYPTOPP_DLL bool g_hasSSSE3;
|
||||
extern CRYPTOPP_DLL bool g_isP4;
|
||||
@ -26,6 +27,7 @@ CRYPTOPP_DLL bool CpuId(word32 input, word32 *output);
|
||||
|
||||
#if CRYPTOPP_BOOL_X64
|
||||
inline bool HasSSE2() {return true;}
|
||||
inline bool HasISSE() {return true;}
|
||||
inline bool HasMMX() {return true;}
|
||||
#else
|
||||
|
||||
@ -36,6 +38,13 @@ inline bool HasSSE2()
|
||||
return g_hasSSE2;
|
||||
}
|
||||
|
||||
inline bool HasISSE()
|
||||
{
|
||||
if (!g_x86DetectionDone)
|
||||
DetectX86Features();
|
||||
return g_hasISSE;
|
||||
}
|
||||
|
||||
inline bool HasMMX()
|
||||
{
|
||||
if (!g_x86DetectionDone)
|
||||
@ -79,9 +88,11 @@ inline bool IsP4() {return false;}
|
||||
// assume MMX and SSE2 if intrinsics are enabled
|
||||
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_X64
|
||||
inline bool HasSSE2() {return true;}
|
||||
inline bool HasISSE() {return true;}
|
||||
inline bool HasMMX() {return true;}
|
||||
#else
|
||||
inline bool HasSSE2() {return false;}
|
||||
inline bool HasISSE() {return false;}
|
||||
inline bool HasMMX() {return false;}
|
||||
#endif
|
||||
|
||||
|
@ -229,6 +229,7 @@ bool TestSettings()
|
||||
cout << endl;
|
||||
|
||||
bool hasMMX = HasMMX();
|
||||
bool hasISSE = HasISSE();
|
||||
bool hasSSE2 = HasSSE2();
|
||||
bool hasSSSE3 = HasSSSE3();
|
||||
bool isP4 = IsP4();
|
||||
@ -242,7 +243,7 @@ bool TestSettings()
|
||||
else
|
||||
cout << "passed: ";
|
||||
|
||||
cout << "hasMMX == " << hasMMX << ", hasSSE2 == " << hasSSE2 << ", hasSSSE3 == " << hasSSSE3 << ", isP4 == " << isP4 << ", cacheLineSize == " << cacheLineSize;
|
||||
cout << "hasMMX == " << hasMMX << ", hasISSE == " << hasISSE << ", hasSSE2 == " << hasSSE2 << ", hasSSSE3 == " << hasSSSE3 << ", isP4 == " << isP4 << ", cacheLineSize == " << cacheLineSize;
|
||||
|
||||
if (!pass)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
// whrlpool.cpp - originally modified by Kevin Springle from
|
||||
// Paulo Barreto and Vincent Rijmen's public domain code, whirlpool.c.
|
||||
// Updated to Whirlpool version 3.0, optimized and MMX version added by Wei Dai
|
||||
// Updated to Whirlpool version 3.0, optimized and SSE version added by Wei Dai
|
||||
// Any modifications are placed in the public domain
|
||||
|
||||
// This is the original introductory comment:
|
||||
@ -390,8 +390,8 @@ CRYPTOPP_ALIGN_DATA(16) static const word64 Whirlpool_C[4*256+R] CRYPTOPP_SECTIO
|
||||
// Whirlpool basic transformation. Transforms state based on block.
|
||||
void Whirlpool::Transform(word64 *digest, const word64 *block)
|
||||
{
|
||||
#if defined(CRYPTOPP_X86_ASM_AVAILABLE)
|
||||
if (HasMMX())
|
||||
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
|
||||
if (HasISSE())
|
||||
{
|
||||
// MMX version has the same structure as C version below
|
||||
#ifdef __GNUC__
|
||||
|
Loading…
x
Reference in New Issue
Block a user