Fix AES and X86 compile on Solaris

pull/326/head
Jeffrey Walton 2016-09-30 09:31:23 -04:00
parent 2efedfb5ab
commit 2b328e8f8b
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 10 additions and 11 deletions

View File

@ -1250,7 +1250,7 @@ inline size_t AESNI_AdvancedProcessBlocks(F1 func1, F4 func4, MAYBE_CONST __m128
} }
#endif #endif
#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM) #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86
struct Locals struct Locals
{ {
word32 subkeys[4*12], workspace[8]; word32 subkeys[4*12], workspace[8];
@ -1260,9 +1260,11 @@ struct Locals
size_t regSpill, lengthAndCounterFlag, keysBegin; size_t regSpill, lengthAndCounterFlag, keysBegin;
}; };
const size_t Rijndael::Enc::aliasPageSize = 4096; const size_t s_aliasPageSize = 4096;
const size_t Rijndael::Enc::aliasBlockSize = 256; const size_t s_aliasBlockSize = 256;
const size_t Rijndael::Enc::sizeToAllocate = aliasPageSize + aliasBlockSize + sizeof(Locals); const size_t s_sizeToAllocate = s_aliasPageSize + s_aliasBlockSize + sizeof(Locals);
Rijndael::Enc::Enc() : m_aliasBlock(s_sizeToAllocate) { }
#endif #endif
size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const
@ -1278,15 +1280,15 @@ size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xo
if (length < BLOCKSIZE) if (length < BLOCKSIZE)
return length; return length;
static const byte *zeros = (const byte*)(Te+aliasBlockSize); static const byte *zeros = (const byte*)(Te+256);
byte *space = NULL, *originalSpace = const_cast<byte*>(m_aliasBlock.data()); byte *space = NULL, *originalSpace = const_cast<byte*>(m_aliasBlock.data());
// round up to nearest 256 byte boundary // round up to nearest 256 byte boundary
space = originalSpace + (aliasBlockSize - (uintptr_t)originalSpace % aliasBlockSize) % aliasBlockSize; space = originalSpace + (s_aliasBlockSize - (uintptr_t)originalSpace % s_aliasBlockSize) % s_aliasBlockSize;
while (AliasedWithTable(space, space + sizeof(Locals))) while (AliasedWithTable(space, space + sizeof(Locals)))
{ {
space += 256; space += 256;
CRYPTOPP_ASSERT(space < (originalSpace + aliasPageSize)); CRYPTOPP_ASSERT(space < (originalSpace + s_aliasPageSize));
} }
size_t increment = BLOCKSIZE; size_t increment = BLOCKSIZE;

View File

@ -56,12 +56,9 @@ class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentat
public: public:
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86
Enc() : m_aliasBlock(sizeToAllocate) {} Enc();
size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const; size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
private: private:
static const size_t aliasPageSize;
static const size_t aliasBlockSize;
static const size_t sizeToAllocate;
SecByteBlock m_aliasBlock; SecByteBlock m_aliasBlock;
#endif #endif
}; };