QMessageAuthenticationCode: re-use messageHash for hashing the key
With the OpenSSL3 code allocating state on the heap instead of in QCH::Private's inline union, reset() should be faster than even a static hash() call. Even in the non-OpenSSL3 case, using less QCH::Private objects to do the same thing means we increase effective data cache size. Pick-to: 6.5 Change-Id: I0b1347864081169a24c5d349702931afdab6c5bf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
8de0262ded
commit
d2e1c0aef1
@ -1002,12 +1002,22 @@ public:
|
|||||||
// END functions that need to be called with finalizeMutex held
|
// END functions that need to be called with finalizeMutex held
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
|
||||||
|
Transforms key into a block-sized format and then seeds messageHash from it.
|
||||||
|
|
||||||
|
This function assumes that messageHash is in its initial state (reset() has
|
||||||
|
been called).
|
||||||
|
*/
|
||||||
void QMessageAuthenticationCodePrivate::initMessageHash()
|
void QMessageAuthenticationCodePrivate::initMessageHash()
|
||||||
{
|
{
|
||||||
const int blockSize = qt_hash_block_size(method);
|
const int blockSize = qt_hash_block_size(method);
|
||||||
|
|
||||||
if (key.size() > blockSize) {
|
if (key.size() > blockSize) {
|
||||||
key = QCryptographicHash::hash(key, method);
|
messageHash.addData(key);
|
||||||
|
key = messageHash.result();
|
||||||
|
messageHash.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.size() < blockSize) {
|
if (key.size() < blockSize) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user