Skip to content

Commit

Permalink
merge: sync to latest commit on develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jNullj committed Feb 18, 2023
2 parents 597a2e9 + ba15981 commit 3b2a730
Show file tree
Hide file tree
Showing 17 changed files with 182 additions and 92 deletions.
53 changes: 41 additions & 12 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1494,10 +1494,6 @@ To prevent this error from appearing, you must go to "Database Settings / S
<source>Retry with empty password</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to authenticate with Windows Hello</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to authenticate with Touch ID</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -1555,6 +1551,10 @@ If you do not have a key file, please leave the field empty.</source>
<source>authenticate to access the database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to authenticate with Windows Hello: %1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DatabaseSettingWidgetMetaData</name>
Expand Down Expand Up @@ -1967,18 +1967,10 @@ If you keep this number, your database will not be protected from brute force at
<source>Maximum number of history items per entry</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Max. history items:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Maximum size of history per entry</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Max. history size:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> MiB</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -2008,6 +2000,35 @@ This action is not reversible.</source>
<source> (old)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>When saving this setting or editing an entry
the oldest history items of an entry will be
removed such that only the specified amount
of entries remain at most.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Limit the amount of history items per entry to:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>When saving this setting or editing an entry
the oldest history items of an entry will be
removed such that the remaining history items
add up to the specified amount at most.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Limit the total size of history items per entry to:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move entries to a recycle bin group
instead of deleting them from the database.
Entries deleted from the recycle bin are
removed from the database.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Autosave delay since last change</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -7912,6 +7933,14 @@ Kernel: %3 %4</source>
<source>Failed to sign challenge using Windows Hello.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid Cipher</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid KDF</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QtIOCompressor</name>
Expand Down
4 changes: 2 additions & 2 deletions src/cli/DatabaseInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ int DatabaseInfo::executeWithDatabase(QSharedPointer<Database> database, QShared
out << QObject::tr("Name: ") << database->metadata()->name() << endl;
out << QObject::tr("Description: ") << database->metadata()->description() << endl;
for (auto& cipher : asConst(KeePass2::CIPHERS)) {
if (cipher.first == database->cipher()) {
out << QObject::tr("Cipher: ") << cipher.second << endl;
if (cipher == database->cipher()) {
out << QObject::tr("Cipher: ") << KeePass2::cipherToString(cipher) << endl;
}
}
out << QObject::tr("KDF: ") << database->kdf()->toString() << endl;
Expand Down
40 changes: 31 additions & 9 deletions src/format/KeePass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,12 @@ const QString KeePass2::KDFPARAM_ARGON2_VERSION("V");
const QString KeePass2::KDFPARAM_ARGON2_SECRET("K");
const QString KeePass2::KDFPARAM_ARGON2_ASSOCDATA("A");

const QList<QPair<QUuid, QString>> KeePass2::CIPHERS{
qMakePair(KeePass2::CIPHER_AES256, QObject::tr("AES 256-bit")),
qMakePair(KeePass2::CIPHER_TWOFISH, QObject::tr("Twofish 256-bit")),
qMakePair(KeePass2::CIPHER_CHACHA20, QObject::tr("ChaCha20 256-bit"))};
const QList<QUuid> KeePass2::CIPHERS{KeePass2::CIPHER_AES256, KeePass2::CIPHER_TWOFISH, KeePass2::CIPHER_CHACHA20};

const QList<QPair<QUuid, QString>> KeePass2::KDFS{
qMakePair(KeePass2::KDF_ARGON2D, QObject::tr("Argon2d (KDBX 4 – recommended)")),
qMakePair(KeePass2::KDF_ARGON2ID, QObject::tr("Argon2id (KDBX 4)")),
qMakePair(KeePass2::KDF_AES_KDBX4, QObject::tr("AES-KDF (KDBX 4)")),
qMakePair(KeePass2::KDF_AES_KDBX3, QObject::tr("AES-KDF (KDBX 3)"))};
const QList<QUuid> KeePass2::KDFS{KeePass2::KDF_ARGON2D,
KeePass2::KDF_ARGON2ID,
KeePass2::KDF_AES_KDBX4,
KeePass2::KDF_AES_KDBX3};

QByteArray KeePass2::hmacKey(const QByteArray& masterSeed, const QByteArray& transformedMasterKey)
{
Expand Down Expand Up @@ -133,3 +129,29 @@ KeePass2::ProtectedStreamAlgo KeePass2::idToProtectedStreamAlgo(quint32 id)
return KeePass2::ProtectedStreamAlgo::InvalidProtectedStreamAlgo;
}
}

QString KeePass2::cipherToString(QUuid cipherUuid)
{
if (cipherUuid == KeePass2::CIPHER_AES256) {
return QObject::tr("AES 256-bit");
} else if (cipherUuid == KeePass2::CIPHER_TWOFISH) {
return QObject::tr("Twofish 256-bit");
} else if (cipherUuid == KeePass2::CIPHER_CHACHA20) {
return QObject::tr("ChaCha20 256-bit");
}
return QObject::tr("Invalid Cipher");
}

QString KeePass2::kdfToString(QUuid kdfUuid)
{
if (kdfUuid == KeePass2::KDF_ARGON2D) {
return QObject::tr("Argon2d (KDBX 4 – recommended)");
} else if (kdfUuid == KeePass2::KDF_ARGON2ID) {
return QObject::tr("Argon2id (KDBX 4)");
} else if (kdfUuid == KeePass2::KDF_AES_KDBX4) {
return QObject::tr("AES-KDF (KDBX 4)");
} else if (kdfUuid == KDF_AES_KDBX3) {
return QObject::tr("AES-KDF (KDBX 3)");
}
return QObject::tr("Invalid KDF");
}
8 changes: 4 additions & 4 deletions src/format/KeePass2.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Kdf;

namespace KeePass2
{

constexpr quint32 SIGNATURE_1 = 0x9AA2D903;
constexpr quint32 SIGNATURE_2 = 0xB54BFB67;

Expand Down Expand Up @@ -67,8 +66,8 @@ namespace KeePass2
extern const QString KDFPARAM_ARGON2_SECRET;
extern const QString KDFPARAM_ARGON2_ASSOCDATA;

extern const QList<QPair<QUuid, QString>> CIPHERS;
extern const QList<QPair<QUuid, QString>> KDFS;
extern const QList<QUuid> CIPHERS;
extern const QList<QUuid> KDFS;

enum class HeaderFieldID
{
Expand Down Expand Up @@ -130,7 +129,8 @@ namespace KeePass2
QVariantMap kdfToParameters(const QSharedPointer<Kdf>& kdf);
QSharedPointer<Kdf> uuidToKdf(const QUuid& uuid);
ProtectedStreamAlgo idToProtectedStreamAlgo(quint32 id);

QString cipherToString(QUuid cipherUuid);
QString kdfToString(QUuid kdfUuid);
} // namespace KeePass2

#endif // KEEPASSX_KEEPASS2_H
9 changes: 4 additions & 5 deletions src/gui/CloneDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "CloneDialog.h"
#include "ui_CloneDialog.h"

#include "config-keepassx.h"

CloneDialog::CloneDialog(DatabaseWidget* parent, Database* db, Entry* entry)
: QDialog(parent)
, m_ui(new Ui::CloneDialog())
Expand All @@ -29,8 +27,9 @@ CloneDialog::CloneDialog(DatabaseWidget* parent, Database* db, Entry* entry)
m_parent = parent;

m_ui->setupUi(this);
this->setFixedSize(this->sizeHint());

window()->layout()->setSizeConstraint(QLayout::SetFixedSize);
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
setAttribute(Qt::WA_DeleteOnClose);

connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(close()));
Expand All @@ -54,10 +53,10 @@ void CloneDialog::cloneEntry()
flags |= Entry::CloneIncludeHistory;
}

