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

@ -65,31 +65,31 @@ int Extract::execute(const QStringList& arguments)
out << QObject::tr("Insert password to unlock %1: ").arg(args.at(0));
out.flush();
CompositeKey compositeKey;
auto compositeKey = QSharedPointer<CompositeKey>::create();
QString line = Utils::getPassword();
PasswordKey passwordKey;
passwordKey.setPassword(line);
compositeKey.addKey(passwordKey);
auto passwordKey = QSharedPointer<PasswordKey>::create();
passwordKey->setPassword(line);
compositeKey->addKey(passwordKey);
QString keyFilePath = parser.value(keyFile);
if (!keyFilePath.isEmpty()) {
FileKey fileKey;
auto fileKey = QSharedPointer<FileKey>::create();
QString errorMsg;
if (!fileKey.load(keyFilePath, &errorMsg)) {
if (!fileKey->load(keyFilePath, &errorMsg)) {
errorTextStream << QObject::tr("Failed to load key file %1 : %2").arg(keyFilePath).arg(errorMsg);
errorTextStream << endl;
return EXIT_FAILURE;
}
if (fileKey.type() != FileKey::Hashed) {
if (fileKey->type() != FileKey::Hashed) {
errorTextStream << QObject::tr("WARNING: You are using a legacy key file format which may become\n"
"unsupported in the future.\n\n"
"Please consider generating a new key file.");
errorTextStream << endl;
}
compositeKey.addKey(fileKey);
compositeKey->addKey(fileKey);
}
QString databaseFilename = args.at(0);

View file

@ -76,7 +76,7 @@ int Merge::execute(const QStringList& arguments)
if (!parser.isSet("same-credentials")) {
db2 = Database::unlockFromStdin(args.at(1), parser.value(keyFileFrom));
} else {
db2 = Database::openDatabaseFile(args.at(1), *(db1->key().clone()));
db2 = Database::openDatabaseFile(args.at(1), db1->key());
}
if (db2 == nullptr) {
return EXIT_FAILURE;