Improve speed of AES KDF transform

* Remove parallel left/right block calculations in favor of calculating both blocks simultaneously. This brings the calculation within parity of 2.6.6.
* Fix #7682
This commit is contained in:
Jonathan White 2022-04-01 07:10:11 -04:00
parent d8da81d87c
commit 41061cfde8

View File

@ -62,30 +62,19 @@ QVariantMap AesKdf::writeParameters()
bool AesKdf::transform(const QByteArray& raw, QByteArray& result) const
{
QByteArray resultLeft;
QByteArray resultRight;
QFuture<bool> future = QtConcurrent::run(transformKeyRaw, raw.left(16), m_seed, m_rounds, &resultLeft);
bool rightResult = transformKeyRaw(raw.right(16), m_seed, m_rounds, &resultRight);
bool leftResult = future.result();
if (!rightResult || !leftResult) {
return false;
}
QByteArray transformed;
transformed.append(resultLeft);
transformed.append(resultRight);
result = CryptoHash::hash(transformed, CryptoHash::Sha256);
return true;
return transformKeyRaw(raw, m_seed, m_rounds, &result);
}
bool AesKdf::transformKeyRaw(const QByteArray& key, const QByteArray& seed, int rounds, QByteArray* result)
{
*result = key;
return SymmetricCipher::aesKdf(seed, rounds, *result);
if (!result) {
return false;
}
auto out = key;
SymmetricCipher::aesKdf(seed, rounds, out);
*result = CryptoHash::hash(out, CryptoHash::Sha256);
return true;
}
QSharedPointer<Kdf> AesKdf::clone() const