diff --git a/cryptest_bds.bdsproj b/cryptest_bds.bdsproj index 80cba636..2d5fa32e 100755 --- a/cryptest_bds.bdsproj +++ b/cryptest_bds.bdsproj @@ -14,7 +14,7 @@ - + @@ -235,11 +235,11 @@ - v 50 + v 66 True . - + D:\cvs\c5\Debug_Build\cryptest_bds.exe diff --git a/cryptlib_bds.bdsproj b/cryptlib_bds.bdsproj index 137f0427..8c9dfa05 100755 --- a/cryptlib_bds.bdsproj +++ b/cryptlib_bds.bdsproj @@ -14,7 +14,7 @@ - + @@ -45,14 +45,19 @@ + + + + + @@ -70,6 +75,10 @@ + + + + @@ -86,10 +95,14 @@ + + + + @@ -227,7 +240,6 @@ - @@ -241,7 +253,6 @@ - @@ -267,7 +278,6 @@ - @@ -296,6 +306,10 @@ + + + + diff --git a/hrtimer.cpp b/hrtimer.cpp index 71c54927..906ec4a0 100644 --- a/hrtimer.cpp +++ b/hrtimer.cpp @@ -4,6 +4,7 @@ #include "hrtimer.h" #include "misc.h" #include // for NULL +#include #if defined(CRYPTOPP_WIN32_AVAILABLE) #include diff --git a/panama.cpp b/panama.cpp index a60e1670..6fecd9bf 100644 --- a/panama.cpp +++ b/panama.cpp @@ -359,15 +359,16 @@ void Panama::Iterate(size_t count, const word32 *p, word32 *z, const word32 * m_state[17] = bstart; } +namespace Weak { template -size_t Weak::PanamaHash::HashMultipleBlocks(const word32 *input, size_t length) +size_t PanamaHash::HashMultipleBlocks(const word32 *input, size_t length) { this->Iterate(length / this->BLOCKSIZE, input); return length % this->BLOCKSIZE; } template -void Weak::PanamaHash::TruncatedFinal(byte *hash, size_t size) +void PanamaHash::TruncatedFinal(byte *hash, size_t size) { this->ThrowIfInvalidTruncatedSize(size); @@ -384,6 +385,7 @@ void Weak::PanamaHash::TruncatedFinal(byte *hash, size_t size) this->Restart(); // reinit for next use } +} template void PanamaCipherPolicy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) diff --git a/secblock.h b/secblock.h index 0bc53243..6ba06567 100644 --- a/secblock.h +++ b/secblock.h @@ -116,17 +116,9 @@ public: CallNewHandler(); #ifdef CRYPTOPP_NO_ALIGNED_ALLOC - assert(IsAlignedOn(p, 8)); - if (IsAlignedOn(p, 16)) - { - p += 16/sizeof(T); - ((int *)p)[-1] = 16; - } - else - { - p += 8/sizeof(T); - ((int *)p)[-1] = 8; - } + size_t adjustment = 16-((size_t)p%16); + p += adjustment; + p[-1] = (byte)adjustment; #endif assert(IsAlignedOn(p, 16)); @@ -148,7 +140,7 @@ public: #ifdef CRYPTOPP_MM_MALLOC_AVAILABLE _mm_free(p); #elif defined(CRYPTOPP_NO_ALIGNED_ALLOC) - p = ((byte *)p) - ((int *)p)[-1]/sizeof(T); + p = (byte *)p - ((byte *)p)[-1]; free(p); #else free(p); @@ -269,9 +261,13 @@ public: size_type max_size() const {return STDMAX(m_fallbackAllocator.max_size(), S);} private: +#ifdef __BORLANDC__ + 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]; +#endif A m_fallbackAllocator; bool m_allocated; }; @@ -286,7 +282,7 @@ public: typedef typename A::const_pointer const_iterator; typedef typename A::size_type size_type; - explicit SecBlock(size_type size=0) + explicit SecBlock(size_type size=0) : m_size(size) {m_ptr = m_alloc.allocate(size, NULL);} SecBlock(const SecBlock &t) : m_size(t.m_size) {m_ptr = m_alloc.allocate(m_size, NULL); memcpy_s(m_ptr, m_size*sizeof(T), t.m_ptr, m_size*sizeof(T));} diff --git a/vmac.cpp b/vmac.cpp index 34cb8bda..67f0074e 100755 --- a/vmac.cpp +++ b/vmac.cpp @@ -13,12 +13,17 @@ NAMESPACE_BEGIN(CryptoPP) #endif #define VMAC_BOOL_WORD128 (defined(CRYPTOPP_WORD128_AVAILABLE) && !defined(CRYPTOPP_X64_ASM_AVAILABLE)) - +#ifdef __BORLANDC__ +#define const // Turbo C++ 2006 workaround +#endif static const word64 p64 = W64LIT(0xfffffffffffffeff); /* 2^64 - 257 prime */ static const word64 m62 = W64LIT(0x3fffffffffffffff); /* 62-bit mask */ static const word64 m63 = W64LIT(0x7fffffffffffffff); /* 63-bit mask */ static const word64 m64 = W64LIT(0xffffffffffffffff); /* 64-bit mask */ static const word64 mpoly = W64LIT(0x1fffffff1fffffff); /* Poly key mask */ +#ifdef __BORLANDC__ +#undef const +#endif #if VMAC_BOOL_WORD128 static const word128 m126 = (word128(m62)<<64)|m64; /* 126-bit mask */ #endif @@ -55,7 +60,7 @@ void VMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, con } /* Fill poly key */ - in[0] = 0xC0; + in[0] = 0xC0; in[15] = 0; for (i = 0; i <= (size_t)m_is128; i++) { @@ -68,14 +73,15 @@ void VMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, con /* Fill ip key */ in[0] = 0xE0; in[15] = 0; + word64 *l3Key = m_l3Key(); for (i = 0; i <= (size_t)m_is128; i++) do { cipher.ProcessBlock(in, out.BytePtr()); - m_l3Key()[i*2+0] = GetWord(true, BIG_ENDIAN_ORDER, out.BytePtr()); - m_l3Key()[i*2+1] = GetWord(true, BIG_ENDIAN_ORDER, out.BytePtr()+8); + l3Key[i*2+0] = GetWord(true, BIG_ENDIAN_ORDER, out.BytePtr()); + l3Key[i*2+1] = GetWord(true, BIG_ENDIAN_ORDER, out.BytePtr()+8); in[15]++; - } while ((m_l3Key()[0] >= p64) || (m_l3Key()[1] >= p64)); + } while ((l3Key[i*2+0] >= p64) || (l3Key[i*2+1] >= p64)); m_padCached = false; Resynchronize(GetIVAndThrowIfInvalid(params));