mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-20 20:18:46 -04: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
5 changed files with 11 additions and 11 deletions
|
@ -78,7 +78,8 @@ bool Kdbx3Reader::readDatabaseImpl(QIODevice* device,
|
||||||
QByteArray realStart = cipherStream.read(32);
|
QByteArray realStart = cipherStream.read(32);
|
||||||
|
|
||||||
if (realStart != m_streamStartBytes) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,8 @@ bool Kdbx4Reader::readDatabaseImpl(QIODevice* device,
|
||||||
// clang-format off
|
// clang-format off
|
||||||
QByteArray hmacKey = KeePass2::hmacKey(m_masterSeed, db->transformedMasterKey());
|
QByteArray hmacKey = KeePass2::hmacKey(m_masterSeed, db->transformedMasterKey());
|
||||||
if (headerHmac != CryptoHash::hmac(headerData, HmacBlockStream::getHmacKey(UINT64_MAX, hmacKey), CryptoHash::Sha256)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
HmacBlockStream hmacStream(device, hmacKey);
|
HmacBlockStream hmacStream(device, hmacKey);
|
||||||
|
|
|
@ -372,7 +372,8 @@ KeePass1Reader::testKeys(const QString& password, const QByteArray& keyfileData,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cipherStream) {
|
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();
|
return cipherStream.take();
|
||||||
|
|
|
@ -194,8 +194,7 @@ void DatabaseOpenWidget::openDatabase()
|
||||||
bool ok = m_db->open(m_filename, masterKey, &error, false);
|
bool ok = m_db->open(m_filename, masterKey, &error, false);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
m_ui->messageWidget->showMessage(tr("Unable to open the database:\n%1").arg(error),
|
m_ui->messageWidget->showMessage(error, MessageWidget::MessageType::Error);
|
||||||
MessageWidget::MessageType::Error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +222,7 @@ void DatabaseOpenWidget::openDatabase()
|
||||||
}
|
}
|
||||||
emit dialogFinished(true);
|
emit dialogFinished(true);
|
||||||
} else {
|
} 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("");
|
m_ui->editPassword->setText("");
|
||||||
|
|
||||||
#ifdef WITH_XC_TOUCHID
|
#ifdef WITH_XC_TOUCHID
|
||||||
|
@ -268,7 +267,7 @@ QSharedPointer<CompositeKey> DatabaseOpenWidget::databaseKey()
|
||||||
QString keyFilename = m_ui->comboKeyFile->currentText();
|
QString keyFilename = m_ui->comboKeyFile->currentText();
|
||||||
QString errorMsg;
|
QString errorMsg;
|
||||||
if (!key->load(keyFilename, &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 {};
|
return {};
|
||||||
}
|
}
|
||||||
if (key->type() != FileKey::Hashed && !config()->get("Messages/NoLegacyKeyFileWarning").toBool()) {
|
if (key->type() != FileKey::Hashed && !config()->get("Messages/NoLegacyKeyFileWarning").toBool()) {
|
||||||
|
|
|
@ -702,8 +702,7 @@ void TestCli::testKeyFileOption()
|
||||||
m_stdoutFile->readLine(); // skip password prompt
|
m_stdoutFile->readLine(); // skip password prompt
|
||||||
m_stderrFile->seek(posErr);
|
m_stderrFile->seek(posErr);
|
||||||
QCOMPARE(m_stdoutFile->readAll(), QByteArray(""));
|
QCOMPARE(m_stdoutFile->readAll(), QByteArray(""));
|
||||||
QCOMPARE(m_stderrFile->readAll(),
|
QVERIFY(m_stderrFile->readAll().contains("Invalid credentials were provided"));
|
||||||
QByteArray("Error while reading the database: Wrong key or database file is corrupt. (HMAC mismatch)\n"));
|
|
||||||
|
|
||||||
// Should raise an error if key file path is invalid.
|
// Should raise an error if key file path is invalid.
|
||||||
pos = m_stdoutFile->pos();
|
pos = m_stdoutFile->pos();
|
||||||
|
@ -736,8 +735,7 @@ void TestCli::testNoPasswordOption()
|
||||||
m_stdoutFile->readLine(); // skip password prompt
|
m_stdoutFile->readLine(); // skip password prompt
|
||||||
m_stderrFile->seek(posErr);
|
m_stderrFile->seek(posErr);
|
||||||
QCOMPARE(m_stdoutFile->readAll(), QByteArray(""));
|
QCOMPARE(m_stdoutFile->readAll(), QByteArray(""));
|
||||||
QCOMPARE(m_stderrFile->readAll(),
|
QVERIFY(m_stderrFile->readAll().contains("Invalid credentials were provided"));
|
||||||
QByteArray("Error while reading the database: Wrong key or database file is corrupt. (HMAC mismatch)\n"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCli::testList()
|
void TestCli::testList()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue