From 54aedff72fe9c07f191044afe7f489ee1e481171 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 Feb 2023 08:00:18 +0100 Subject: [PATCH] QMessageAuthenticationCode: use QCryptographicHashPrivate in finalizeUnchecked() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... basically inlining static QCH::hash(), which, however, accepts only one piece of data, while we have two. Avoids the memory allocation of the QCH d-pointer. The toByteArray() is now the only memory allocation left in finalizeUnchecked(), and will be removed in a subsequent commit. Change-Id: I7549d6e1c116a4cdc29dac74b867dfa6647022a0 Reviewed-by: Thiago Macieira (cherry picked from commit d235953a82bf8df5a6011dcf55331e287f0e6e65) Reviewed-by: MÃ¥rten Nordheim --- src/corelib/tools/qcryptographichash.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 0a9b6d5d622..32580113237 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -1151,11 +1151,12 @@ void QMessageAuthenticationCodePrivate::finalizeUnchecked() for (int i = 0; i < blockSize; ++i) oKeyPad[i] = keyData[i] ^ 0x5c; - QCryptographicHash hash(method); + QCryptographicHashPrivate hash(method); hash.addData(oKeyPad); hash.addData(hashedMessage); + hash.finalizeUnchecked(); - result = hash.result(); + result = hash.resultView().toByteArray(); } /*!