fix compile on MSVC 6
parent
df9fe81ee0
commit
d6b4e54448
6
config.h
6
config.h
|
|
@ -287,6 +287,12 @@ NAMESPACE_END
|
|||
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
|
||||
#endif
|
||||
|
||||
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
|
||||
#define CRYPTOPP_BOOL_ALIGN16_ENABLED 1
|
||||
#else
|
||||
#define CRYPTOPP_BOOL_ALIGN16_ENABLED 0
|
||||
#endif
|
||||
|
||||
// how to allocate 16-byte aligned memory (for SSE2)
|
||||
#if defined(CRYPTOPP_MSVC6PP_OR_LATER)
|
||||
#define CRYPTOPP_MM_MALLOC_AVAILABLE
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters)
|
|||
|
||||
if (test == "Encrypt" || test == "EncryptXorDigest" || test == "Resync")
|
||||
{
|
||||
static std::auto_ptr<SymmetricCipher> encryptor, decryptor;
|
||||
static member_ptr<SymmetricCipher> encryptor, decryptor;
|
||||
static std::string lastName;
|
||||
|
||||
if (name != lastName)
|
||||
|
|
|
|||
14
secblock.h
14
secblock.h
|
|
@ -98,7 +98,7 @@ public:
|
|||
if (n == 0)
|
||||
return NULL;
|
||||
|
||||
if (T_Align16 && n*sizeof(T) >= 16)
|
||||
if (CRYPTOPP_BOOL_ALIGN16_ENABLED && T_Align16 && n*sizeof(T) >= 16)
|
||||
{
|
||||
byte *p;
|
||||
#ifdef CRYPTOPP_MM_MALLOC_AVAILABLE
|
||||
|
|
@ -132,7 +132,7 @@ public:
|
|||
{
|
||||
memset_z(p, 0, n*sizeof(T));
|
||||
|
||||
if (T_Align16 && n*sizeof(T) >= 16)
|
||||
if (CRYPTOPP_BOOL_ALIGN16_ENABLED && T_Align16 && n*sizeof(T) >= 16)
|
||||
{
|
||||
#ifdef CRYPTOPP_MM_MALLOC_AVAILABLE
|
||||
_mm_free(p);
|
||||
|
|
@ -262,8 +262,8 @@ private:
|
|||
T* GetAlignedArray() {return m_array;}
|
||||
T m_array[S];
|
||||
#else
|
||||
T* GetAlignedArray() {return T_Align16 ? (T*)(((byte *)m_array) + (0-(size_t)m_array)%16) : m_array;}
|
||||
CRYPTOPP_ALIGN_DATA(8) T m_array[T_Align16 ? S+8/sizeof(T) : S];
|
||||
T* GetAlignedArray() {return (CRYPTOPP_BOOL_ALIGN16_ENABLED && T_Align16) ? (T*)(((byte *)m_array) + (0-(size_t)m_array)%16) : m_array;}
|
||||
CRYPTOPP_ALIGN_DATA(8) T m_array[(CRYPTOPP_BOOL_ALIGN16_ENABLED && T_Align16) ? S+8/sizeof(T) : S];
|
||||
#endif
|
||||
A m_fallbackAllocator;
|
||||
bool m_allocated;
|
||||
|
|
@ -401,7 +401,7 @@ public:
|
|||
void CleanNew(size_type newSize)
|
||||
{
|
||||
New(newSize);
|
||||
memset(m_ptr, 0, m_size*sizeof(T));
|
||||
memset_z(m_ptr, 0, m_size*sizeof(T));
|
||||
}
|
||||
|
||||
//! change size only if newSize > current size. contents are preserved
|
||||
|
|
@ -447,7 +447,7 @@ public:
|
|||
};
|
||||
|
||||
typedef SecBlock<byte> SecByteBlock;
|
||||
typedef SecBlock<byte, AllocatorWithCleanup<byte, CRYPTOPP_BOOL_X86 | CRYPTOPP_BOOL_X64> > AlignedSecByteBlock;
|
||||
typedef SecBlock<byte, AllocatorWithCleanup<byte, true> > AlignedSecByteBlock;
|
||||
typedef SecBlock<word> SecWordBlock;
|
||||
|
||||
//! a SecBlock with fixed size, allocated statically
|
||||
|
|
@ -458,7 +458,7 @@ public:
|
|||
explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {}
|
||||
};
|
||||
|
||||
template <class T, unsigned int S, bool T_Align16 = CRYPTOPP_BOOL_X86 | CRYPTOPP_BOOL_X64>
|
||||
template <class T, unsigned int S, bool T_Align16 = true>
|
||||
class FixedSizeAlignedSecBlock : public FixedSizeSecBlock<T, S, FixedSizeAllocatorWithCleanup<T, S, NullAllocator<T>, T_Align16> >
|
||||
{
|
||||
};
|
||||
|
|
|
|||
14
sha.cpp
14
sha.cpp
|
|
@ -272,16 +272,19 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32
|
|||
AS2( mov DATA_END, WORD_REG(di))
|
||||
AS2( mov K_END, WORD_REG(si))
|
||||
|
||||
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
|
||||
#if CRYPTOPP_BOOL_X86
|
||||
AS2( test edi, 1)
|
||||
ASJ( jnz, 2, f)
|
||||
#endif
|
||||
|
||||
AS2( movdqa xmm0, XMMWORD_PTR [WORD_REG(cx)+0*16])
|
||||
AS2( movdqa xmm1, XMMWORD_PTR [WORD_REG(cx)+1*16])
|
||||
#endif
|
||||
|
||||
#if CRYPTOPP_BOOL_X86
|
||||
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
|
||||
ASJ( jmp, 0, f)
|
||||
#endif
|
||||
ASL(2) // non-SSE2
|
||||
AS2( mov esi, ecx)
|
||||
AS2( lea edi, A(0))
|
||||
|
|
@ -291,9 +294,11 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32
|
|||
ASJ( jmp, 3, f)
|
||||
#endif
|
||||
|
||||
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
|
||||
ASL(0)
|
||||
AS2( movdqa E(0), xmm1)
|
||||
AS2( movdqa A(0), xmm0)
|
||||
#endif
|
||||
#if CRYPTOPP_BOOL_X86
|
||||
ASL(3)
|
||||
#endif
|
||||
|
|
@ -352,11 +357,11 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32
|
|||
AS2( mov AS_REG_7, STATE_SAVE)
|
||||
AS2( mov DATA_SAVE, WORD_REG(dx))
|
||||
|
||||
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
|
||||
#if CRYPTOPP_BOOL_X86
|
||||
AS2( test DWORD PTR DATA_END, 1)
|
||||
ASJ( jnz, 4, f)
|
||||
#endif
|
||||
|
||||
AS2( movdqa xmm1, XMMWORD_PTR [AS_REG_7+1*16])
|
||||
AS2( movdqa xmm0, XMMWORD_PTR [AS_REG_7+0*16])
|
||||
AS2( paddd xmm1, E(0))
|
||||
|
|
@ -365,10 +370,13 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32
|
|||
AS2( movdqa [AS_REG_7+0*16], xmm0)
|
||||
AS2( cmp WORD_REG(dx), DATA_END)
|
||||
ASJ( jl, 0, b)
|
||||
#endif
|
||||
|
||||
#if CRYPTOPP_BOOL_X86
|
||||
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
|
||||
ASJ( jmp, 5, f)
|
||||
ASL(4) // non-SSE2
|
||||
#endif
|
||||
AS2( add [AS_REG_7+0*4], ecx) // A
|
||||
AS2( add [AS_REG_7+4*4], edi) // E
|
||||
AS2( mov eax, B(0))
|
||||
|
|
@ -386,7 +394,9 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32
|
|||
AS2( mov ecx, AS_REG_7d)
|
||||
AS2( cmp WORD_REG(dx), DATA_END)
|
||||
ASJ( jl, 2, b)
|
||||
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
|
||||
ASL(5)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
AS_POP_IF86(sp)
|
||||
|
|
|
|||
4
sha.h
4
sha.h
|
|
@ -17,7 +17,7 @@ public:
|
|||
typedef SHA1 SHA; // for backwards compatibility
|
||||
|
||||
//! implements the SHA-256 standard
|
||||
class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA256, 32, CRYPTOPP_BOOL_X86||CRYPTOPP_BOOL_X64>
|
||||
class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA256, 32, true>
|
||||
{
|
||||
public:
|
||||
#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
|
||||
|
|
@ -29,7 +29,7 @@ public:
|
|||
};
|
||||
|
||||
//! implements the SHA-224 standard
|
||||
class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA224, 28, CRYPTOPP_BOOL_X86||CRYPTOPP_BOOL_X64>
|
||||
class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA224, 28, true>
|
||||
{
|
||||
public:
|
||||
#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
|
||||
|
|
|
|||
Loading…
Reference in New Issue