diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-03-20 10:54:18 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-03-21 18:40:36 +0100 |
commit | c513d4fe31ebc8eb6f8976bba621e3187dc48b0c (patch) | |
tree | 47438831ff02d86a49603b0b68eeb1f438f59f87 /src | |
parent | bd7e304d486de1740b08fbc4f67359a5ef650706 (diff) |
QMessageAuthenticationCode: have setKey() call initMessageHash()
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 <fabian.kosmale@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qcryptographichash.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
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(); |