diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 78ab9836a1b..09b53d4941e 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -1150,7 +1150,14 @@ void QMessageAuthenticationCodePrivate::setKey(const QByteArray &newKey) if (newKey.size() > blockSize) { messageHash.addData(newKey); messageHash.finalizeUnchecked(); - static_assert(maxHashLength() <= maxHashBlockSize()); + static_assert([] { + using A = QCryptographicHash::Algorithm; + for (int i = 0; i < A::NumAlgorithms; ++i) { + if (hashLengthInternal(A(i)) > qt_hash_block_size(A(i))) + return false; + } + return true; + }(), "this code assumes that a hash's result always fits into that hash's block size"); key = messageHash.result; messageHash.reset(); } else {