Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanek Bevendorff <janek@jbev.net>2017-12-16 20:36:42 +0300
committerJonathan White <support@dmapps.us>2018-01-13 22:23:28 +0300
commit15648991fc0636320804804000066a27973fb7e5 (patch)
tree714fa266f9035e081d657644548e6002fa582163 /src/format/KeePass2.cpp
parentd00ccd2eb5016dec4be962385e61d5bccd606ce1 (diff)
Refactor Kdf class, remove fields concept
Diffstat (limited to 'src/format/KeePass2.cpp')
-rw-r--r--src/format/KeePass2.cpp48
1 files changed, 12 insertions, 36 deletions
diff --git a/src/format/KeePass2.cpp b/src/format/KeePass2.cpp
index e79dff513..61bd383df 100644
--- a/src/format/KeePass2.cpp
+++ b/src/format/KeePass2.cpp
@@ -16,9 +16,9 @@
*/
#include "KeePass2.h"
-#include "crypto/CryptoHash.h"
#include "crypto/kdf/AesKdf.h"
-#include "core/Uuid.h"
+#include <QSharedPointer>
+
const Uuid KeePass2::CIPHER_AES = Uuid(QByteArray::fromHex("31c1f2e6bf714350be5805216afc5aff"));
const Uuid KeePass2::CIPHER_TWOFISH = Uuid(QByteArray::fromHex("ad68f29f576f4bb9a36ad47af965346c"));
@@ -28,33 +28,25 @@ const Uuid KeePass2::KDF_AES = Uuid(QByteArray::fromHex("C9D9F39A628A4460BF740D0
const QByteArray KeePass2::INNER_STREAM_SALSA20_IV("\xE8\x30\x09\x4B\x97\x20\x5D\x2A");
-const QList<KeePass2::UuidNamePair> KeePass2::CIPHERS {
- KeePass2::UuidNamePair(KeePass2::CIPHER_AES, "AES: 256-bit"),
- KeePass2::UuidNamePair(KeePass2::CIPHER_TWOFISH, "Twofish: 256-bit"),
- KeePass2::UuidNamePair(KeePass2::CIPHER_CHACHA20, "ChaCha20: 256-bit")
+const QList<QPair<Uuid, QString>> KeePass2::CIPHERS {
+ qMakePair(KeePass2::CIPHER_AES, QObject::tr("AES: 256-bit")),
+ qMakePair(KeePass2::CIPHER_TWOFISH, QObject::tr("Twofish: 256-bit")),
+ qMakePair(KeePass2::CIPHER_CHACHA20, QObject::tr("ChaCha20: 256-bit"))
};
-const QList<KeePass2::UuidNamePair> KeePass2::KDFS {
- KeePass2::UuidNamePair(KeePass2::KDF_AES, "AES-KDF"),
+const QList<QPair<Uuid, QString>> KeePass2::KDFS {
+ qMakePair(KeePass2::KDF_AES, QObject::tr("AES-KDF")),
};
-Kdf* KeePass2::uuidToKdf(const Uuid& uuid) {
+QSharedPointer<Kdf> KeePass2::uuidToKdf(const Uuid& uuid)
+{
if (uuid == KDF_AES) {
- return static_cast<Kdf*>(new AesKdf());
+ return QSharedPointer<AesKdf>::create();
}
+ Q_ASSERT_X(false, "uuidToKdf", "Invalid UUID");
return nullptr;
}
-Uuid KeePass2::kdfToUuid(const Kdf& kdf)
-{
- switch (kdf.type()) {
- case Kdf::Type::AES:
- return KDF_AES;
- default:
- return Uuid();
- }
-}
-
KeePass2::ProtectedStreamAlgo KeePass2::idToProtectedStreamAlgo(quint32 id)
{
switch (id) {
@@ -68,19 +60,3 @@ KeePass2::ProtectedStreamAlgo KeePass2::idToProtectedStreamAlgo(quint32 id)
return KeePass2::InvalidProtectedStreamAlgo;
}
}
-
-KeePass2::UuidNamePair::UuidNamePair(const Uuid& uuid, const QString& name)
- : m_uuid(uuid)
- , m_name(name)
-{
-}
-
-Uuid KeePass2::UuidNamePair::uuid() const
-{
- return m_uuid;
-}
-
-QString KeePass2::UuidNamePair::name() const
-{
- return m_name;
-}