mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-14 08:50:08 -05:00
Add warning when using legacy key file formats.
This commit is contained in:
parent
21a6c0fd89
commit
871332ecf0
@ -82,6 +82,13 @@ int Extract::execute(QStringList arguments)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (fileKey.type() != FileKey::Hashed) {
|
||||
errorTextStream << QObject::tr("WARNING: You are using a legacy key file format which may become\n"
|
||||
"unsupported in the future.\n\n"
|
||||
"Please consider generating a new key file.");
|
||||
errorTextStream << endl;
|
||||
}
|
||||
|
||||
compositeKey.addKey(fileKey);
|
||||
}
|
||||
|
||||
|
@ -162,6 +162,14 @@ void ChangeMasterKeyWidget::generateKey()
|
||||
tr("Failed to set %1 as the Key file:\n%2").arg(fileKeyName, errorMsg), MessageWidget::Error);
|
||||
return;
|
||||
}
|
||||
if (fileKey.type() != FileKey::Hashed) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Legacy key file format"),
|
||||
tr("You are using a legacy key file format which may become\n"
|
||||
"unsupported in the future.\n\n"
|
||||
"Please consider generating a new key file."),
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
m_key.addKey(fileKey);
|
||||
}
|
||||
|
||||
|
@ -218,6 +218,23 @@ QSharedPointer<CompositeKey> DatabaseOpenWidget::databaseKey()
|
||||
MessageWidget::Error);
|
||||
return QSharedPointer<CompositeKey>();
|
||||
}
|
||||
if (key.type() != FileKey::Hashed && !config()->get("Messages/NoLegacyKeyFileWarning").toBool()) {
|
||||
QMessageBox legacyWarning;
|
||||
legacyWarning.setWindowTitle(tr("Legacy key file format"));
|
||||
legacyWarning.setText(tr("You are using a legacy key file format which may become\n"
|
||||
"unsupported in the future.\n\n"
|
||||
"Please consider generating a new key file."));
|
||||
legacyWarning.setIcon(QMessageBox::Icon::Warning);
|
||||
legacyWarning.addButton(QMessageBox::Ok);
|
||||
legacyWarning.setDefaultButton(QMessageBox::Ok);
|
||||
legacyWarning.setCheckBox(new QCheckBox(tr("Don't show this warning again")));
|
||||
|
||||
connect(legacyWarning.checkBox(), &QCheckBox::stateChanged, [](int state){
|
||||
config()->set("Messages/NoLegacyKeyFileWarning", state == Qt::CheckState::Checked);
|
||||
});
|
||||
|
||||
legacyWarning.exec();
|
||||
}
|
||||
masterKey->addKey(key);
|
||||
lastKeyFiles[m_filename] = keyFilename;
|
||||
} else {
|
||||
|
@ -45,6 +45,8 @@
|
||||
*/
|
||||
bool FileKey::load(QIODevice* device)
|
||||
{
|
||||
m_type = None;
|
||||
|
||||
// we may need to read the file multiple times
|
||||
if (device->isSequential()) {
|
||||
return false;
|
||||
@ -59,6 +61,7 @@ bool FileKey::load(QIODevice* device)
|
||||
return false;
|
||||
}
|
||||
if (loadXml(device)) {
|
||||
m_type = KeePass2XML;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -66,6 +69,7 @@ bool FileKey::load(QIODevice* device)
|
||||
return false;
|
||||
}
|
||||
if (loadBinary(device)) {
|
||||
m_type = FixedBinary;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -73,15 +77,20 @@ bool FileKey::load(QIODevice* device)
|
||||
return false;
|
||||
}
|
||||
if (loadHex(device)) {
|
||||
m_type = FixedBinaryHex;
|
||||
return true;
|
||||
}
|
||||
|
||||
// if no legacy format was detected, generate SHA-256 hash of key file
|
||||
if (!device->reset()) {
|
||||
return false;
|
||||
}
|
||||
if (loadHashed(device)) {
|
||||
m_type = Hashed;
|
||||
return true;
|
||||
}
|
||||
|
||||
// if no legacy format was detected, generate SHA-256 hash of key file
|
||||
return loadHashed(device);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -345,3 +354,11 @@ bool FileKey::loadHashed(QIODevice* device)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type of loaded key file
|
||||
*/
|
||||
FileKey::Type FileKey::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
@ -28,10 +28,19 @@ class QIODevice;
|
||||
class FileKey: public Key
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
None,
|
||||
Hashed,
|
||||
KeePass2XML,
|
||||
FixedBinary,
|
||||
FixedBinaryHex
|
||||
};
|
||||
|
||||
bool load(QIODevice* device);
|
||||
bool load(const QString& fileName, QString* errorMsg = nullptr);
|
||||
QByteArray rawKey() const override;
|
||||
FileKey* clone() const override;
|
||||
Type type() const;
|
||||
static void create(QIODevice* device, int size = 128);
|
||||
static bool create(const QString& fileName, QString* errorMsg = nullptr, int size = 128);
|
||||
|
||||
@ -44,6 +53,7 @@ private:
|
||||
bool loadHashed(QIODevice* device);
|
||||
|
||||
QByteArray m_key;
|
||||
Type m_type = None;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_FILEKEY_H
|
||||
|
Loading…
Reference in New Issue
Block a user