summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--misc.cpp4
-rw-r--r--misc.h11
2 files changed, 8 insertions, 7 deletions
diff --git a/misc.cpp b/misc.cpp
index cfd03828..91f1d8d0 100644
--- a/misc.cpp
+++ b/misc.cpp
@@ -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))
diff --git a/misc.h b/misc.h
index ce6fff28..a90bdb75 100644
--- a/misc.h
+++ b/misc.h
@@ -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);