Entry* entry = m_entry->clone(flags);
auto entry = m_entry->clone(flags);
entry->setGroup(m_entry->group());

m_parent->refreshSearch();
emit entryCloned(entry);
close();
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/CloneDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class CloneDialog : public QDialog
explicit CloneDialog(DatabaseWidget* parent = nullptr, Database* db = nullptr, Entry* entry = nullptr);
~CloneDialog() override;

signals:
void entryCloned(Entry* clone);

private:
QScopedPointer<Ui::CloneDialog> m_ui;

Expand Down
66 changes: 34 additions & 32 deletions src/gui/CloneDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,56 @@
<rect>
<x>0</x>
<y>0</y>
<width>347</width>
<height>136</height>
<width>319</width>
<height>132</height>
</rect>
</property>
<property name="windowTitle">
<string>Clone Entry Options</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="titleClone">
<property name="text">
<string>Append ' - Clone' to title</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="referencesClone">
<property name="text">
<string>Replace username and password with references</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="historyClone">
<property name="text">
<string>Copy history</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<widget class="QCheckBox" name="titleClone">
<property name="text">
<string>Append ' - Clone' to title</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="referencesClone">
<property name="text">
<string>Replace username and password with references</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="historyClone">
<property name="text">
<string>Copy history</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>6</height>
</size>
</property>
</spacer>
Expand Down
7 changes: 6 additions & 1 deletion src/gui/DatabaseOpenWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,12 @@ QSharedPointer<CompositeKey> DatabaseOpenWidget::buildDatabaseKey()
#ifdef Q_CC_MSVC
if (!getWindowsHello()->getKey(m_filename, keyData)) {
// Failed to retrieve Quick Unlock data
m_ui->messageWidget->showMessage(tr("Failed to authenticate with Windows Hello"), MessageWidget::Error);
auto error = getWindowsHello()->errorString();
if (!error.isEmpty()) {
m_ui->messageWidget->showMessage(tr("Failed to authenticate with Windows Hello: %1").arg(error),
MessageWidget::Error);
resetQuickUnlock();
}
return {};
}
#elif defined(Q_OS_MACOS)
Expand Down
8 changes: 8 additions & 0 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,11 @@ void DatabaseWidget::cloneEntry()
}

