mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-29 15:53:38 -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;
|
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);
|
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);
|
tr("Failed to set %1 as the Key file:\n%2").arg(fileKeyName, errorMsg), MessageWidget::Error);
|
||||||
return;
|
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);
|
m_key.addKey(fileKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,6 +218,23 @@ QSharedPointer<CompositeKey> DatabaseOpenWidget::databaseKey()
|
|||||||
MessageWidget::Error);
|
MessageWidget::Error);
|
||||||
return QSharedPointer<CompositeKey>();
|
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);
|
masterKey->addKey(key);
|
||||||
lastKeyFiles[m_filename] = keyFilename;
|
lastKeyFiles[m_filename] = keyFilename;
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
*/
|
*/
|
||||||
bool FileKey::load(QIODevice* device)
|
bool FileKey::load(QIODevice* device)
|
||||||
{
|
{
|
||||||
|
m_type = None;
|
||||||
|
|
||||||
// we may need to read the file multiple times
|
// we may need to read the file multiple times
|
||||||
if (device->isSequential()) {
|
if (device->isSequential()) {
|
||||||
return false;
|
return false;
|
||||||
@ -59,6 +61,7 @@ bool FileKey::load(QIODevice* device)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (loadXml(device)) {
|
if (loadXml(device)) {
|
||||||
|
m_type = KeePass2XML;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +69,7 @@ bool FileKey::load(QIODevice* device)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (loadBinary(device)) {
|
if (loadBinary(device)) {
|
||||||
|
m_type = FixedBinary;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,15 +77,20 @@ bool FileKey::load(QIODevice* device)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (loadHex(device)) {
|
if (loadHex(device)) {
|
||||||
|
m_type = FixedBinaryHex;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if no legacy format was detected, generate SHA-256 hash of key file
|
||||||
if (!device->reset()) {
|
if (!device->reset()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (loadHashed(device)) {
|
||||||
|
m_type = Hashed;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// if no legacy format was detected, generate SHA-256 hash of key file
|
return false;
|
||||||
return loadHashed(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -345,3 +354,11 @@ bool FileKey::loadHashed(QIODevice* device)
|
|||||||
|
|
||||||
return true;
|
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
|
class FileKey: public Key
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum Type {
|
||||||
|
None,
|
||||||
|
Hashed,
|
||||||
|
KeePass2XML,
|
||||||
|
FixedBinary,
|
||||||
|
FixedBinaryHex
|
||||||
|
};
|
||||||
|
|
||||||
bool load(QIODevice* device);
|
bool load(QIODevice* device);
|
||||||
bool load(const QString& fileName, QString* errorMsg = nullptr);
|
bool load(const QString& fileName, QString* errorMsg = nullptr);
|
||||||
QByteArray rawKey() const override;
|
QByteArray rawKey() const override;
|
||||||
FileKey* clone() const override;
|
FileKey* clone() const override;
|
||||||
|
Type type() const;
|
||||||
static void create(QIODevice* device, int size = 128);
|
static void create(QIODevice* device, int size = 128);
|
||||||
static bool create(const QString& fileName, QString* errorMsg = nullptr, int size = 128);
|
static bool create(const QString& fileName, QString* errorMsg = nullptr, int size = 128);
|
||||||
|
|
||||||
@ -44,6 +53,7 @@ private:
|
|||||||
bool loadHashed(QIODevice* device);
|
bool loadHashed(QIODevice* device);
|
||||||
|
|
||||||
QByteArray m_key;
|
QByteArray m_key;
|
||||||
|
Type m_type = None;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_FILEKEY_H
|
#endif // KEEPASSX_FILEKEY_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user