Allow for KDF seeds between 8 and 32 bytes

Correcting undocumented feature from KeePass2
Fixes #2581
This commit is contained in:
Jonathan White 2019-01-10 08:19:14 -07:00
parent f446774605
commit 1d24b52fa6
2 changed files with 4 additions and 3 deletions

View file

@ -24,7 +24,7 @@
Kdf::Kdf(const QUuid& uuid) Kdf::Kdf(const QUuid& uuid)
: m_rounds(KDF_DEFAULT_ROUNDS) : m_rounds(KDF_DEFAULT_ROUNDS)
, m_seed(QByteArray(KDF_DEFAULT_SEED_SIZE, 0)) , m_seed(QByteArray(KDF_MAX_SEED_SIZE, 0))
, m_uuid(uuid) , m_uuid(uuid)
{ {
} }
@ -56,7 +56,7 @@ bool Kdf::setRounds(int rounds)
bool Kdf::setSeed(const QByteArray& seed) bool Kdf::setSeed(const QByteArray& seed)
{ {
if (seed.size() != m_seed.size()) { if (seed.size() < KDF_MIN_SEED_SIZE || seed.size() > KDF_MAX_SEED_SIZE) {
return false; return false;
} }

View file

@ -21,7 +21,8 @@
#include <QUuid> #include <QUuid>
#include <QVariant> #include <QVariant>
#define KDF_DEFAULT_SEED_SIZE 32 #define KDF_MIN_SEED_SIZE 8
#define KDF_MAX_SEED_SIZE 32
#define KDF_DEFAULT_ROUNDS 1000000ull #define KDF_DEFAULT_ROUNDS 1000000ull
class Kdf class Kdf