From 039db17da7880692ed0e808d9a002fbc9e33f3c5 Mon Sep 17 00:00:00 2001 From: Asen Kovachev Date: Fri, 4 May 2018 03:12:34 +0300 Subject: [PATCH] Add CRYPTOPP_ASSERT to match Keccak and SHA3 (#654) As described in https://github.com/weidai11/cryptopp/issues/652 for consistency we should add assert in all hash transformations. The expectation is to have a good pointer and a non-0 length or a null pointer and 0-length. --- iterhash.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/iterhash.cpp b/iterhash.cpp index bf287164..33a697a5 100644 --- a/iterhash.cpp +++ b/iterhash.cpp @@ -12,6 +12,7 @@ NAMESPACE_BEGIN(CryptoPP) template void IteratedHashBase::Update(const byte *input, size_t len) { + CRYPTOPP_ASSERT((input && len) || !(input || len)); HashWordType oldCountLo = m_countLo, oldCountHi = m_countHi; if ((m_countLo = oldCountLo + HashWordType(len)) < oldCountLo) m_countHi++; // carry from low to high