From d327c169049c0b56df237e6d8b31812ba0ce9d8b Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Wed, 10 Jan 2018 00:49:04 +0100 Subject: [PATCH] Increase Argon2 warning threshold and set parallelism default value to number of available processors --- src/crypto/kdf/Argon2Kdf.cpp | 3 +-- src/gui/DatabaseSettingsWidget.cpp | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/crypto/kdf/Argon2Kdf.cpp b/src/crypto/kdf/Argon2Kdf.cpp index 154f2ffe4..cd8474056 100644 --- a/src/crypto/kdf/Argon2Kdf.cpp +++ b/src/crypto/kdf/Argon2Kdf.cpp @@ -21,7 +21,6 @@ #include #include "format/KeePass2.h" -#include "crypto/CryptoHash.h" /** * KeePass' Argon2 implementation supports all parameters that are defined in the official specification, @@ -34,7 +33,7 @@ Argon2Kdf::Argon2Kdf() : Kdf::Kdf(KeePass2::KDF_ARGON2) , m_version(0x13) , m_memory(1 << 16) - , m_parallelism(2) + , m_parallelism(static_cast(QThread::idealThreadCount())) { m_rounds = 1; } diff --git a/src/gui/DatabaseSettingsWidget.cpp b/src/gui/DatabaseSettingsWidget.cpp index c59f97423..68b0d4ae6 100644 --- a/src/gui/DatabaseSettingsWidget.cpp +++ b/src/gui/DatabaseSettingsWidget.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "core/Global.h" #include "core/FilePath.h" @@ -118,6 +119,9 @@ void DatabaseSettingsWidget::load(Database* db) kdfChanged(kdfIndex); } + // properly initialize parallelism spin box (may be overwritten by actual KDF values) + m_uiEncryption->parallelismSpinBox->setValue(QThread::idealThreadCount()); + // Setup kdf parameters auto kdf = m_db->kdf(); m_uiEncryption->transformRoundsSpinBox->setValue(kdf->rounds()); @@ -134,7 +138,7 @@ void DatabaseSettingsWidget::save() { // first perform safety check for KDF rounds auto kdf = KeePass2::uuidToKdf(Uuid(m_uiEncryption->kdfComboBox->currentData().toByteArray())); - if (kdf->uuid() == KeePass2::KDF_ARGON2 && m_uiEncryption->transformRoundsSpinBox->value() > 1000) { + if (kdf->uuid() == KeePass2::KDF_ARGON2 && m_uiEncryption->transformRoundsSpinBox->value() > 10000) { QMessageBox warning; warning.setIcon(QMessageBox::Warning); warning.setWindowTitle(tr("Number of rounds too high"));