diff --git a/src/format/Kdbx3Reader.cpp b/src/format/Kdbx3Reader.cpp index 4fec74718..9196bc616 100644 --- a/src/format/Kdbx3Reader.cpp +++ b/src/format/Kdbx3Reader.cpp @@ -78,7 +78,8 @@ bool Kdbx3Reader::readDatabaseImpl(QIODevice* device, QByteArray realStart = cipherStream.read(32); if (realStart != m_streamStartBytes) { - raiseError(tr("Wrong key or database file is corrupt.")); + raiseError(tr("Invalid credentials were provided, please try again.\n" + "If this reoccurs, then your database file may be corrupt.")); return false; } diff --git a/src/format/Kdbx4Reader.cpp b/src/format/Kdbx4Reader.cpp index fbdf865bc..4bb0202b1 100644 --- a/src/format/Kdbx4Reader.cpp +++ b/src/format/Kdbx4Reader.cpp @@ -71,7 +71,8 @@ bool Kdbx4Reader::readDatabaseImpl(QIODevice* device, // clang-format off QByteArray hmacKey = KeePass2::hmacKey(m_masterSeed, db->transformedMasterKey()); if (headerHmac != CryptoHash::hmac(headerData, HmacBlockStream::getHmacKey(UINT64_MAX, hmacKey), CryptoHash::Sha256)) { - raiseError(tr("Wrong key or database file is corrupt. (HMAC mismatch)")); + raiseError(tr("Invalid credentials were provided, please try again.\n" + "If this reoccurs, then your database file may be corrupt.") + " " + tr("(HMAC mismatch)")); return false; } HmacBlockStream hmacStream(device, hmacKey); diff --git a/src/format/KeePass1Reader.cpp b/src/format/KeePass1Reader.cpp index e42449358..0319b1b2d 100644 --- a/src/format/KeePass1Reader.cpp +++ b/src/format/KeePass1Reader.cpp @@ -372,7 +372,8 @@ KeePass1Reader::testKeys(const QString& password, const QByteArray& keyfileData, } if (!cipherStream) { - raiseError(tr("Wrong key or database file is corrupt.")); + raiseError(tr("Invalid credentials were provided, please try again.\n" + "If this reoccurs, then your database file may be corrupt.")); } return cipherStream.take(); diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 0f540bca8..ced72485e 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -194,8 +194,7 @@ void DatabaseOpenWidget::openDatabase() bool ok = m_db->open(m_filename, masterKey, &error, false); QApplication::restoreOverrideCursor(); if (!ok) { - m_ui->messageWidget->showMessage(tr("Unable to open the database:\n%1").arg(error), - MessageWidget::MessageType::Error); + m_ui->messageWidget->showMessage(error, MessageWidget::MessageType::Error); return; } @@ -223,7 +222,7 @@ void DatabaseOpenWidget::openDatabase() } emit dialogFinished(true); } else { - m_ui->messageWidget->showMessage(tr("Unable to open the database:\n%1").arg(error), MessageWidget::Error); + m_ui->messageWidget->showMessage(error, MessageWidget::Error); m_ui->editPassword->setText(""); #ifdef WITH_XC_TOUCHID @@ -268,7 +267,7 @@ QSharedPointer DatabaseOpenWidget::databaseKey() QString keyFilename = m_ui->comboKeyFile->currentText(); QString errorMsg; if (!key->load(keyFilename, &errorMsg)) { - m_ui->messageWidget->showMessage(tr("Can't open key file:\n%1").arg(errorMsg), MessageWidget::Error); + m_ui->messageWidget->showMessage(tr("Failed to open key file: %1").arg(errorMsg), MessageWidget::Error); return {}; } if (key->type() != FileKey::Hashed && !config()->get("Messages/NoLegacyKeyFileWarning").toBool()) { diff --git a/tests/TestCli.cpp b/tests/TestCli.cpp index 3ba40b904..9574f6d32 100644 --- a/tests/TestCli.cpp +++ b/tests/TestCli.cpp @@ -702,8 +702,7 @@ void TestCli::testKeyFileOption() m_stdoutFile->readLine(); // skip password prompt m_stderrFile->seek(posErr); QCOMPARE(m_stdoutFile->readAll(), QByteArray("")); - QCOMPARE(m_stderrFile->readAll(), - QByteArray("Error while reading the database: Wrong key or database file is corrupt. (HMAC mismatch)\n")); + QVERIFY(m_stderrFile->readAll().contains("Invalid credentials were provided")); // Should raise an error if key file path is invalid. pos = m_stdoutFile->pos(); @@ -736,8 +735,7 @@ void TestCli::testNoPasswordOption() m_stdoutFile->readLine(); // skip password prompt m_stderrFile->seek(posErr); QCOMPARE(m_stdoutFile->readAll(), QByteArray("")); - QCOMPARE(m_stderrFile->readAll(), - QByteArray("Error while reading the database: Wrong key or database file is corrupt. (HMAC mismatch)\n")); + QVERIFY(m_stderrFile->readAll().contains("Invalid credentials were provided")); } void TestCli::testList()