diff options
author | Janek Bevendorff <janek@jbev.net> | 2020-12-10 03:28:01 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2020-12-19 17:42:21 +0300 |
commit | cd0084f21cc4eb7c0f2b00bdafb0eeba051fd927 (patch) | |
tree | 2101eb5da0a82a4b3d3669e899d0b615a52b8825 /src/keys/FileKey.h | |
parent | 404fd941e8e5428c8fe80c78f16ff7e4fa09aff4 (diff) |
Add support for version 2 XML key files.
As discussed in #4317, the next KeePass2 release will ship with
support for a new generation of XML key files which enable
hash integrity checks.
This patch adds support for reading and generating this new format.
By default, KeePass2 now uses the .keyx extension for generated
key files, which was added to KeePassXC's key generation file chooser
filter. We continue to generate hashed binary key files by default,
but the user can explicitly save the file with the new .keyx
extension to generate an XML v2 key file (currently undocumented).
When opening a database, the key file type is still determined
by content negotation, so the file extension has no impact here.
As an additional change, the legacy key file warnings have been
improved slightly to be less confusing and more helpful.
Diffstat (limited to 'src/keys/FileKey.h')
-rw-r--r-- | src/keys/FileKey.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/keys/FileKey.h b/src/keys/FileKey.h index 290a04af0..540dde7d2 100644 --- a/src/keys/FileKey.h +++ b/src/keys/FileKey.h @@ -35,25 +35,25 @@ public: None, Hashed, KeePass2XML, + KeePass2XMLv2, FixedBinary, FixedBinaryHex }; FileKey(); ~FileKey() override; - bool load(QIODevice* device); + bool load(QIODevice* device, QString* errorMsg = nullptr); bool load(const QString& fileName, QString* errorMsg = nullptr); QByteArray rawKey() 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); + static void createRandom(QIODevice* device, int size = 128); + static void createXMLv2(QIODevice* device, int size = 32); + static bool create(const QString& fileName, QString* errorMsg = nullptr); private: static constexpr int SHA256_SIZE = 32; - bool loadXml(QIODevice* device); - bool loadXmlMeta(QXmlStreamReader& xmlReader); - QByteArray loadXmlKey(QXmlStreamReader& xmlReader); + bool loadXml(QIODevice* device, QString* errorMsg = nullptr); bool loadBinary(QIODevice* device); bool loadHex(QIODevice* device); bool loadHashed(QIODevice* device); |