Add a new database settings wizard

This patch implements a new database wizard to guide users through the process
of setting up a new database and choosing sane encryption settings.

It also reimplements the master key settings to be more
user-friendly. Users can now add, change, or remove individual composite
key components instead of having to set all components at once. This
avoids confusion about a password being reset if the user only wants to
add a key file.

With these changes comes a major refactor of how database composite keys and key
components are handled. Copying of keys is prohibited and each key
exists only once in memory and is referenced via shared pointers. GUI
components for changing individual keys are encapsulated into separate
classes to be more reusable. The password edit and generator widgets
have also been refactored to be more reusable.
This commit is contained in:
Janek Bevendorff 2018-05-13 23:21:43 +02:00
parent e4ded388b4
commit e443cde452
116 changed files with 5054 additions and 1692 deletions

View file

@ -63,7 +63,7 @@ void TestKdbx3::writeXml(QBuffer* buf, Database* db, bool& hasError, QString& er
}
void TestKdbx3::readKdbx(QIODevice* device,
CompositeKey const& key,
QSharedPointer<const CompositeKey> key,
QScopedPointer<Database>& db,
bool& hasError,
QString& errorString)
@ -78,7 +78,7 @@ void TestKdbx3::readKdbx(QIODevice* device,
}
void TestKdbx3::readKdbx(const QString& path,
CompositeKey const& key,
QSharedPointer<const CompositeKey> key,
QScopedPointer<Database>& db,
bool& hasError,
QString& errorString)
@ -106,8 +106,8 @@ void TestKdbx3::writeKdbx(QIODevice* device, Database* db, bool& hasError, QStri
void TestKdbx3::testFormat300()
{
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/Format300.kdbx");
CompositeKey key;
key.addKey(PasswordKey("a"));
auto key = QSharedPointer<CompositeKey>::create();
key->addKey(QSharedPointer<PasswordKey>::create("a"));
KeePass2Reader reader;
QScopedPointer<Database> db(reader.readDatabase(filename, key));
QCOMPARE(reader.version(), KeePass2::FILE_VERSION_3);
@ -121,8 +121,8 @@ void TestKdbx3::testFormat300()
void TestKdbx3::testNonAscii()
{
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/NonAscii.kdbx");
CompositeKey key;
key.addKey(PasswordKey(QString::fromUtf8("\xce\x94\xc3\xb6\xd8\xb6")));
auto key = QSharedPointer<CompositeKey>::create();
key->addKey(QSharedPointer<PasswordKey>::create(QString::fromUtf8("\xce\x94\xc3\xb6\xd8\xb6")));
KeePass2Reader reader;
QScopedPointer<Database> db(reader.readDatabase(filename, key));
QVERIFY(db.data());
@ -134,8 +134,8 @@ void TestKdbx3::testNonAscii()
void TestKdbx3::testCompressed()
{
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/Compressed.kdbx");
CompositeKey key;
key.addKey(PasswordKey(""));
auto key = QSharedPointer<CompositeKey>::create();
key->addKey(QSharedPointer<PasswordKey>::create(""));
KeePass2Reader reader;
QScopedPointer<Database> db(reader.readDatabase(filename, key));
QVERIFY(db.data());
@ -147,8 +147,8 @@ void TestKdbx3::testCompressed()
void TestKdbx3::testProtectedStrings()
{
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/ProtectedStrings.kdbx");
CompositeKey key;
key.addKey(PasswordKey("masterpw"));
auto key = QSharedPointer<CompositeKey>::create();
key->addKey(QSharedPointer<PasswordKey>::create("masterpw"));
KeePass2Reader reader;
QScopedPointer<Database> db(reader.readDatabase(filename, key));
QVERIFY(db.data());
@ -174,8 +174,8 @@ void TestKdbx3::testBrokenHeaderHash()
// Make sure the database won't open.
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/BrokenHeaderHash.kdbx");
CompositeKey key;
key.addKey(PasswordKey(""));
auto key = QSharedPointer<CompositeKey>::create();
key->addKey(QSharedPointer<PasswordKey>::create(""));
KeePass2Reader reader;
QScopedPointer<Database> db(reader.readDatabase(filename, key));
QVERIFY(!db.data());
@ -188,8 +188,8 @@ void TestKdbx3::testKdbxRepair()
// master password = test
// entry username: testuser\x10\x20AC
// entry password: testpw
CompositeKey key;
key.addKey(PasswordKey("test"));
auto key = QSharedPointer<CompositeKey>::create();
key->addKey(QSharedPointer<PasswordKey>::create("test"));
// test that we can't open the broken database
bool hasError;