From 53e0893b51683386c4a9cfdab3784a63c89cc06f Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Fri, 2 Dec 2016 03:50:19 +0000 Subject: spelling: correct --- src/keys/FileKey.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/keys') diff --git a/src/keys/FileKey.cpp b/src/keys/FileKey.cpp index d399f545f..d3cdfe040 100644 --- a/src/keys/FileKey.cpp +++ b/src/keys/FileKey.cpp @@ -190,18 +190,18 @@ bool FileKey::loadXml(QIODevice* device) bool FileKey::loadXmlMeta(QXmlStreamReader& xmlReader) { - bool corectVersion = false; + bool correctVersion = false; while (!xmlReader.error() && xmlReader.readNextStartElement()) { if (xmlReader.name() == "Version") { // TODO: error message about incompatible key file version if (xmlReader.readElementText() == "1.00") { - corectVersion = true; + correctVersion = true; } } } - return corectVersion; + return correctVersion; } QByteArray FileKey::loadXmlKey(QXmlStreamReader& xmlReader) -- cgit v1.2.3 From 798041fe11adb7fc24f5ca413e7e88844da2b750 Mon Sep 17 00:00:00 2001 From: Louis-Bertrand Varin Date: Sat, 14 Jan 2017 13:25:30 -0500 Subject: Extract readKeyFromLine. --- src/keys/CompositeKey.cpp | 28 +++++++++++++++++++++++++++- src/keys/CompositeKey.h | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'src/keys') diff --git a/src/keys/CompositeKey.cpp b/src/keys/CompositeKey.cpp index 16b48592e..88116c104 100644 --- a/src/keys/CompositeKey.cpp +++ b/src/keys/CompositeKey.cpp @@ -18,12 +18,15 @@ #include "CompositeKey.h" #include "CompositeKey_p.h" -#include #include +#include +#include #include "core/Global.h" #include "crypto/CryptoHash.h" #include "crypto/SymmetricCipher.h" +#include "keys/FileKey.h" +#include "keys/PasswordKey.h" CompositeKey::CompositeKey() { @@ -71,6 +74,29 @@ CompositeKey& CompositeKey::operator=(const CompositeKey& key) return *this; } +/* + * Read a key from a line of input. + * If the line references a valid file + * path, the key is loaded from file. + */ +CompositeKey CompositeKey::readFromLine(QString line) +{ + + CompositeKey key; + if (QFile::exists(line)) { + FileKey fileKey; + fileKey.load(line); + key.addKey(fileKey); + } + else { + PasswordKey password; + password.setPassword(line); + key.addKey(password); + } + return key; + +} + QByteArray CompositeKey::rawKey() const { CryptoHash cryptoHash(CryptoHash::Sha256); diff --git a/src/keys/CompositeKey.h b/src/keys/CompositeKey.h index 3290d3671..f8666aadc 100644 --- a/src/keys/CompositeKey.h +++ b/src/keys/CompositeKey.h @@ -19,6 +19,7 @@ #define KEEPASSX_COMPOSITEKEY_H #include +#include #include "keys/Key.h" @@ -39,6 +40,7 @@ public: void addKey(const Key& key); static int transformKeyBenchmark(int msec); + static CompositeKey readFromLine(QString line); private: static QByteArray transformKeyRaw(const QByteArray& key, const QByteArray& seed, -- cgit v1.2.3