mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-24 23:09:44 -05:00
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:
parent
d8da81d87c
commit
41061cfde8
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user