diff options
-rw-r--r-- | misc.cpp | 4 | ||||
-rw-r--r-- | misc.h | 11 |
2 files changed, 8 insertions, 7 deletions
@@ -101,12 +101,12 @@ bool VerifyBufsEqual(const byte *buf, const byte *mask, size_t count) {
CRYPTOPP_ASSERT(buf != NULLPTR);
CRYPTOPP_ASSERT(mask != NULLPTR);
- CRYPTOPP_ASSERT(count > 0);
+ // CRYPTOPP_ASSERT(count > 0);
size_t i=0;
byte acc8 = 0;
- if (IsAligned<word32>(buf) && IsAligned<word32>(mask))
+ if (IsAligned<word32>(buf) && IsAligned<word32>(mask) && count)
{
word32 acc32 = 0;
if (!CRYPTOPP_BOOL_SLOW_WORD64 && IsAligned<word64>(buf) && IsAligned<word64>(mask))
@@ -936,11 +936,12 @@ CRYPTOPP_DLL void CRYPTOPP_API xorbuf(byte *output, const byte *input, const byt /// \param buf1 the first buffer
/// \param buf2 the second buffer
/// \param count the size of the buffers, in bytes
-/// \details The function effectively performs an XOR of the elements in two equally sized
-/// buffers and retruns a result based on the XOR operation. The function is near
-/// constant-time because CPU micro-code timings could affect the "constant-ness".
-/// Calling code is responsible for mitigating timing attacks if the buffers are not
-/// equally sized.
+/// \details VerifyBufsEqual performs an XOR of the elements in two equally sized
+/// buffers and retruns a result based on the XOR operation. A count of 0 returns
+/// true because two empty buffers are considered equal.
+/// \details The function is near constant-time because CPU micro-code timings could
+/// affect the "constant-ness". Calling code is responsible for mitigating timing
+/// attacks if the buffers are not equally sized.
/// \sa ModPowerOf2
CRYPTOPP_DLL bool CRYPTOPP_API VerifyBufsEqual(const byte *buf1, const byte *buf2, size_t count);
|