diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts
index d209e0e6d..762d9c201 100644
--- a/share/translations/keepassxc_en.ts
+++ b/share/translations/keepassxc_en.ts
@@ -7888,6 +7888,14 @@ Kernel: %3 %4
+
+
+
+
+
+
+
+
diff --git a/src/cli/DatabaseInfo.cpp b/src/cli/DatabaseInfo.cpp
index b5569ae84..f0e5e0f03 100644
--- a/src/cli/DatabaseInfo.cpp
+++ b/src/cli/DatabaseInfo.cpp
@@ -39,8 +39,8 @@ int DatabaseInfo::executeWithDatabase(QSharedPointer 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;
diff --git a/src/format/KeePass2.cpp b/src/format/KeePass2.cpp
index bf991f880..b19316741 100644
--- a/src/format/KeePass2.cpp
+++ b/src/format/KeePass2.cpp
@@ -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> 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 KeePass2::CIPHERS{KeePass2::CIPHER_AES256, KeePass2::CIPHER_TWOFISH, KeePass2::CIPHER_CHACHA20};
-const QList> 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 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)
{
@@ -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");
+}
diff --git a/src/format/KeePass2.h b/src/format/KeePass2.h
index 5aed903c3..1d18a18ba 100644
--- a/src/format/KeePass2.h
+++ b/src/format/KeePass2.h
@@ -26,7 +26,6 @@ class Kdf;
namespace KeePass2
{
-
constexpr quint32 SIGNATURE_1 = 0x9AA2D903;
constexpr quint32 SIGNATURE_2 = 0xB54BFB67;
@@ -67,8 +66,8 @@ namespace KeePass2
extern const QString KDFPARAM_ARGON2_SECRET;
extern const QString KDFPARAM_ARGON2_ASSOCDATA;
- extern const QList> CIPHERS;
- extern const QList> KDFS;
+ extern const QList CIPHERS;
+ extern const QList KDFS;
enum class HeaderFieldID
{
@@ -130,7 +129,8 @@ namespace KeePass2
QVariantMap kdfToParameters(const QSharedPointer& kdf);
QSharedPointer uuidToKdf(const QUuid& uuid);
ProtectedStreamAlgo idToProtectedStreamAlgo(quint32 id);
-
+ QString cipherToString(QUuid cipherUuid);
+ QString kdfToString(QUuid kdfUuid);
} // namespace KeePass2
#endif // KEEPASSX_KEEPASS2_H
diff --git a/src/gui/dbsettings/DatabaseSettingsWidgetEncryption.cpp b/src/gui/dbsettings/DatabaseSettingsWidgetEncryption.cpp
index be13cd188..76f86fcae 100644
--- a/src/gui/dbsettings/DatabaseSettingsWidgetEncryption.cpp
+++ b/src/gui/dbsettings/DatabaseSettingsWidgetEncryption.cpp
@@ -143,7 +143,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) {
@@ -157,8 +157,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);