mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-02 09:34:58 -05:00
Improved error messages when opening database
* Reduced wording and confusion * Streamlined delivery format * Fix #813
This commit is contained in:
parent
791b796c23
commit
0201fcd400
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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<CompositeKey> 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()) {
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user