auto cloneDialog = new CloneDialog(this, m_db.data(), currentEntry);
connect(cloneDialog, &CloneDialog::entryCloned, this, [this](auto entry) {
refreshSearch();
m_entryView->setCurrentEntry(entry);
});

cloneDialog->show();
}

Expand Down Expand Up @@ -1403,7 +1408,10 @@ void DatabaseWidget::performUnlockDatabase(const QString& password, const QStrin
void DatabaseWidget::refreshSearch()
{
if (isSearchActive()) {
auto selectedEntry = m_entryView->currentEntry();
search(m_lastSearchText);
// Re-select the previous entry if it is still in the search
m_entryView->setCurrentEntry(selectedEntry);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/gui/dbsettings/DatabaseSettingsWidgetEncryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void DatabaseSettingsWidgetEncryption::setupAlgorithmComboBox()
{
m_ui->algorithmComboBox->clear();
for (auto& cipher : asConst(KeePass2::CIPHERS)) {
m_ui->algorithmComboBox->addItem(cipher.second.toUtf8(), cipher.first.toByteArray());
m_ui->algorithmComboBox->addItem(KeePass2::cipherToString(cipher), cipher.toByteArray());
}
int cipherIndex = m_ui->algorithmComboBox->findData(m_db->cipher().toByteArray());
if (cipherIndex > -1) {
Expand All @@ -155,8 +155,8 @@ void DatabaseSettingsWidgetEncryption::setupKdfComboBox(bool enableKdbx3)
bool block = m_ui->kdfComboBox->blockSignals(true);
m_ui->kdfComboBox->clear();
for (auto& kdf : asConst(KeePass2::KDFS)) {
if (kdf.first != KeePass2::KDF_AES_KDBX3 or enableKdbx3) {
m_ui->kdfComboBox->addItem(kdf.second.toUtf8(), kdf.first.toByteArray());
if (kdf != KeePass2::KDF_AES_KDBX3 or enableKdbx3) {
m_ui->kdfComboBox->addItem(KeePass2::kdfToString(kdf), kdf.toByteArray());
}
}
m_ui->kdfComboBox->blockSignals(block);
Expand Down
6 changes: 4 additions & 2 deletions src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ void DatabaseSettingsWidgetGeneral::initialize()
m_ui->historyMaxItemsCheckBox->setChecked(true);
} else {
m_ui->historyMaxItemsSpinBox->setValue(Metadata::DefaultHistoryMaxItems);
m_ui->historyMaxItemsSpinBox->setEnabled(false);
m_ui->historyMaxItemsCheckBox->setChecked(false);
}
int historyMaxSizeMiB = qRound(meta->historyMaxSize() / qreal(1048576));
int historyMaxSizeMiB = qRound(meta->historyMaxSize() / qreal(1024 * 1024));
if (historyMaxSizeMiB > 0) {
m_ui->historyMaxSizeSpinBox->setValue(historyMaxSizeMiB);
m_ui->historyMaxSizeCheckBox->setChecked(true);
} else {
m_ui->historyMaxSizeSpinBox->setValue(Metadata::DefaultHistoryMaxSize);
m_ui->historyMaxSizeSpinBox->setValue(qRound(Metadata::DefaultHistoryMaxSize / qreal(1024 * 1024)));
m_ui->historyMaxSizeSpinBox->setEnabled(false);
m_ui->historyMaxSizeCheckBox->setChecked(false);
}
if (meta->autosaveDelayMin() > 0) {
Expand Down
Loading

0 comments on commit 3b2a730

Please sign in to comment.