// misc.cpp - written and placed in the public domain by Wei Dai #include "pch.h" #ifndef CRYPTOPP_IMPORTS #include "misc.h" #include "words.h" #include "trap.h" #include #if defined(CRYPTOPP_MEMALIGN_AVAILABLE) || defined(CRYPTOPP_MM_MALLOC_AVAILABLE) || defined(QNX) #include #endif NAMESPACE_BEGIN(CryptoPP) // Vectorization at -O3 requires IsStrictAligned for GCC 4.8 and above with xorbuf // and VerifyBufsEqual. With vectorization, GCC generates a `vmovdqa` instruction. The // instruction is sensitive to unaligned data due to XMM register use. void xorbuf(byte *buf, const byte *mask, size_t count) { size_t i; if (IsAligned(buf) && IsAligned(mask)) { if (!CRYPTOPP_BOOL_SLOW_WORD64 && IsStrictAligned(buf) && IsStrictAligned(mask)) { CRYPTOPP_ASSERT(IsAlignedOn(buf, GetStrictAlignmentOf())); CRYPTOPP_ASSERT(IsAlignedOn(mask, GetStrictAlignmentOf())); for (i=0; i(output) && IsAligned(input) && IsAligned(mask)) { if (!CRYPTOPP_BOOL_SLOW_WORD64 && IsStrictAligned(output) && IsStrictAligned(input) && IsStrictAligned(mask)) { CRYPTOPP_ASSERT(IsAlignedOn(output, GetStrictAlignmentOf())); CRYPTOPP_ASSERT(IsAlignedOn(input, GetStrictAlignmentOf())); CRYPTOPP_ASSERT(IsAlignedOn(mask, GetStrictAlignmentOf())); for (i=0; i(buf) && IsAligned(mask)) { word32 acc32 = 0; if (!CRYPTOPP_BOOL_SLOW_WORD64 && IsStrictAligned(buf) && IsStrictAligned(mask)) { CRYPTOPP_ASSERT(IsAlignedOn(buf, GetStrictAlignmentOf())); CRYPTOPP_ASSERT(IsAlignedOn(mask, GetStrictAlignmentOf())); word64 acc64 = 0; for (i=0; i>32); } for (i=0; i>8) | byte(acc32>>16) | byte(acc32>>24); } for (i=0; i