From c513d4fe31ebc8eb6f8976bba621e3187dc48b0c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 20 Mar 2023 10:54:18 +0100 Subject: QMessageAuthenticationCode: have setKey() call initMessageHash() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All callers of Private::setKey() follow the call with one to initMessageHash(), so move the call into setKey(). We can't remove initMessageHash(), because reset() still needs to call it without a setKey(). Pick-to: 6.5 Change-Id: I1fc8cd5cda90f1595cedcc323a4cee8baa7ce6a5 Reviewed-by: Fabian Kosmale Reviewed-by: MÃ¥rten Nordheim --- src/corelib/tools/qcryptographichash.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 72c13d247b..dbb2448c1f 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -1352,6 +1352,8 @@ void QMessageAuthenticationCodePrivate::setKey(QByteArrayView newKey) noexcept if (key.size() < blockSize) key.resize(blockSize, '\0'); + + initMessageHash(); } /*! @@ -1414,7 +1416,6 @@ QMessageAuthenticationCode::QMessageAuthenticationCode(QCryptographicHash::Algor : d(new QMessageAuthenticationCodePrivate(method)) { d->setKey(key); - d->initMessageHash(); } /*! @@ -1503,7 +1504,6 @@ void QMessageAuthenticationCode::setKey(QByteArrayView key) noexcept { d->messageHash.reset(); d->setKey(key); - d->initMessageHash(); } /*! @@ -1594,7 +1594,6 @@ QByteArray QMessageAuthenticationCode::hash(QByteArrayView message, QByteArrayVi { QMessageAuthenticationCodePrivate mac(method); mac.setKey(key); - mac.initMessageHash(); mac.messageHash.addData(message); mac.finalizeUnchecked(); return mac.messageHash.resultView().toByteArray(); -- cgit v1.2.3