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>
This commit is contained in:
parent
bd7e304d48
commit
c513d4fe31
@ -1352,6 +1352,8 @@ void QMessageAuthenticationCodePrivate::setKey(QByteArrayView newKey) noexcept
|
|||||||
|
|
||||||
if (key.size() < blockSize)
|
if (key.size() < blockSize)
|
||||||
key.resize(blockSize, '\0');
|
key.resize(blockSize, '\0');
|
||||||
|
|
||||||
|
initMessageHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1414,7 +1416,6 @@ QMessageAuthenticationCode::QMessageAuthenticationCode(QCryptographicHash::Algor
|
|||||||
: d(new QMessageAuthenticationCodePrivate(method))
|
: d(new QMessageAuthenticationCodePrivate(method))
|
||||||
{
|
{
|
||||||
d->setKey(key);
|
d->setKey(key);
|
||||||
d->initMessageHash();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1503,7 +1504,6 @@ void QMessageAuthenticationCode::setKey(QByteArrayView key) noexcept
|
|||||||
{
|
{
|
||||||
d->messageHash.reset();
|
d->messageHash.reset();
|
||||||
d->setKey(key);
|
d->setKey(key);
|
||||||
d->initMessageHash();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1594,7 +1594,6 @@ QByteArray QMessageAuthenticationCode::hash(QByteArrayView message, QByteArrayVi
|
|||||||
{
|
{
|
||||||
QMessageAuthenticationCodePrivate mac(method);
|
QMessageAuthenticationCodePrivate mac(method);
|
||||||
mac.setKey(key);
|
mac.setKey(key);
|
||||||
mac.initMessageHash();
|
|
||||||
mac.messageHash.addData(message);
|
mac.messageHash.addData(message);
|
||||||
mac.finalizeUnchecked();
|
mac.finalizeUnchecked();
|
||||||
return mac.messageHash.resultView().toByteArray();
|
return mac.messageHash.resultView().toByteArray();
|
||||||
|
Loading…
Reference in New Issue
Block a user