Replaced Uuid with QUuid
This commit is contained in:
@@ -66,7 +66,6 @@ set(keepassx_SOURCES
|
||||
core/TimeInfo.cpp
|
||||
core/Tools.cpp
|
||||
core/Translator.cpp
|
||||
core/Uuid.cpp
|
||||
core/Base32.h
|
||||
core/Base32.cpp
|
||||
cli/Utils.cpp
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "Database.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QSaveFile>
|
||||
#include <QTemporaryFile>
|
||||
@@ -35,13 +36,13 @@
|
||||
#include "keys/FileKey.h"
|
||||
#include "keys/PasswordKey.h"
|
||||
|
||||
QHash<Uuid, Database*> Database::m_uuidMap;
|
||||
QHash<QUuid, Database*> Database::m_uuidMap;
|
||||
|
||||
Database::Database()
|
||||
: m_metadata(new Metadata(this))
|
||||
, m_timer(new QTimer(this))
|
||||
, m_emitModified(false)
|
||||
, m_uuid(Uuid::random())
|
||||
, m_uuid(QUuid::createUuid())
|
||||
{
|
||||
m_data.cipher = KeePass2::CIPHER_AES;
|
||||
m_data.compressionAlgo = CompressionGZip;
|
||||
@@ -53,7 +54,7 @@ Database::Database()
|
||||
m_data.hasKey = false;
|
||||
|
||||
setRootGroup(new Group());
|
||||
rootGroup()->setUuid(Uuid::random());
|
||||
rootGroup()->setUuid(QUuid::createUuid());
|
||||
m_timer->setSingleShot(true);
|
||||
|
||||
m_uuidMap.insert(m_uuid, this);
|
||||
@@ -97,7 +98,7 @@ const Metadata* Database::metadata() const
|
||||
return m_metadata;
|
||||
}
|
||||
|
||||
Entry* Database::resolveEntry(const Uuid& uuid)
|
||||
Entry* Database::resolveEntry(const QUuid& uuid)
|
||||
{
|
||||
return findEntryRecursive(uuid, m_rootGroup);
|
||||
}
|
||||
@@ -107,7 +108,7 @@ Entry* Database::resolveEntry(const QString& text, EntryReferenceType referenceT
|
||||
return findEntryRecursive(text, referenceType, m_rootGroup);
|
||||
}
|
||||
|
||||
Entry* Database::findEntryRecursive(const Uuid& uuid, Group* group)
|
||||
Entry* Database::findEntryRecursive(const QUuid& uuid, Group* group)
|
||||
{
|
||||
const QList<Entry*> entryList = group->entries();
|
||||
for (Entry* entry : entryList) {
|
||||
@@ -154,8 +155,8 @@ Entry* Database::findEntryRecursive(const QString& text, EntryReferenceType refe
|
||||
case EntryReferenceType::Notes:
|
||||
found = entry->notes() == text;
|
||||
break;
|
||||
case EntryReferenceType::Uuid:
|
||||
found = entry->uuid() == Uuid::fromHex(text);
|
||||
case EntryReferenceType::QUuid:
|
||||
found = entry->uuid() == QUuid::fromRfc4122(QByteArray::fromHex(text.toLatin1()));
|
||||
break;
|
||||
case EntryReferenceType::CustomAttributes:
|
||||
found = entry->attributes()->containsValue(text);
|
||||
@@ -178,12 +179,12 @@ Entry* Database::findEntryRecursive(const QString& text, EntryReferenceType refe
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Group* Database::resolveGroup(const Uuid& uuid)
|
||||
Group* Database::resolveGroup(const QUuid& uuid)
|
||||
{
|
||||
return findGroupRecursive(uuid, m_rootGroup);
|
||||
}
|
||||
|
||||
Group* Database::findGroupRecursive(const Uuid& uuid, Group* group)
|
||||
Group* Database::findGroupRecursive(const QUuid& uuid, Group* group)
|
||||
{
|
||||
if (group->uuid() == uuid) {
|
||||
return group;
|
||||
@@ -211,7 +212,7 @@ void Database::addDeletedObject(const DeletedObject& delObj)
|
||||
m_deletedObjects.append(delObj);
|
||||
}
|
||||
|
||||
void Database::addDeletedObject(const Uuid& uuid)
|
||||
void Database::addDeletedObject(const QUuid& uuid)
|
||||
{
|
||||
DeletedObject delObj;
|
||||
delObj.deletionTime = QDateTime::currentDateTimeUtc();
|
||||
@@ -220,7 +221,7 @@ void Database::addDeletedObject(const Uuid& uuid)
|
||||
addDeletedObject(delObj);
|
||||
}
|
||||
|
||||
Uuid Database::cipher() const
|
||||
const QUuid& Database::cipher() const
|
||||
{
|
||||
return m_data.cipher;
|
||||
}
|
||||
@@ -246,7 +247,7 @@ bool Database::challengeMasterSeed(const QByteArray& masterSeed)
|
||||
return m_data.key.challenge(masterSeed, m_data.challengeResponseKey);
|
||||
}
|
||||
|
||||
void Database::setCipher(const Uuid& cipher)
|
||||
void Database::setCipher(const QUuid& cipher)
|
||||
{
|
||||
Q_ASSERT(!cipher.isNull());
|
||||
|
||||
@@ -387,10 +388,10 @@ void Database::merge(const Database* other)
|
||||
{
|
||||
m_rootGroup->merge(other->rootGroup());
|
||||
|
||||
for (Uuid customIconId : other->metadata()->customIcons().keys()) {
|
||||
for (const QUuid& customIconId : other->metadata()->customIcons().keys()) {
|
||||
QImage customIcon = other->metadata()->customIcon(customIconId);
|
||||
if (!this->metadata()->containsCustomIcon(customIconId)) {
|
||||
qDebug("Adding custom icon %s to database.", qPrintable(customIconId.toHex()));
|
||||
qDebug() << QString("Adding custom icon %1 to database.").arg(customIconId.toString());
|
||||
this->metadata()->addCustomIcon(customIconId, customIcon);
|
||||
}
|
||||
}
|
||||
@@ -407,12 +408,12 @@ void Database::setEmitModified(bool value)
|
||||
m_emitModified = value;
|
||||
}
|
||||
|
||||
Uuid Database::uuid()
|
||||
const QUuid& Database::uuid()
|
||||
{
|
||||
return m_uuid;
|
||||
}
|
||||
|
||||
Database* Database::databaseByUuid(const Uuid& uuid)
|
||||
Database* Database::databaseByUuid(const QUuid& uuid)
|
||||
{
|
||||
return m_uuidMap.value(uuid, 0);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
|
||||
#include "core/Uuid.h"
|
||||
#include "crypto/kdf/Kdf.h"
|
||||
#include "keys/CompositeKey.h"
|
||||
|
||||
@@ -36,7 +35,7 @@ class QIODevice;
|
||||
|
||||
struct DeletedObject
|
||||
{
|
||||
Uuid uuid;
|
||||
QUuid uuid;
|
||||
QDateTime deletionTime;
|
||||
};
|
||||
|
||||
@@ -56,7 +55,7 @@ public:
|
||||
|
||||
struct DatabaseData
|
||||
{
|
||||
Uuid cipher;
|
||||
QUuid cipher;
|
||||
CompressionAlgorithm compressionAlgo;
|
||||
QByteArray transformedMasterKey;
|
||||
QSharedPointer<Kdf> kdf;
|
||||
@@ -83,14 +82,14 @@ public:
|
||||
|
||||
Metadata* metadata();
|
||||
const Metadata* metadata() const;
|
||||
Entry* resolveEntry(const Uuid& uuid);
|
||||
Entry* resolveEntry(const QUuid& uuid);
|
||||
Entry* resolveEntry(const QString& text, EntryReferenceType referenceType);
|
||||
Group* resolveGroup(const Uuid& uuid);
|
||||
Group* resolveGroup(const QUuid& uuid);
|
||||
QList<DeletedObject> deletedObjects();
|
||||
void addDeletedObject(const DeletedObject& delObj);
|
||||
void addDeletedObject(const Uuid& uuid);
|
||||
void addDeletedObject(const QUuid& uuid);
|
||||
|
||||
Uuid cipher() const;
|
||||
const QUuid& cipher() const;
|
||||
Database::CompressionAlgorithm compressionAlgo() const;
|
||||
QSharedPointer<Kdf> kdf() const;
|
||||
QByteArray transformedMasterKey() const;
|
||||
@@ -98,7 +97,7 @@ public:
|
||||
QByteArray challengeResponseKey() const;
|
||||
bool challengeMasterSeed(const QByteArray& masterSeed);
|
||||
|
||||
void setCipher(const Uuid& cipher);
|
||||
void setCipher(const QUuid& cipher);
|
||||
void setCompressionAlgo(Database::CompressionAlgorithm algo);
|
||||
void setKdf(QSharedPointer<Kdf> kdf);
|
||||
bool setKey(const CompositeKey& key, bool updateChangedTime = true, bool updateTransformSalt = false);
|
||||
@@ -117,10 +116,10 @@ public:
|
||||
/**
|
||||
* Returns a unique id that is only valid as long as the Database exists.
|
||||
*/
|
||||
Uuid uuid();
|
||||
const QUuid& uuid();
|
||||
bool changeKdf(QSharedPointer<Kdf> kdf);
|
||||
|
||||
static Database* databaseByUuid(const Uuid& uuid);
|
||||
static Database* databaseByUuid(const QUuid& uuid);
|
||||
static Database* openDatabaseFile(QString fileName, CompositeKey key);
|
||||
static Database* unlockFromStdin(QString databaseFilename, QString keyFilename = QString(""));
|
||||
|
||||
@@ -140,9 +139,9 @@ private slots:
|
||||
void startModifiedTimer();
|
||||
|
||||
private:
|
||||
Entry* findEntryRecursive(const Uuid& uuid, Group* group);
|
||||
Entry* findEntryRecursive(const QUuid& uuid, Group* group);
|
||||
Entry* findEntryRecursive(const QString& text, EntryReferenceType referenceType, Group* group);
|
||||
Group* findGroupRecursive(const Uuid& uuid, Group* group);
|
||||
Group* findGroupRecursive(const QUuid& uuid, Group* group);
|
||||
|
||||
void createRecycleBin();
|
||||
QString writeDatabase(QIODevice* device);
|
||||
@@ -155,8 +154,8 @@ private:
|
||||
DatabaseData m_data;
|
||||
bool m_emitModified;
|
||||
|
||||
Uuid m_uuid;
|
||||
static QHash<Uuid, Database*> m_uuidMap;
|
||||
QUuid m_uuid;
|
||||
static QHash<QUuid, Database*> m_uuidMap;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_DATABASE_H
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "core/Metadata.h"
|
||||
#include "totp/totp.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
|
||||
const int Entry::DefaultIconNumber = 0;
|
||||
@@ -110,7 +111,7 @@ EntryReferenceType Entry::referenceType(const QString& referenceStr)
|
||||
} else if (referenceLowerStr == QLatin1String("n")) {
|
||||
result = EntryReferenceType::Notes;
|
||||
} else if (referenceLowerStr == QLatin1String("i")) {
|
||||
result = EntryReferenceType::Uuid;
|
||||
result = EntryReferenceType::QUuid;
|
||||
} else if (referenceLowerStr == QLatin1String("o")) {
|
||||
result = EntryReferenceType::CustomAttributes;
|
||||
}
|
||||
@@ -118,7 +119,7 @@ EntryReferenceType Entry::referenceType(const QString& referenceStr)
|
||||
return result;
|
||||
}
|
||||
|
||||
Uuid Entry::uuid() const
|
||||
const QUuid& Entry::uuid() const
|
||||
{
|
||||
return m_uuid;
|
||||
}
|
||||
@@ -170,7 +171,7 @@ int Entry::iconNumber() const
|
||||
return m_data.iconNumber;
|
||||
}
|
||||
|
||||
Uuid Entry::iconUuid() const
|
||||
const QUuid& Entry::iconUuid() const
|
||||
{
|
||||
return m_data.customIcon;
|
||||
}
|
||||
@@ -417,7 +418,7 @@ quint8 Entry::totpDigits() const
|
||||
return m_data.totpDigits;
|
||||
}
|
||||
|
||||
void Entry::setUuid(const Uuid& uuid)
|
||||
void Entry::setUuid(const QUuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
set(m_uuid, uuid);
|
||||
@@ -429,14 +430,14 @@ void Entry::setIcon(int iconNumber)
|
||||
|
||||
if (m_data.iconNumber != iconNumber || !m_data.customIcon.isNull()) {
|
||||
m_data.iconNumber = iconNumber;
|
||||
m_data.customIcon = Uuid();
|
||||
m_data.customIcon = QUuid();
|
||||
|
||||
emit modified();
|
||||
emitDataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Entry::setIcon(const Uuid& uuid)
|
||||
void Entry::setIcon(const QUuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
|
||||
@@ -632,7 +633,7 @@ Entry* Entry::clone(CloneFlags flags) const
|
||||
Entry* entry = new Entry();
|
||||
entry->setUpdateTimeinfo(false);
|
||||
if (flags & CloneNewUuid) {
|
||||
entry->m_uuid = Uuid::random();
|
||||
entry->m_uuid = QUuid::createUuid();
|
||||
} else {
|
||||
entry->m_uuid = m_uuid;
|
||||
}
|
||||
@@ -643,15 +644,13 @@ Entry* Entry::clone(CloneFlags flags) const
|
||||
|
||||
if (flags & CloneUserAsRef) {
|
||||
// Build the username reference
|
||||
QString username = "{REF:U@I:" + m_uuid.toHex() + "}";
|
||||
entry->m_attributes->set(
|
||||
EntryAttributes::UserNameKey, username.toUpper(), m_attributes->isProtected(EntryAttributes::UserNameKey));
|
||||
QString username = "{REF:U@I:" + m_uuid.toRfc4122().toHex() + "}";
|
||||
entry->m_attributes->set(EntryAttributes::UserNameKey, username.toUpper(), m_attributes->isProtected(EntryAttributes::UserNameKey));
|
||||
}
|
||||
|
||||
if (flags & ClonePassAsRef) {
|
||||
QString password = "{REF:P@I:" + m_uuid.toHex() + "}";
|
||||
entry->m_attributes->set(
|
||||
EntryAttributes::PasswordKey, password.toUpper(), m_attributes->isProtected(EntryAttributes::PasswordKey));
|
||||
QString password = "{REF:P@I:" + m_uuid.toRfc4122().toHex() + "}";
|
||||
entry->m_attributes->set(EntryAttributes::PasswordKey, password.toUpper(), m_attributes->isProtected(EntryAttributes::PasswordKey));
|
||||
}
|
||||
|
||||
entry->m_autoTypeAssociations->copyDataFrom(m_autoTypeAssociations);
|
||||
@@ -757,7 +756,7 @@ void Entry::updateTotp()
|
||||
QString Entry::resolveMultiplePlaceholdersRecursive(const QString& str, int maxDepth) const
|
||||
{
|
||||
if (maxDepth <= 0) {
|
||||
qWarning("Maximum depth of replacement has been reached. Entry uuid: %s", qPrintable(uuid().toHex()));
|
||||
qWarning() << QString("Maximum depth of replacement has been reached. Entry uuid: %1").arg(uuid().toString());
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -781,7 +780,7 @@ QString Entry::resolveMultiplePlaceholdersRecursive(const QString& str, int maxD
|
||||
QString Entry::resolvePlaceholderRecursive(const QString& placeholder, int maxDepth) const
|
||||
{
|
||||
if (maxDepth <= 0) {
|
||||
qWarning("Maximum depth of replacement has been reached. Entry uuid: %s", qPrintable(uuid().toHex()));
|
||||
qWarning() << QString("Maximum depth of replacement has been reached. Entry uuid: %1").arg(uuid().toString());
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
@@ -845,7 +844,7 @@ QString Entry::resolvePlaceholderRecursive(const QString& placeholder, int maxDe
|
||||
QString Entry::resolveReferencePlaceholderRecursive(const QString& placeholder, int maxDepth) const
|
||||
{
|
||||
if (maxDepth <= 0) {
|
||||
qWarning("Maximum depth of replacement has been reached. Entry uuid: %s", qPrintable(uuid().toHex()));
|
||||
qWarning() << QString("Maximum depth of replacement has been reached. Entry uuid: %1").arg(uuid().toString());
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
@@ -893,8 +892,8 @@ QString Entry::referenceFieldValue(EntryReferenceType referenceType) const
|
||||
return url();
|
||||
case EntryReferenceType::Notes:
|
||||
return notes();
|
||||
case EntryReferenceType::Uuid:
|
||||
return uuid().toHex();
|
||||
case EntryReferenceType::QUuid:
|
||||
return uuid().toRfc4122().toHex();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
#include <QPointer>
|
||||
#include <QSet>
|
||||
#include <QUrl>
|
||||
#include <QUuid>
|
||||
|
||||
#include "core/AutoTypeAssociations.h"
|
||||
#include "core/CustomData.h"
|
||||
#include "core/EntryAttachments.h"
|
||||
#include "core/EntryAttributes.h"
|
||||
#include "core/TimeInfo.h"
|
||||
#include "core/Uuid.h"
|
||||
|
||||
class Database;
|
||||
class Group;
|
||||
@@ -45,14 +45,14 @@ enum class EntryReferenceType
|
||||
Password,
|
||||
Url,
|
||||
Notes,
|
||||
Uuid,
|
||||
QUuid,
|
||||
CustomAttributes
|
||||
};
|
||||
|
||||
struct EntryData
|
||||
{
|
||||
int iconNumber;
|
||||
Uuid customIcon;
|
||||
QUuid customIcon;
|
||||
QColor foregroundColor;
|
||||
QColor backgroundColor;
|
||||
QString overrideUrl;
|
||||
@@ -72,12 +72,12 @@ class Entry : public QObject
|
||||
public:
|
||||
Entry();
|
||||
~Entry();
|
||||
Uuid uuid() const;
|
||||
const QUuid& uuid() const;
|
||||
QImage icon() const;
|
||||
QPixmap iconPixmap() const;
|
||||
QPixmap iconScaledPixmap() const;
|
||||
int iconNumber() const;
|
||||
Uuid iconUuid() const;
|
||||
const QUuid& iconUuid() const;
|
||||
QColor foregroundColor() const;
|
||||
QColor backgroundColor() const;
|
||||
QString overrideUrl() const;
|
||||
@@ -117,9 +117,9 @@ public:
|
||||
static const QString AutoTypeSequenceUsername;
|
||||
static const QString AutoTypeSequencePassword;
|
||||
|
||||
void setUuid(const Uuid& uuid);
|
||||
void setUuid(const QUuid& uuid);
|
||||
void setIcon(int iconNumber);
|
||||
void setIcon(const Uuid& uuid);
|
||||
void setIcon(const QUuid& uuid);
|
||||
void setForegroundColor(const QColor& color);
|
||||
void setBackgroundColor(const QColor& color);
|
||||
void setOverrideUrl(const QString& url);
|
||||
@@ -232,7 +232,7 @@ private:
|
||||
const Database* database() const;
|
||||
template <class T> bool set(T& property, const T& value);
|
||||
|
||||
Uuid m_uuid;
|
||||
QUuid m_uuid;
|
||||
EntryData m_data;
|
||||
QPointer<EntryAttributes> m_attributes;
|
||||
QPointer<EntryAttachments> m_attachments;
|
||||
|
||||
@@ -73,7 +73,7 @@ Group::~Group()
|
||||
Group* Group::createRecycleBin()
|
||||
{
|
||||
Group* recycleBin = new Group();
|
||||
recycleBin->setUuid(Uuid::random());
|
||||
recycleBin->setUuid(QUuid::createUuid());
|
||||
recycleBin->setName(tr("Recycle Bin"));
|
||||
recycleBin->setIcon(RecycleBinIconNumber);
|
||||
recycleBin->setSearchingEnabled(Group::Disable);
|
||||
@@ -105,7 +105,7 @@ void Group::setUpdateTimeinfo(bool value)
|
||||
m_updateTimeinfo = value;
|
||||
}
|
||||
|
||||
Uuid Group::uuid() const
|
||||
const QUuid& Group::uuid() const
|
||||
{
|
||||
return m_uuid;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ int Group::iconNumber() const
|
||||
return m_data.iconNumber;
|
||||
}
|
||||
|
||||
Uuid Group::iconUuid() const
|
||||
const QUuid& Group::iconUuid() const
|
||||
{
|
||||
return m_data.customIcon;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ const CustomData* Group::customData() const
|
||||
return m_customData;
|
||||
}
|
||||
|
||||
void Group::setUuid(const Uuid& uuid)
|
||||
void Group::setUuid(const QUuid& uuid)
|
||||
{
|
||||
set(m_uuid, uuid);
|
||||
}
|
||||
@@ -282,13 +282,13 @@ void Group::setIcon(int iconNumber)
|
||||
|
||||
if (m_data.iconNumber != iconNumber || !m_data.customIcon.isNull()) {
|
||||
m_data.iconNumber = iconNumber;
|
||||
m_data.customIcon = Uuid();
|
||||
m_data.customIcon = QUuid();
|
||||
emit modified();
|
||||
emit dataChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Group::setIcon(const Uuid& uuid)
|
||||
void Group::setIcon(const QUuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
|
||||
@@ -514,8 +514,9 @@ Entry* Group::findEntry(QString entryId)
|
||||
Q_ASSERT(!entryId.isNull());
|
||||
|
||||
Entry* entry;
|
||||
if (Uuid::isUuid(entryId)) {
|
||||
entry = findEntryByUuid(Uuid::fromHex(entryId));
|
||||
QUuid entryUuid = QUuid::fromRfc4122(QByteArray::fromHex(entryId.toLatin1()));
|
||||
if (!entryUuid.isNull()) {
|
||||
entry = findEntryByUuid(entryUuid);
|
||||
if (entry) {
|
||||
return entry;
|
||||
}
|
||||
@@ -535,7 +536,7 @@ Entry* Group::findEntry(QString entryId)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Entry* Group::findEntryByUuid(const Uuid& uuid)
|
||||
Entry* Group::findEntryByUuid(const QUuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
for (Entry* entry : entriesRecursive(false)) {
|
||||
@@ -654,9 +655,9 @@ QList<Group*> Group::groupsRecursive(bool includeSelf)
|
||||
return groupList;
|
||||
}
|
||||
|
||||
QSet<Uuid> Group::customIconsRecursive() const
|
||||
QSet<QUuid> Group::customIconsRecursive() const
|
||||
{
|
||||
QSet<Uuid> result;
|
||||
QSet<QUuid> result;
|
||||
|
||||
if (!iconUuid().isNull()) {
|
||||
result.insert(iconUuid());
|
||||
@@ -730,7 +731,7 @@ void Group::merge(const Group* other)
|
||||
emit modified();
|
||||
}
|
||||
|
||||
Group* Group::findChildByUuid(const Uuid& uuid)
|
||||
Group* Group::findChildByUuid(const QUuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
for (Group* group : groupsRecursive(true)) {
|
||||
@@ -760,7 +761,7 @@ Group* Group::clone(Entry::CloneFlags entryFlags, Group::CloneFlags groupFlags)
|
||||
clonedGroup->setUpdateTimeinfo(false);
|
||||
|
||||
if (groupFlags & Group::CloneNewUuid) {
|
||||
clonedGroup->setUuid(Uuid::random());
|
||||
clonedGroup->setUuid(QUuid::createUuid());
|
||||
} else {
|
||||
clonedGroup->setUuid(this->uuid());
|
||||
}
|
||||
@@ -1042,7 +1043,7 @@ Entry* Group::addEntryWithPath(QString entryPath)
|
||||
|
||||
Entry* entry = new Entry();
|
||||
entry->setTitle(entryTitle);
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
entry->setGroup(group);
|
||||
|
||||
return entry;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "core/Database.h"
|
||||
#include "core/Entry.h"
|
||||
#include "core/TimeInfo.h"
|
||||
#include "core/Uuid.h"
|
||||
|
||||
class Group : public QObject
|
||||
{
|
||||
@@ -63,7 +62,7 @@ public:
|
||||
QString name;
|
||||
QString notes;
|
||||
int iconNumber;
|
||||
Uuid customIcon;
|
||||
QUuid customIcon;
|
||||
TimeInfo timeInfo;
|
||||
bool isExpanded;
|
||||
QString defaultAutoTypeSequence;
|
||||
@@ -77,14 +76,14 @@ public:
|
||||
|
||||
static Group* createRecycleBin();
|
||||
|
||||
Uuid uuid() const;
|
||||
const QUuid& uuid() const;
|
||||
QString name() const;
|
||||
QString notes() const;
|
||||
QImage icon() const;
|
||||
QPixmap iconPixmap() const;
|
||||
QPixmap iconScaledPixmap() const;
|
||||
int iconNumber() const;
|
||||
Uuid iconUuid() const;
|
||||
const QUuid& iconUuid() const;
|
||||
TimeInfo timeInfo() const;
|
||||
bool isExpanded() const;
|
||||
QString defaultAutoTypeSequence() const;
|
||||
@@ -106,18 +105,18 @@ public:
|
||||
static const QString RootAutoTypeSequence;
|
||||
|
||||
Group* findChildByName(const QString& name);
|
||||
Group* findChildByUuid(const Uuid& uuid);
|
||||
Group* findChildByUuid(const QUuid& uuid);
|
||||
Entry* findEntry(QString entryId);
|
||||
Entry* findEntryByUuid(const Uuid& uuid);
|
||||
Entry* findEntryByUuid(const QUuid& uuid);
|
||||
Entry* findEntryByPath(QString entryPath, QString basePath = QString(""));
|
||||
Group* findGroupByPath(QString groupPath, QString basePath = QString("/"));
|
||||
QStringList locate(QString locateTerm, QString currentPath = QString("/"));
|
||||
Entry* addEntryWithPath(QString entryPath);
|
||||
void setUuid(const Uuid& uuid);
|
||||
void setUuid(const QUuid& uuid);
|
||||
void setName(const QString& name);
|
||||
void setNotes(const QString& notes);
|
||||
void setIcon(int iconNumber);
|
||||
void setIcon(const Uuid& uuid);
|
||||
void setIcon(const QUuid& uuid);
|
||||
void setTimeInfo(const TimeInfo& timeInfo);
|
||||
void setExpanded(bool expanded);
|
||||
void setDefaultAutoTypeSequence(const QString& sequence);
|
||||
@@ -144,7 +143,7 @@ public:
|
||||
QList<Entry*> entriesRecursive(bool includeHistoryItems = false) const;
|
||||
QList<const Group*> groupsRecursive(bool includeSelf) const;
|
||||
QList<Group*> groupsRecursive(bool includeSelf);
|
||||
QSet<Uuid> customIconsRecursive() const;
|
||||
QSet<QUuid> customIconsRecursive() const;
|
||||
/**
|
||||
* Creates a duplicate of this group.
|
||||
* Note that you need to copy the custom icons manually when inserting the
|
||||
@@ -197,7 +196,7 @@ private:
|
||||
void recCreateDelObjects();
|
||||
|
||||
QPointer<Database> m_db;
|
||||
Uuid m_uuid;
|
||||
QUuid m_uuid;
|
||||
GroupData m_data;
|
||||
QPointer<Entry> m_lastTopVisibleEntry;
|
||||
QList<Group*> m_children;
|
||||
|
||||
@@ -160,12 +160,12 @@ bool Metadata::protectNotes() const
|
||||
return m_data.protectNotes;
|
||||
}
|
||||
|
||||
QImage Metadata::customIcon(const Uuid& uuid) const
|
||||
QImage Metadata::customIcon(const QUuid& uuid) const
|
||||
{
|
||||
return m_customIcons.value(uuid);
|
||||
}
|
||||
|
||||
QPixmap Metadata::customIconPixmap(const Uuid& uuid) const
|
||||
QPixmap Metadata::customIconPixmap(const QUuid& uuid) const
|
||||
{
|
||||
QPixmap pixmap;
|
||||
|
||||
@@ -183,7 +183,7 @@ QPixmap Metadata::customIconPixmap(const Uuid& uuid) const
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QPixmap Metadata::customIconScaledPixmap(const Uuid& uuid) const
|
||||
QPixmap Metadata::customIconScaledPixmap(const QUuid& uuid) const
|
||||
{
|
||||
QPixmap pixmap;
|
||||
|
||||
@@ -202,28 +202,28 @@ QPixmap Metadata::customIconScaledPixmap(const Uuid& uuid) const
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
bool Metadata::containsCustomIcon(const Uuid& uuid) const
|
||||
bool Metadata::containsCustomIcon(const QUuid& uuid) const
|
||||
{
|
||||
return m_customIcons.contains(uuid);
|
||||
}
|
||||
|
||||
QHash<Uuid, QImage> Metadata::customIcons() const
|
||||
QHash<QUuid, QImage> Metadata::customIcons() const
|
||||
{
|
||||
return m_customIcons;
|
||||
}
|
||||
|
||||
QHash<Uuid, QPixmap> Metadata::customIconsScaledPixmaps() const
|
||||
QHash<QUuid, QPixmap> Metadata::customIconsScaledPixmaps() const
|
||||
{
|
||||
QHash<Uuid, QPixmap> result;
|
||||
QHash<QUuid, QPixmap> result;
|
||||
|
||||
for (const Uuid& uuid : m_customIconsOrder) {
|
||||
for (const QUuid& uuid : m_customIconsOrder) {
|
||||
result.insert(uuid, customIconScaledPixmap(uuid));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<Uuid> Metadata::customIconsOrder() const
|
||||
QList<QUuid> Metadata::customIconsOrder() const
|
||||
{
|
||||
return m_customIconsOrder;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ void Metadata::setProtectNotes(bool value)
|
||||
set(m_data.protectNotes, value);
|
||||
}
|
||||
|
||||
void Metadata::addCustomIcon(const Uuid& uuid, const QImage& icon)
|
||||
void Metadata::addCustomIcon(const QUuid& uuid, const QImage& icon)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
Q_ASSERT(!m_customIcons.contains(uuid));
|
||||
@@ -395,7 +395,7 @@ void Metadata::addCustomIcon(const Uuid& uuid, const QImage& icon)
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void Metadata::addCustomIconScaled(const Uuid& uuid, const QImage& icon)
|
||||
void Metadata::addCustomIconScaled(const QUuid& uuid, const QImage& icon)
|
||||
{
|
||||
QImage iconScaled;
|
||||
|
||||
@@ -409,7 +409,7 @@ void Metadata::addCustomIconScaled(const Uuid& uuid, const QImage& icon)
|
||||
addCustomIcon(uuid, iconScaled);
|
||||
}
|
||||
|
||||
void Metadata::removeCustomIcon(const Uuid& uuid)
|
||||
void Metadata::removeCustomIcon(const QUuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
Q_ASSERT(m_customIcons.contains(uuid));
|
||||
@@ -430,15 +430,15 @@ void Metadata::removeCustomIcon(const Uuid& uuid)
|
||||
emit modified();
|
||||
}
|
||||
|
||||
Uuid Metadata::findCustomIcon(const QImage& candidate)
|
||||
QUuid Metadata::findCustomIcon(const QImage &candidate)
|
||||
{
|
||||
QByteArray hash = hashImage(candidate);
|
||||
return m_customIconsHashes.value(hash, Uuid());
|
||||
return m_customIconsHashes.value(hash, QUuid());
|
||||
}
|
||||
|
||||
void Metadata::copyCustomIcons(const QSet<Uuid>& iconList, const Metadata* otherMetadata)
|
||||
void Metadata::copyCustomIcons(const QSet<QUuid>& iconList, const Metadata* otherMetadata)
|
||||
{
|
||||
for (const Uuid& uuid : iconList) {
|
||||
for (const QUuid& uuid : iconList) {
|
||||
Q_ASSERT(otherMetadata->containsCustomIcon(uuid));
|
||||
|
||||
if (!containsCustomIcon(uuid) && otherMetadata->containsCustomIcon(uuid)) {
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
#include <QPointer>
|
||||
#include <QUuid>
|
||||
|
||||
#include "core/CustomData.h"
|
||||
#include "core/Uuid.h"
|
||||
|
||||
class Database;
|
||||
class Group;
|
||||
@@ -78,14 +78,14 @@ public:
|
||||
bool protectPassword() const;
|
||||
bool protectUrl() const;
|
||||
bool protectNotes() const;
|
||||
QImage customIcon(const Uuid& uuid) const;
|
||||
QPixmap customIconPixmap(const Uuid& uuid) const;
|
||||
QPixmap customIconScaledPixmap(const Uuid& uuid) const;
|
||||
bool containsCustomIcon(const Uuid& uuid) const;
|
||||
QHash<Uuid, QImage> customIcons() const;
|
||||
QList<Uuid> customIconsOrder() const;
|
||||
QImage customIcon(const QUuid& uuid) const;
|
||||
QPixmap customIconPixmap(const QUuid& uuid) const;
|
||||
QPixmap customIconScaledPixmap(const QUuid& uuid) const;
|
||||
bool containsCustomIcon(const QUuid& uuid) const;
|
||||
QHash<QUuid, QImage> customIcons() const;
|
||||
QList<QUuid> customIconsOrder() const;
|
||||
bool recycleBinEnabled() const;
|
||||
QHash<Uuid, QPixmap> customIconsScaledPixmaps() const;
|
||||
QHash<QUuid, QPixmap> customIconsScaledPixmaps() const;
|
||||
Group* recycleBin();
|
||||
const Group* recycleBin() const;
|
||||
QDateTime recycleBinChanged() const;
|
||||
@@ -119,11 +119,11 @@ public:
|
||||
void setProtectPassword(bool value);
|
||||
void setProtectUrl(bool value);
|
||||
void setProtectNotes(bool value);
|
||||
void addCustomIcon(const Uuid& uuid, const QImage& icon);
|
||||
void addCustomIconScaled(const Uuid& uuid, const QImage& icon);
|
||||
void removeCustomIcon(const Uuid& uuid);
|
||||
void copyCustomIcons(const QSet<Uuid>& iconList, const Metadata* otherMetadata);
|
||||
Uuid findCustomIcon(const QImage& candidate);
|
||||
void addCustomIcon(const QUuid& uuid, const QImage& icon);
|
||||
void addCustomIconScaled(const QUuid& uuid, const QImage& icon);
|
||||
void removeCustomIcon(const QUuid& uuid);
|
||||
void copyCustomIcons(const QSet<QUuid>& iconList, const Metadata* otherMetadata);
|
||||
QUuid findCustomIcon(const QImage& candidate);
|
||||
void setRecycleBinEnabled(bool value);
|
||||
void setRecycleBin(Group* group);
|
||||
void setRecycleBinChanged(const QDateTime& value);
|
||||
@@ -159,11 +159,11 @@ private:
|
||||
|
||||
MetadataData m_data;
|
||||
|
||||
QHash<Uuid, QImage> m_customIcons;
|
||||
mutable QHash<Uuid, QPixmapCache::Key> m_customIconCacheKeys;
|
||||
mutable QHash<Uuid, QPixmapCache::Key> m_customIconScaledCacheKeys;
|
||||
QList<Uuid> m_customIconsOrder;
|
||||
QHash<QByteArray, Uuid> m_customIconsHashes;
|
||||
QHash<QUuid, QImage> m_customIcons;
|
||||
mutable QHash<QUuid, QPixmapCache::Key> m_customIconCacheKeys;
|
||||
mutable QHash<QUuid, QPixmapCache::Key> m_customIconScaledCacheKeys;
|
||||
QList<QUuid> m_customIconsOrder;
|
||||
QHash<QByteArray, QUuid> m_customIconsHashes;
|
||||
|
||||
QPointer<Group> m_recycleBin;
|
||||
QDateTime m_recycleBinChanged;
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 or (at your option)
|
||||
* version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Uuid.h"
|
||||
|
||||
#include <QHash>
|
||||
|
||||
#include "crypto/Random.h"
|
||||
|
||||
const int Uuid::Length = 16;
|
||||
const QRegExp Uuid::HexRegExp =
|
||||
QRegExp(QString("^[0-9A-F]{%1}$").arg(QString::number(Uuid::Length * 2)), Qt::CaseInsensitive);
|
||||
|
||||
Uuid::Uuid()
|
||||
: m_data(Length, 0)
|
||||
{
|
||||
}
|
||||
|
||||
Uuid::Uuid(const QByteArray& data)
|
||||
{
|
||||
Q_ASSERT(data.size() == Length);
|
||||
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
Uuid Uuid::random()
|
||||
{
|
||||
return Uuid(randomGen()->randomArray(Length));
|
||||
}
|
||||
|
||||
QString Uuid::toBase64() const
|
||||
{
|
||||
return QString::fromLatin1(m_data.toBase64());
|
||||
}
|
||||
|
||||
QString Uuid::toHex() const
|
||||
{
|
||||
return QString::fromLatin1(m_data.toHex());
|
||||
}
|
||||
|
||||
QByteArray Uuid::toByteArray() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
bool Uuid::isNull() const
|
||||
{
|
||||
for (int i = 0; i < m_data.size(); ++i) {
|
||||
if (m_data[i] != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Uuid& Uuid::operator=(const Uuid& other)
|
||||
{
|
||||
m_data = other.m_data;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Uuid::operator==(const Uuid& other) const
|
||||
{
|
||||
return m_data == other.m_data;
|
||||
}
|
||||
|
||||
bool Uuid::operator!=(const Uuid& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
Uuid Uuid::fromBase64(const QString& str)
|
||||
{
|
||||
QByteArray data = QByteArray::fromBase64(str.toLatin1());
|
||||
return Uuid(data);
|
||||
}
|
||||
|
||||
Uuid Uuid::fromHex(const QString& str)
|
||||
{
|
||||
QByteArray data = QByteArray::fromHex(str.toLatin1());
|
||||
return Uuid(data);
|
||||
}
|
||||
|
||||
uint qHash(const Uuid& key)
|
||||
{
|
||||
return qHash(key.toByteArray());
|
||||
}
|
||||
|
||||
QDataStream& operator<<(QDataStream& stream, const Uuid& uuid)
|
||||
{
|
||||
return stream << uuid.toByteArray();
|
||||
}
|
||||
|
||||
QDataStream& operator>>(QDataStream& stream, Uuid& uuid)
|
||||
{
|
||||
QByteArray data;
|
||||
stream >> data;
|
||||
if (data.size() == Uuid::Length) {
|
||||
uuid = Uuid(data);
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
bool Uuid::isUuid(const QString& uuid)
|
||||
{
|
||||
return Uuid::HexRegExp.exactMatch(uuid);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 or (at your option)
|
||||
* version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KEEPASSX_UUID_H
|
||||
#define KEEPASSX_UUID_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QRegExp>
|
||||
#include <QString>
|
||||
|
||||
class Uuid
|
||||
{
|
||||
public:
|
||||
Uuid();
|
||||
explicit Uuid(const QByteArray& data);
|
||||
static Uuid random();
|
||||
QString toBase64() const;
|
||||
QString toHex() const;
|
||||
QByteArray toByteArray() const;
|
||||
|
||||
bool isNull() const;
|
||||
Uuid& operator=(const Uuid& other);
|
||||
bool operator==(const Uuid& other) const;
|
||||
bool operator!=(const Uuid& other) const;
|
||||
static const int Length;
|
||||
static const QRegExp HexRegExp;
|
||||
static Uuid fromBase64(const QString& str);
|
||||
static Uuid fromHex(const QString& str);
|
||||
static bool isUuid(const QString& str);
|
||||
|
||||
private:
|
||||
QByteArray m_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(Uuid, Q_MOVABLE_TYPE);
|
||||
|
||||
uint qHash(const Uuid& key);
|
||||
|
||||
QDataStream& operator<<(QDataStream& stream, const Uuid& uuid);
|
||||
QDataStream& operator>>(QDataStream& stream, Uuid& uuid);
|
||||
|
||||
#endif // KEEPASSX_UUID_H
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "config-keepassx.h"
|
||||
#include "crypto/SymmetricCipherGcrypt.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
SymmetricCipher::SymmetricCipher(Algorithm algo, Mode mode, Direction direction)
|
||||
: m_backend(createBackend(algo, mode, direction))
|
||||
, m_initialized(false)
|
||||
@@ -90,7 +92,7 @@ QString SymmetricCipher::errorString() const
|
||||
return m_backend->errorString();
|
||||
}
|
||||
|
||||
SymmetricCipher::Algorithm SymmetricCipher::cipherToAlgorithm(Uuid cipher)
|
||||
SymmetricCipher::Algorithm SymmetricCipher::cipherToAlgorithm(const QUuid& cipher)
|
||||
{
|
||||
if (cipher == KeePass2::CIPHER_AES) {
|
||||
return Aes256;
|
||||
@@ -100,11 +102,11 @@ SymmetricCipher::Algorithm SymmetricCipher::cipherToAlgorithm(Uuid cipher)
|
||||
return Twofish;
|
||||
}
|
||||
|
||||
qWarning("SymmetricCipher::cipherToAlgorithm: invalid Uuid %s", cipher.toByteArray().toHex().data());
|
||||
qWarning() << "SymmetricCipher::cipherToAlgorithm: invalid UUID " << cipher;
|
||||
return InvalidAlgorithm;
|
||||
}
|
||||
|
||||
Uuid SymmetricCipher::algorithmToCipher(Algorithm algo)
|
||||
QUuid SymmetricCipher::algorithmToCipher(Algorithm algo)
|
||||
{
|
||||
switch (algo) {
|
||||
case Aes256:
|
||||
@@ -115,7 +117,7 @@ Uuid SymmetricCipher::algorithmToCipher(Algorithm algo)
|
||||
return KeePass2::CIPHER_TWOFISH;
|
||||
default:
|
||||
qWarning("SymmetricCipher::algorithmToCipher: invalid algorithm %d", algo);
|
||||
return Uuid();
|
||||
return QUuid();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#include <QByteArray>
|
||||
#include <QScopedPointer>
|
||||
#include <QString>
|
||||
#include <QUuid>
|
||||
|
||||
#include "core/Uuid.h"
|
||||
#include "crypto/SymmetricCipherBackend.h"
|
||||
#include "format/KeePass2.h"
|
||||
|
||||
@@ -83,8 +83,8 @@ public:
|
||||
QString errorString() const;
|
||||
Algorithm algorithm() const;
|
||||
|
||||
static Algorithm cipherToAlgorithm(Uuid cipher);
|
||||
static Uuid algorithmToCipher(Algorithm algo);
|
||||
static Algorithm cipherToAlgorithm(const QUuid& cipher);
|
||||
static QUuid algorithmToCipher(Algorithm algo);
|
||||
static int algorithmIvSize(Algorithm algo);
|
||||
static Mode algorithmMode(Algorithm algo);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ QVariantMap AesKdf::writeParameters()
|
||||
QVariantMap p;
|
||||
|
||||
// always write old KDBX3 AES-KDF UUID for compatibility with other applications
|
||||
p.insert(KeePass2::KDFPARAM_UUID, KeePass2::KDF_AES_KDBX3.toByteArray());
|
||||
p.insert(KeePass2::KDFPARAM_UUID, KeePass2::KDF_AES_KDBX3.toRfc4122());
|
||||
|
||||
p.insert(KeePass2::KDFPARAM_AES_ROUNDS, static_cast<quint64>(rounds()));
|
||||
p.insert(KeePass2::KDFPARAM_AES_SEED, seed());
|
||||
|
||||
@@ -133,7 +133,7 @@ bool Argon2Kdf::processParameters(const QVariantMap& p)
|
||||
QVariantMap Argon2Kdf::writeParameters()
|
||||
{
|
||||
QVariantMap p;
|
||||
p.insert(KeePass2::KDFPARAM_UUID, KeePass2::KDF_ARGON2.toByteArray());
|
||||
p.insert(KeePass2::KDFPARAM_UUID, KeePass2::KDF_ARGON2.toRfc4122());
|
||||
p.insert(KeePass2::KDFPARAM_ARGON2_VERSION, version());
|
||||
p.insert(KeePass2::KDFPARAM_ARGON2_PARALLELISM, parallelism());
|
||||
p.insert(KeePass2::KDFPARAM_ARGON2_MEMORY, memory() * 1024);
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
|
||||
#include "crypto/Random.h"
|
||||
|
||||
Kdf::Kdf(Uuid uuid)
|
||||
Kdf::Kdf(const QUuid& uuid)
|
||||
: m_rounds(KDF_DEFAULT_ROUNDS)
|
||||
, m_seed(QByteArray(KDF_DEFAULT_SEED_SIZE, 0))
|
||||
, m_uuid(uuid)
|
||||
{
|
||||
}
|
||||
|
||||
Uuid Kdf::uuid() const
|
||||
const QUuid& Kdf::uuid() const
|
||||
{
|
||||
return m_uuid;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#define KEEPASSX_KDF_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "core/Uuid.h"
|
||||
#include <QUuid.h>
|
||||
|
||||
#define KDF_DEFAULT_SEED_SIZE 32
|
||||
#define KDF_DEFAULT_ROUNDS 1000000ull
|
||||
@@ -28,10 +27,10 @@
|
||||
class Kdf
|
||||
{
|
||||
public:
|
||||
explicit Kdf(Uuid uuid);
|
||||
explicit Kdf(const QUuid& uuid);
|
||||
virtual ~Kdf() = default;
|
||||
|
||||
Uuid uuid() const;
|
||||
const QUuid& uuid() const;
|
||||
|
||||
int rounds() const;
|
||||
virtual bool setRounds(int rounds);
|
||||
@@ -54,7 +53,6 @@ protected:
|
||||
|
||||
private:
|
||||
class BenchmarkThread;
|
||||
const Uuid m_uuid;
|
||||
const QUuid m_uuid;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_KDF_H
|
||||
|
||||
@@ -65,12 +65,10 @@ bool Kdbx3Writer::writeDatabase(QIODevice* device, Database* db)
|
||||
|
||||
writeMagicNumbers(&header, KeePass2::SIGNATURE_1, KeePass2::SIGNATURE_2, KeePass2::FILE_VERSION_3_1);
|
||||
|
||||
CHECK_RETURN_FALSE(
|
||||
writeHeaderField<quint16>(&header, KeePass2::HeaderFieldID::CipherID, db->cipher().toByteArray()));
|
||||
CHECK_RETURN_FALSE(
|
||||
writeHeaderField<quint16>(&header,
|
||||
KeePass2::HeaderFieldID::CompressionFlags,
|
||||
Endian::sizedIntToBytes<qint32>(db->compressionAlgo(), KeePass2::BYTEORDER)));
|
||||
CHECK_RETURN_FALSE(writeHeaderField<quint16>(&header, KeePass2::HeaderFieldID::CipherID, db->cipher().toRfc4122()));
|
||||
CHECK_RETURN_FALSE(writeHeaderField<quint16>(&header, KeePass2::HeaderFieldID::CompressionFlags,
|
||||
Endian::sizedIntToBytes<qint32>(db->compressionAlgo(),
|
||||
KeePass2::BYTEORDER)));
|
||||
auto kdf = db->kdf();
|
||||
CHECK_RETURN_FALSE(writeHeaderField<quint16>(&header, KeePass2::HeaderFieldID::MasterSeed, masterSeed));
|
||||
CHECK_RETURN_FALSE(writeHeaderField<quint16>(&header, KeePass2::HeaderFieldID::TransformSeed, kdf->seed()));
|
||||
|
||||
@@ -73,12 +73,10 @@ bool Kdbx4Writer::writeDatabase(QIODevice* device, Database* db)
|
||||
|
||||
writeMagicNumbers(&header, KeePass2::SIGNATURE_1, KeePass2::SIGNATURE_2, KeePass2::FILE_VERSION_4);
|
||||
|
||||
CHECK_RETURN_FALSE(
|
||||
writeHeaderField<quint32>(&header, KeePass2::HeaderFieldID::CipherID, db->cipher().toByteArray()));
|
||||
CHECK_RETURN_FALSE(writeHeaderField<quint32>(
|
||||
&header,
|
||||
KeePass2::HeaderFieldID::CompressionFlags,
|
||||
Endian::sizedIntToBytes(static_cast<int>(db->compressionAlgo()), KeePass2::BYTEORDER)));
|
||||
CHECK_RETURN_FALSE(writeHeaderField<quint32>(&header, KeePass2::HeaderFieldID::CipherID, db->cipher().toRfc4122()));
|
||||
CHECK_RETURN_FALSE(writeHeaderField<quint32>(&header, KeePass2::HeaderFieldID::CompressionFlags,
|
||||
Endian::sizedIntToBytes(static_cast<int>(db->compressionAlgo()),
|
||||
KeePass2::BYTEORDER)));
|
||||
CHECK_RETURN_FALSE(writeHeaderField<quint32>(&header, KeePass2::HeaderFieldID::MasterSeed, masterSeed));
|
||||
CHECK_RETURN_FALSE(writeHeaderField<quint32>(&header, KeePass2::HeaderFieldID::EncryptionIV, encryptionIV));
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "core/Database.h"
|
||||
#include "core/Endian.h"
|
||||
|
||||
#define UUID_LENGHT 16
|
||||
|
||||
/**
|
||||
* Read KDBX magic header numbers from a device.
|
||||
*
|
||||
@@ -133,12 +135,16 @@ KeePass2::ProtectedStreamAlgo KdbxReader::protectedStreamAlgo() const
|
||||
*/
|
||||
void KdbxReader::setCipher(const QByteArray& data)
|
||||
{
|
||||
if (data.size() != Uuid::Length) {
|
||||
raiseError(tr("Invalid cipher uuid length"));
|
||||
if (data.size() != UUID_LENGHT) {
|
||||
raiseError(tr("Invalid cipher uuid length: %1 (length=%2)").arg(QString(data)).arg(data.size()));
|
||||
return;
|
||||
}
|
||||
|
||||
Uuid uuid(data);
|
||||
QUuid uuid = QUuid::fromRfc4122(data);
|
||||
if (uuid.isNull()) {
|
||||
raiseError(tr("Unable to parse UUID: %1").arg(QString(data)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (SymmetricCipher::cipherToAlgorithm(uuid) == SymmetricCipher::InvalidAlgorithm) {
|
||||
raiseError(tr("Unsupported cipher"));
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <QBuffer>
|
||||
#include <QFile>
|
||||
|
||||
#define UUID_LENGHT 16
|
||||
|
||||
/**
|
||||
* @param version KDBX version
|
||||
*/
|
||||
@@ -142,12 +144,12 @@ void KdbxXmlReader::readDatabase(QIODevice* device, Database* db, KeePass2Random
|
||||
|
||||
m_meta->setUpdateDatetime(true);
|
||||
|
||||
QHash<Uuid, Group*>::const_iterator iGroup;
|
||||
QHash<QUuid, Group*>::const_iterator iGroup;
|
||||
for (iGroup = m_groups.constBegin(); iGroup != m_groups.constEnd(); ++iGroup) {
|
||||
iGroup.value()->setUpdateTimeinfo(true);
|
||||
}
|
||||
|
||||
QHash<Uuid, Entry*>::const_iterator iEntry;
|
||||
QHash<QUuid, Entry*>::const_iterator iEntry;
|
||||
for (iEntry = m_entries.constBegin(); iEntry != m_entries.constEnd(); ++iEntry) {
|
||||
iEntry.value()->setUpdateTimeinfo(true);
|
||||
|
||||
@@ -346,7 +348,7 @@ void KdbxXmlReader::parseIcon()
|
||||
{
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Icon");
|
||||
|
||||
Uuid uuid;
|
||||
QUuid uuid;
|
||||
QImage icon;
|
||||
bool uuidSet = false;
|
||||
bool iconSet = false;
|
||||
@@ -479,12 +481,12 @@ Group* KdbxXmlReader::parseGroup()
|
||||
QList<Entry*> entries;
|
||||
while (!m_xml.hasError() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "UUID") {
|
||||
Uuid uuid = readUuid();
|
||||
QUuid uuid = readUuid();
|
||||
if (uuid.isNull()) {
|
||||
if (m_strictMode) {
|
||||
raiseError(tr("Null group uuid"));
|
||||
} else {
|
||||
group->setUuid(Uuid::random());
|
||||
group->setUuid(QUuid::createUuid());
|
||||
}
|
||||
} else {
|
||||
group->setUuid(uuid);
|
||||
@@ -515,7 +517,7 @@ Group* KdbxXmlReader::parseGroup()
|
||||
continue;
|
||||
}
|
||||
if (m_xml.name() == "CustomIconUUID") {
|
||||
Uuid uuid = readUuid();
|
||||
QUuid uuid = readUuid();
|
||||
if (!uuid.isNull()) {
|
||||
group->setIcon(uuid);
|
||||
}
|
||||
@@ -588,7 +590,7 @@ Group* KdbxXmlReader::parseGroup()
|
||||
}
|
||||
|
||||
if (group->uuid().isNull() && !m_strictMode) {
|
||||
group->setUuid(Uuid::random());
|
||||
group->setUuid(QUuid::createUuid());
|
||||
}
|
||||
|
||||
if (!group->uuid().isNull()) {
|
||||
@@ -633,10 +635,11 @@ void KdbxXmlReader::parseDeletedObject()
|
||||
|
||||
while (!m_xml.hasError() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "UUID") {
|
||||
Uuid uuid = readUuid();
|
||||
QUuid uuid = readUuid();
|
||||
if (uuid.isNull()) {
|
||||
if (m_strictMode) {
|
||||
raiseError(tr("Null DeleteObject uuid"));
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -671,12 +674,12 @@ Entry* KdbxXmlReader::parseEntry(bool history)
|
||||
|
||||
while (!m_xml.hasError() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "UUID") {
|
||||
Uuid uuid = readUuid();
|
||||
QUuid uuid = readUuid();
|
||||
if (uuid.isNull()) {
|
||||
if (m_strictMode) {
|
||||
raiseError(tr("Null entry uuid"));
|
||||
} else {
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
}
|
||||
} else {
|
||||
entry->setUuid(uuid);
|
||||
@@ -695,7 +698,7 @@ Entry* KdbxXmlReader::parseEntry(bool history)
|
||||
continue;
|
||||
}
|
||||
if (m_xml.name() == "CustomIconUUID") {
|
||||
Uuid uuid = readUuid();
|
||||
QUuid uuid = readUuid();
|
||||
if (!uuid.isNull()) {
|
||||
entry->setIcon(uuid);
|
||||
}
|
||||
@@ -752,7 +755,7 @@ Entry* KdbxXmlReader::parseEntry(bool history)
|
||||
}
|
||||
|
||||
if (entry->uuid().isNull() && !m_strictMode) {
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
}
|
||||
|
||||
if (!entry->uuid().isNull()) {
|
||||
@@ -1090,19 +1093,19 @@ int KdbxXmlReader::readNumber()
|
||||
return result;
|
||||
}
|
||||
|
||||
Uuid KdbxXmlReader::readUuid()
|
||||
QUuid KdbxXmlReader::readUuid()
|
||||
{
|
||||
QByteArray uuidBin = readBinary();
|
||||
if (uuidBin.isEmpty()) {
|
||||
return {};
|
||||
return QUuid();
|
||||
}
|
||||
if (uuidBin.length() != Uuid::Length) {
|
||||
if (uuidBin.length() != UUID_LENGHT) {
|
||||
if (m_strictMode) {
|
||||
raiseError(tr("Invalid uuid value"));
|
||||
}
|
||||
return {};
|
||||
return QUuid();
|
||||
}
|
||||
return Uuid(uuidBin);
|
||||
return QUuid::fromRfc4122(uuidBin);
|
||||
}
|
||||
|
||||
QByteArray KdbxXmlReader::readBinary()
|
||||
@@ -1146,7 +1149,7 @@ QByteArray KdbxXmlReader::readCompressedBinary()
|
||||
return result;
|
||||
}
|
||||
|
||||
Group* KdbxXmlReader::getGroup(const Uuid& uuid)
|
||||
Group* KdbxXmlReader::getGroup(const QUuid& uuid)
|
||||
{
|
||||
if (uuid.isNull()) {
|
||||
return nullptr;
|
||||
@@ -1164,7 +1167,7 @@ Group* KdbxXmlReader::getGroup(const Uuid& uuid)
|
||||
return group;
|
||||
}
|
||||
|
||||
Entry* KdbxXmlReader::getEntry(const Uuid& uuid)
|
||||
Entry* KdbxXmlReader::getEntry(const QUuid& uuid)
|
||||
{
|
||||
if (uuid.isNull()) {
|
||||
return nullptr;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "core/Database.h"
|
||||
#include "core/Metadata.h"
|
||||
#include "core/TimeInfo.h"
|
||||
#include "core/Uuid.h"
|
||||
#include "core/Database.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QPair>
|
||||
@@ -86,14 +86,14 @@ protected:
|
||||
virtual QDateTime readDateTime();
|
||||
virtual QColor readColor();
|
||||
virtual int readNumber();
|
||||
virtual Uuid readUuid();
|
||||
virtual QUuid readUuid();
|
||||
virtual QByteArray readBinary();
|
||||
virtual QByteArray readCompressedBinary();
|
||||
|
||||
virtual void skipCurrentElement();
|
||||
|
||||
virtual Group* getGroup(const Uuid& uuid);
|
||||
virtual Entry* getEntry(const Uuid& uuid);
|
||||
virtual Group* getGroup(const QUuid& uuid);
|
||||
virtual Entry* getEntry(const QUuid& uuid);
|
||||
|
||||
virtual bool isTrueValue(const QStringRef& value);
|
||||
virtual void raiseError(const QString& errorMessage);
|
||||
@@ -108,8 +108,8 @@ protected:
|
||||
QXmlStreamReader m_xml;
|
||||
|
||||
QScopedPointer<Group> m_tmpParent;
|
||||
QHash<Uuid, Group*> m_groups;
|
||||
QHash<Uuid, Entry*> m_entries;
|
||||
QHash<QUuid, Group*> m_groups;
|
||||
QHash<QUuid, Entry*> m_entries;
|
||||
|
||||
QHash<QString, QByteArray> m_binaryPool;
|
||||
QHash<QString, QPair<Entry*, QString>> m_binaryMap;
|
||||
|
||||
@@ -154,15 +154,15 @@ void KdbxXmlWriter::writeCustomIcons()
|
||||
{
|
||||
m_xml.writeStartElement("CustomIcons");
|
||||
|
||||
const QList<Uuid> customIconsOrder = m_meta->customIconsOrder();
|
||||
for (const Uuid& uuid : customIconsOrder) {
|
||||
const QList<QUuid> customIconsOrder = m_meta->customIconsOrder();
|
||||
for (const QUuid& uuid : customIconsOrder) {
|
||||
writeIcon(uuid, m_meta->customIcon(uuid));
|
||||
}
|
||||
|
||||
m_xml.writeEndElement();
|
||||
}
|
||||
|
||||
void KdbxXmlWriter::writeIcon(const Uuid& uuid, const QImage& icon)
|
||||
void KdbxXmlWriter::writeIcon(const QUuid& uuid, const QImage& icon)
|
||||
{
|
||||
m_xml.writeStartElement("Icon");
|
||||
|
||||
@@ -502,9 +502,9 @@ void KdbxXmlWriter::writeDateTime(const QString& qualifiedName, const QDateTime&
|
||||
writeString(qualifiedName, dateTimeStr);
|
||||
}
|
||||
|
||||
void KdbxXmlWriter::writeUuid(const QString& qualifiedName, const Uuid& uuid)
|
||||
void KdbxXmlWriter::writeUuid(const QString& qualifiedName, const QUuid& uuid)
|
||||
{
|
||||
writeString(qualifiedName, uuid.toBase64());
|
||||
writeString(qualifiedName, uuid.toRfc4122().toBase64());
|
||||
}
|
||||
|
||||
void KdbxXmlWriter::writeUuid(const QString& qualifiedName, const Group* group)
|
||||
@@ -512,7 +512,7 @@ void KdbxXmlWriter::writeUuid(const QString& qualifiedName, const Group* group)
|
||||
if (group) {
|
||||
writeUuid(qualifiedName, group->uuid());
|
||||
} else {
|
||||
writeUuid(qualifiedName, Uuid());
|
||||
writeUuid(qualifiedName, QUuid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ void KdbxXmlWriter::writeUuid(const QString& qualifiedName, const Entry* entry)
|
||||
if (entry) {
|
||||
writeUuid(qualifiedName, entry->uuid());
|
||||
} else {
|
||||
writeUuid(qualifiedName, Uuid());
|
||||
writeUuid(qualifiedName, QUuid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "core/Entry.h"
|
||||
#include "core/Group.h"
|
||||
#include "core/TimeInfo.h"
|
||||
#include "core/Uuid.h"
|
||||
|
||||
class KeePass2RandomStream;
|
||||
class Metadata;
|
||||
@@ -51,7 +50,7 @@ private:
|
||||
void writeMetadata();
|
||||
void writeMemoryProtection();
|
||||
void writeCustomIcons();
|
||||
void writeIcon(const Uuid& uuid, const QImage& icon);
|
||||
void writeIcon(const QUuid& uuid, const QImage& icon);
|
||||
void writeBinaries();
|
||||
void writeCustomData(const CustomData* customData);
|
||||
void writeCustomDataItem(const QString& key, const QString& value);
|
||||
@@ -69,7 +68,7 @@ private:
|
||||
void writeNumber(const QString& qualifiedName, int number);
|
||||
void writeBool(const QString& qualifiedName, bool b);
|
||||
void writeDateTime(const QString& qualifiedName, const QDateTime& dateTime);
|
||||
void writeUuid(const QString& qualifiedName, const Uuid& uuid);
|
||||
void writeUuid(const QString& qualifiedName, const QUuid& uuid);
|
||||
void writeUuid(const QString& qualifiedName, const Group* group);
|
||||
void writeUuid(const QString& qualifiedName, const Entry* entry);
|
||||
void writeBinary(const QString& qualifiedName, const QByteArray& ba);
|
||||
|
||||
@@ -207,7 +207,7 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
||||
} else {
|
||||
entry->setGroup(m_groupIds.value(groupId));
|
||||
}
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -545,7 +545,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
group->setUuid(Uuid::random());
|
||||
group->setUuid(QUuid::createUuid());
|
||||
group->setTimeInfo(timeInfo);
|
||||
m_groupIds.insert(groupId, group.data());
|
||||
m_groupLevels.insert(group.data(), groupLevel);
|
||||
@@ -846,7 +846,7 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
|
||||
quint32 numGroups = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
|
||||
pos += 4;
|
||||
|
||||
QList<Uuid> iconUuids;
|
||||
QList<QUuid> iconUuids;
|
||||
|
||||
for (quint32 i = 0; i < numIcons; i++) {
|
||||
if (data.size() < (pos + 4)) {
|
||||
@@ -865,7 +865,7 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
|
||||
icon = icon.scaled(16, 16);
|
||||
}
|
||||
|
||||
Uuid uuid = Uuid::random();
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
iconUuids.append(uuid);
|
||||
m_db->metadata()->addCustomIcon(uuid, icon);
|
||||
}
|
||||
|
||||
@@ -21,13 +21,15 @@
|
||||
#include "crypto/kdf/Argon2Kdf.h"
|
||||
#include <QSharedPointer>
|
||||
|
||||
const Uuid KeePass2::CIPHER_AES = Uuid(QByteArray::fromHex("31c1f2e6bf714350be5805216afc5aff"));
|
||||
const Uuid KeePass2::CIPHER_TWOFISH = Uuid(QByteArray::fromHex("ad68f29f576f4bb9a36ad47af965346c"));
|
||||
const Uuid KeePass2::CIPHER_CHACHA20 = Uuid(QByteArray::fromHex("D6038A2B8B6F4CB5A524339A31DBB59A"));
|
||||
#define UUID_LENGHT 16
|
||||
|
||||
const Uuid KeePass2::KDF_AES_KDBX3 = Uuid(QByteArray::fromHex("C9D9F39A628A4460BF740D08C18A4FEA"));
|
||||
const Uuid KeePass2::KDF_AES_KDBX4 = Uuid(QByteArray::fromHex("7C02BB8279A74AC0927D114A00648238"));
|
||||
const Uuid KeePass2::KDF_ARGON2 = Uuid(QByteArray::fromHex("EF636DDF8C29444B91F7A9A403E30A0C"));
|
||||
const QUuid KeePass2::CIPHER_AES = QUuid::fromRfc4122(QByteArray::fromHex("31c1f2e6bf714350be5805216afc5aff"));
|
||||
const QUuid KeePass2::CIPHER_TWOFISH = QUuid::fromRfc4122(QByteArray::fromHex("ad68f29f576f4bb9a36ad47af965346c"));
|
||||
const QUuid KeePass2::CIPHER_CHACHA20 = QUuid::fromRfc4122(QByteArray::fromHex("D6038A2B8B6F4CB5A524339A31DBB59A"));
|
||||
|
||||
const QUuid KeePass2::KDF_AES_KDBX3 = QUuid::fromRfc4122(QByteArray::fromHex("C9D9F39A628A4460BF740D08C18A4FEA"));
|
||||
const QUuid KeePass2::KDF_AES_KDBX4 = QUuid::fromRfc4122(QByteArray::fromHex("7C02BB8279A74AC0927D114A00648238"));
|
||||
const QUuid KeePass2::KDF_ARGON2 = QUuid::fromRfc4122(QByteArray::fromHex("EF636DDF8C29444B91F7A9A403E30A0C"));
|
||||
|
||||
const QByteArray KeePass2::INNER_STREAM_SALSA20_IV("\xE8\x30\x09\x4B\x97\x20\x5D\x2A");
|
||||
|
||||
@@ -44,15 +46,17 @@ const QString KeePass2::KDFPARAM_ARGON2_VERSION("V");
|
||||
const QString KeePass2::KDFPARAM_ARGON2_SECRET("K");
|
||||
const QString KeePass2::KDFPARAM_ARGON2_ASSOCDATA("A");
|
||||
|
||||
const QList<QPair<Uuid, QString>> KeePass2::CIPHERS{
|
||||
qMakePair(KeePass2::CIPHER_AES, QString(QT_TRANSLATE_NOOP("KeePass2", "AES: 256-bit"))),
|
||||
qMakePair(KeePass2::CIPHER_TWOFISH, QString(QT_TRANSLATE_NOOP("KeePass2", "Twofish: 256-bit"))),
|
||||
qMakePair(KeePass2::CIPHER_CHACHA20, QString(QT_TRANSLATE_NOOP("KeePass2", "ChaCha20: 256-bit")))};
|
||||
const QList<QPair<QUuid, 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<QPair<Uuid, QString>> KeePass2::KDFS{
|
||||
qMakePair(KeePass2::KDF_ARGON2, QString(QT_TRANSLATE_NOOP("KeePass2", "Argon2 (KDBX 4 – recommended)"))),
|
||||
qMakePair(KeePass2::KDF_AES_KDBX4, QString(QT_TRANSLATE_NOOP("KeePass2", "AES-KDF (KDBX 4)"))),
|
||||
qMakePair(KeePass2::KDF_AES_KDBX3, QString(QT_TRANSLATE_NOOP("KeePass2", "AES-KDF (KDBX 3.1)")))};
|
||||
const QList<QPair<QUuid, QString>> KeePass2::KDFS{
|
||||
qMakePair(KeePass2::KDF_ARGON2, QObject::tr("Argon2 (KDBX 4 – recommended)")),
|
||||
qMakePair(KeePass2::KDF_AES_KDBX4, QObject::tr("AES-KDF (KDBX 4)")),
|
||||
qMakePair(KeePass2::KDF_AES_KDBX3, QObject::tr("AES-KDF (KDBX 3.1)"))
|
||||
};
|
||||
|
||||
QByteArray KeePass2::hmacKey(QByteArray masterSeed, QByteArray transformedMasterKey)
|
||||
{
|
||||
@@ -72,11 +76,11 @@ QByteArray KeePass2::hmacKey(QByteArray masterSeed, QByteArray transformedMaster
|
||||
QSharedPointer<Kdf> KeePass2::kdfFromParameters(const QVariantMap& p)
|
||||
{
|
||||
QByteArray uuidBytes = p.value(KDFPARAM_UUID).toByteArray();
|
||||
if (uuidBytes.size() != Uuid::Length) {
|
||||
if (uuidBytes.size() != UUID_LENGHT) {
|
||||
return {};
|
||||
}
|
||||
|
||||
Uuid kdfUuid(uuidBytes);
|
||||
QUuid kdfUuid = QUuid::fromRfc4122(uuidBytes);
|
||||
if (kdfUuid == KDF_AES_KDBX3) {
|
||||
// upgrade to non-legacy AES-KDF, since KDBX3 doesn't have any KDF parameters
|
||||
kdfUuid = KDF_AES_KDBX4;
|
||||
@@ -98,7 +102,7 @@ QVariantMap KeePass2::kdfToParameters(QSharedPointer<Kdf> kdf)
|
||||
return kdf->writeParameters();
|
||||
}
|
||||
|
||||
QSharedPointer<Kdf> KeePass2::uuidToKdf(const Uuid& uuid)
|
||||
QSharedPointer<Kdf> KeePass2::uuidToKdf(const QUuid& uuid)
|
||||
{
|
||||
if (uuid == KDF_AES_KDBX3) {
|
||||
return QSharedPointer<AesKdf>::create(true);
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QVariantMap>
|
||||
#include <QtGlobal>
|
||||
#include <QUuid>
|
||||
|
||||
#include "core/Uuid.h"
|
||||
#include "crypto/SymmetricCipher.h"
|
||||
#include "crypto/kdf/Kdf.h"
|
||||
|
||||
@@ -46,13 +46,13 @@ namespace KeePass2
|
||||
|
||||
const QSysInfo::Endian BYTEORDER = QSysInfo::LittleEndian;
|
||||
|
||||
extern const Uuid CIPHER_AES;
|
||||
extern const Uuid CIPHER_TWOFISH;
|
||||
extern const Uuid CIPHER_CHACHA20;
|
||||
extern const QUuid CIPHER_AES;
|
||||
extern const QUuid CIPHER_TWOFISH;
|
||||
extern const QUuid CIPHER_CHACHA20;
|
||||
|
||||
extern const Uuid KDF_AES_KDBX3;
|
||||
extern const Uuid KDF_AES_KDBX4;
|
||||
extern const Uuid KDF_ARGON2;
|
||||
extern const QUuid KDF_AES_KDBX3;
|
||||
extern const QUuid KDF_AES_KDBX4;
|
||||
extern const QUuid KDF_ARGON2;
|
||||
|
||||
extern const QByteArray INNER_STREAM_SALSA20_IV;
|
||||
|
||||
@@ -67,8 +67,8 @@ namespace KeePass2
|
||||
extern const QString KDFPARAM_ARGON2_SECRET;
|
||||
extern const QString KDFPARAM_ARGON2_ASSOCDATA;
|
||||
|
||||
extern const QList<QPair<Uuid, QString>> CIPHERS;
|
||||
extern const QList<QPair<Uuid, QString>> KDFS;
|
||||
extern const QList<QPair<QUuid, QString>> CIPHERS;
|
||||
extern const QList<QPair<QUuid, QString>> KDFS;
|
||||
|
||||
enum class HeaderFieldID
|
||||
{
|
||||
@@ -125,12 +125,11 @@ namespace KeePass2
|
||||
ByteArray = 0x42
|
||||
};
|
||||
|
||||
QByteArray hmacKey(QByteArray masterSeed, QByteArray transformedMasterKey);
|
||||
QSharedPointer<Kdf> kdfFromParameters(const QVariantMap& p);
|
||||
QVariantMap kdfToParameters(QSharedPointer<Kdf> kdf);
|
||||
QSharedPointer<Kdf> uuidToKdf(const Uuid& uuid);
|
||||
Uuid kdfToUuid(QSharedPointer<Kdf> kdf);
|
||||
ProtectedStreamAlgo idToProtectedStreamAlgo(quint32 id);
|
||||
QByteArray hmacKey(QByteArray masterSeed, QByteArray transformedMasterKey);
|
||||
QSharedPointer<Kdf> kdfFromParameters(const QVariantMap& p);
|
||||
QVariantMap kdfToParameters(QSharedPointer<Kdf> kdf);
|
||||
QSharedPointer<Kdf> uuidToKdf(const QUuid& uuid);
|
||||
ProtectedStreamAlgo idToProtectedStreamAlgo(quint32 id);
|
||||
|
||||
} // namespace KeePass2
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ void DatabaseSettingsWidget::load(Database* db)
|
||||
m_uiEncryption->algorithmComboBox->addItem(QCoreApplication::translate("KeePass2", cipher.second.toUtf8()),
|
||||
cipher.first.toByteArray());
|
||||
}
|
||||
int cipherIndex = m_uiEncryption->algorithmComboBox->findData(m_db->cipher().toByteArray());
|
||||
int cipherIndex = m_uiEncryption->algorithmComboBox->findData(m_db->cipher().toRfc4122());
|
||||
if (cipherIndex > -1) {
|
||||
m_uiEncryption->algorithmComboBox->setCurrentIndex(cipherIndex);
|
||||
}
|
||||
@@ -117,14 +117,13 @@ void DatabaseSettingsWidget::load(Database* db)
|
||||
// Setup kdf combo box
|
||||
m_uiEncryption->kdfComboBox->blockSignals(true);
|
||||
m_uiEncryption->kdfComboBox->clear();
|
||||
for (auto& kdf : asConst(KeePass2::KDFS)) {
|
||||
m_uiEncryption->kdfComboBox->addItem(QCoreApplication::translate("KeePass2", kdf.second.toUtf8()),
|
||||
kdf.first.toByteArray());
|
||||
for (auto& kdf: asConst(KeePass2::KDFS)) {
|
||||
m_uiEncryption->kdfComboBox->addItem(kdf.second, kdf.first.toRfc4122());
|
||||
}
|
||||
m_uiEncryption->kdfComboBox->blockSignals(false);
|
||||
|
||||
auto kdfUuid = m_db->kdf()->uuid();
|
||||
int kdfIndex = m_uiEncryption->kdfComboBox->findData(kdfUuid.toByteArray());
|
||||
int kdfIndex = m_uiEncryption->kdfComboBox->findData(kdfUuid.toRfc4122());
|
||||
if (kdfIndex > -1) {
|
||||
m_uiEncryption->kdfComboBox->setCurrentIndex(kdfIndex);
|
||||
kdfChanged(kdfIndex);
|
||||
@@ -149,7 +148,7 @@ void DatabaseSettingsWidget::load(Database* db)
|
||||
void DatabaseSettingsWidget::save()
|
||||
{
|
||||
// first perform safety check for KDF rounds
|
||||
auto kdf = KeePass2::uuidToKdf(Uuid(m_uiEncryption->kdfComboBox->currentData().toByteArray()));
|
||||
auto kdf = KeePass2::uuidToKdf(m_uiEncryption->kdfComboBox->currentData().value<QUuid>());
|
||||
if (kdf->uuid() == KeePass2::KDF_ARGON2 && m_uiEncryption->transformRoundsSpinBox->value() > 10000) {
|
||||
QMessageBox warning;
|
||||
warning.setIcon(QMessageBox::Warning);
|
||||
@@ -218,7 +217,7 @@ void DatabaseSettingsWidget::save()
|
||||
truncateHistories();
|
||||
}
|
||||
|
||||
m_db->setCipher(Uuid(m_uiEncryption->algorithmComboBox->currentData().toByteArray()));
|
||||
m_db->setCipher(m_uiEncryption->algorithmComboBox->currentData().value<QUuid>());
|
||||
|
||||
// Save kdf parameters
|
||||
kdf->setRounds(m_uiEncryption->transformRoundsSpinBox->value());
|
||||
@@ -256,7 +255,7 @@ void DatabaseSettingsWidget::transformRoundsBenchmark()
|
||||
m_uiEncryption->transformRoundsSpinBox->setFocus();
|
||||
|
||||
// Create a new kdf with the current parameters
|
||||
auto kdf = KeePass2::uuidToKdf(Uuid(m_uiEncryption->kdfComboBox->currentData().toByteArray()));
|
||||
auto kdf = KeePass2::uuidToKdf(m_uiEncryption->kdfComboBox->currentData().value<QUuid>());
|
||||
kdf->setRounds(m_uiEncryption->transformRoundsSpinBox->value());
|
||||
if (kdf->uuid() == KeePass2::KDF_ARGON2) {
|
||||
auto argon2Kdf = kdf.staticCast<Argon2Kdf>();
|
||||
@@ -286,7 +285,7 @@ void DatabaseSettingsWidget::truncateHistories()
|
||||
|
||||
void DatabaseSettingsWidget::kdfChanged(int index)
|
||||
{
|
||||
Uuid id(m_uiEncryption->kdfComboBox->itemData(index).toByteArray());
|
||||
QUuid id(m_uiEncryption->kdfComboBox->itemData(index).value<QUuid>());
|
||||
|
||||
bool memoryEnabled = id == KeePass2::KDF_ARGON2;
|
||||
m_uiEncryption->memoryUsageLabel->setEnabled(memoryEnabled);
|
||||
|
||||
@@ -369,7 +369,7 @@ void DatabaseWidget::createEntry()
|
||||
m_newEntry->setTitle(getCurrentSearch());
|
||||
endSearch();
|
||||
}
|
||||
m_newEntry->setUuid(Uuid::random());
|
||||
m_newEntry->setUuid(QUuid::createUuid());
|
||||
m_newEntry->setUsername(m_db->metadata()->defaultUserName());
|
||||
m_newParent = m_groupView->currentGroup();
|
||||
setIconFromParent();
|
||||
@@ -675,7 +675,7 @@ void DatabaseWidget::createGroup()
|
||||
}
|
||||
|
||||
m_newGroup = new Group();
|
||||
m_newGroup->setUuid(Uuid::random());
|
||||
m_newGroup->setUuid(QUuid::createUuid());
|
||||
m_newParent = m_groupView->currentGroup();
|
||||
switchToGroupEdit(m_newGroup, true);
|
||||
}
|
||||
@@ -905,8 +905,8 @@ void DatabaseWidget::unlockDatabase(bool accepted)
|
||||
replaceDatabase(db);
|
||||
|
||||
restoreGroupEntryFocus(m_groupBeforeLock, m_entryBeforeLock);
|
||||
m_groupBeforeLock = Uuid();
|
||||
m_entryBeforeLock = Uuid();
|
||||
m_groupBeforeLock = QUuid();
|
||||
m_entryBeforeLock = QUuid();
|
||||
|
||||
setCurrentWidget(m_mainWidget);
|
||||
m_unlockDatabaseWidget->clearForms();
|
||||
@@ -1299,14 +1299,14 @@ void DatabaseWidget::reloadDatabaseFile()
|
||||
}
|
||||
}
|
||||
|
||||
Uuid groupBeforeReload;
|
||||
QUuid groupBeforeReload;
|
||||
if (m_groupView && m_groupView->currentGroup()) {
|
||||
groupBeforeReload = m_groupView->currentGroup()->uuid();
|
||||
} else {
|
||||
groupBeforeReload = m_db->rootGroup()->uuid();
|
||||
}
|
||||
|
||||
Uuid entryBeforeReload;
|
||||
QUuid entryBeforeReload;
|
||||
if (m_entryView && m_entryView->currentEntry()) {
|
||||
entryBeforeReload = m_entryView->currentEntry()->uuid();
|
||||
}
|
||||
@@ -1348,7 +1348,7 @@ QStringList DatabaseWidget::customEntryAttributes() const
|
||||
* Restores the focus on the group and entry that was focused
|
||||
* before the database was locked or reloaded.
|
||||
*/
|
||||
void DatabaseWidget::restoreGroupEntryFocus(Uuid groupUuid, Uuid entryUuid)
|
||||
void DatabaseWidget::restoreGroupEntryFocus(const QUuid& groupUuid, const QUuid& entryUuid)
|
||||
{
|
||||
Group* restoredGroup = nullptr;
|
||||
const QList<Group*> groups = m_db->rootGroup()->groupsRecursive(true);
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
#include <QStackedWidget>
|
||||
#include <QTimer>
|
||||
|
||||
#include "core/Uuid.h"
|
||||
|
||||
#include "gui/entry/EntryModel.h"
|
||||
#include "gui/MessageWidget.h"
|
||||
#include "gui/csvImport/CsvImportWizard.h"
|
||||
#include "gui/entry/EntryModel.h"
|
||||
@@ -204,7 +203,7 @@ private slots:
|
||||
// Database autoreload slots
|
||||
void onWatchedFileChanged();
|
||||
void reloadDatabaseFile();
|
||||
void restoreGroupEntryFocus(Uuid groupUuid, Uuid EntryUuid);
|
||||
void restoreGroupEntryFocus(const QUuid& groupUuid, const QUuid& EntryUuid);
|
||||
void unblockAutoReload();
|
||||
|
||||
private:
|
||||
@@ -234,8 +233,8 @@ private:
|
||||
Entry* m_newEntry;
|
||||
Group* m_newParent;
|
||||
QString m_filePath;
|
||||
Uuid m_groupBeforeLock;
|
||||
Uuid m_entryBeforeLock;
|
||||
QUuid m_groupBeforeLock;
|
||||
QUuid m_entryBeforeLock;
|
||||
MessageWidget* m_messageWidget;
|
||||
DetailsWidget* m_detailsView;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#endif
|
||||
|
||||
IconStruct::IconStruct()
|
||||
: uuid(Uuid())
|
||||
: uuid(QUuid())
|
||||
, number(0)
|
||||
{
|
||||
}
|
||||
@@ -127,13 +127,10 @@ IconStruct EditWidgetIcons::state()
|
||||
void EditWidgetIcons::reset()
|
||||
{
|
||||
m_database = nullptr;
|
||||
m_currentUuid = Uuid();
|
||||
m_currentUuid = QUuid();
|
||||
}
|
||||
|
||||
void EditWidgetIcons::load(const Uuid& currentUuid,
|
||||
Database* database,
|
||||
const IconStruct& iconStruct,
|
||||
const QString& url)
|
||||
void EditWidgetIcons::load(const QUuid& currentUuid, Database* database, const IconStruct& iconStruct, const QString& url)
|
||||
{
|
||||
Q_ASSERT(database);
|
||||
Q_ASSERT(!currentUuid.isNull());
|
||||
@@ -145,7 +142,7 @@ void EditWidgetIcons::load(const Uuid& currentUuid,
|
||||
m_customIconModel->setIcons(database->metadata()->customIconsScaledPixmaps(),
|
||||
database->metadata()->customIconsOrder());
|
||||
|
||||
Uuid iconUuid = iconStruct.uuid;
|
||||
QUuid iconUuid = iconStruct.uuid;
|
||||
if (iconUuid.isNull()) {
|
||||
int iconNumber = iconStruct.number;
|
||||
m_ui->defaultIconsView->setCurrentIndex(m_defaultIconModel->index(iconNumber, 0));
|
||||
@@ -380,9 +377,9 @@ bool EditWidgetIcons::addCustomIcon(const QImage& icon)
|
||||
scaledicon = icon.scaled(128, 128);
|
||||
}
|
||||
|
||||
Uuid uuid = m_database->metadata()->findCustomIcon(scaledicon);
|
||||
QUuid uuid = m_database->metadata()->findCustomIcon(scaledicon);
|
||||
if (uuid.isNull()) {
|
||||
uuid = Uuid::random();
|
||||
uuid = QUuid::createUuid();
|
||||
m_database->metadata()->addCustomIcon(uuid, scaledicon);
|
||||
m_customIconModel->setIcons(m_database->metadata()->customIconsScaledPixmaps(),
|
||||
m_database->metadata()->customIconsOrder());
|
||||
@@ -405,7 +402,7 @@ void EditWidgetIcons::removeCustomIcon()
|
||||
if (m_database) {
|
||||
QModelIndex index = m_ui->customIconsView->currentIndex();
|
||||
if (index.isValid()) {
|
||||
Uuid iconUuid = m_customIconModel->uuidFromIndex(index);
|
||||
QUuid iconUuid = m_customIconModel->uuidFromIndex(index);
|
||||
|
||||
const QList<Entry*> allEntries = m_database->rootGroup()->entriesRecursive(true);
|
||||
QList<Entry*> entriesWithSameIcon;
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QUuid.h>
|
||||
|
||||
#include "config-keepassx.h"
|
||||
#include "core/Global.h"
|
||||
#include "core/Uuid.h"
|
||||
#include "gui/MessageWidget.h"
|
||||
|
||||
class Database;
|
||||
@@ -46,7 +46,7 @@ struct IconStruct
|
||||
{
|
||||
IconStruct();
|
||||
|
||||
Uuid uuid;
|
||||
QUuid uuid;
|
||||
int number;
|
||||
};
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
|
||||
IconStruct state();
|
||||
void reset();
|
||||
void load(const Uuid& currentUuid, Database* database, const IconStruct& iconStruct, const QString& url = "");
|
||||
void load(const QUuid& currentUuid, Database* database, const IconStruct& iconStruct, const QString& url = "");
|
||||
|
||||
public slots:
|
||||
void setUrl(const QString& url);
|
||||
@@ -98,7 +98,7 @@ private slots:
|
||||
private:
|
||||
const QScopedPointer<Ui::EditWidgetIcons> m_ui;
|
||||
Database* m_database;
|
||||
Uuid m_currentUuid;
|
||||
QUuid m_currentUuid;
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
QUrl m_url;
|
||||
QUrl m_fetchUrl;
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
|
||||
#include "EditWidgetProperties.h"
|
||||
|
||||
#include <QUuid.h>
|
||||
|
||||
#include "MessageBox.h"
|
||||
#include "ui_EditWidgetProperties.h"
|
||||
|
||||
@@ -39,13 +42,13 @@ EditWidgetProperties::~EditWidgetProperties()
|
||||
{
|
||||
}
|
||||
|
||||
void EditWidgetProperties::setFields(const TimeInfo& timeInfo, const Uuid& uuid)
|
||||
void EditWidgetProperties::setFields(const TimeInfo& timeInfo, const QUuid& uuid)
|
||||
{
|
||||
static const QString timeFormat("d MMM yyyy HH:mm:ss");
|
||||
m_ui->modifiedEdit->setText(timeInfo.lastModificationTime().toLocalTime().toString(timeFormat));
|
||||
m_ui->createdEdit->setText(timeInfo.creationTime().toLocalTime().toString(timeFormat));
|
||||
m_ui->accessedEdit->setText(timeInfo.lastAccessTime().toLocalTime().toString(timeFormat));
|
||||
m_ui->uuidEdit->setText(uuid.toHex());
|
||||
m_ui->uuidEdit->setText(uuid.toRfc4122().toHex());
|
||||
}
|
||||
|
||||
void EditWidgetProperties::setCustomData(const CustomData* customData)
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "core/CustomData.h"
|
||||
#include "core/TimeInfo.h"
|
||||
#include "core/Uuid.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -40,7 +39,7 @@ public:
|
||||
explicit EditWidgetProperties(QWidget* parent = nullptr);
|
||||
~EditWidgetProperties();
|
||||
|
||||
void setFields(const TimeInfo& timeInfo, const Uuid& uuid);
|
||||
void setFields(const TimeInfo& timeInfo, const QUuid& uuid);
|
||||
void setCustomData(const CustomData* customData);
|
||||
|
||||
const CustomData* customData() const;
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
#include "IconModels.h"
|
||||
|
||||
#include <QUuid.h>
|
||||
|
||||
#include "core/DatabaseIcons.h"
|
||||
|
||||
DefaultIconModel::DefaultIconModel(QObject* parent)
|
||||
@@ -53,7 +55,7 @@ CustomIconModel::CustomIconModel(QObject* parent)
|
||||
{
|
||||
}
|
||||
|
||||
void CustomIconModel::setIcons(const QHash<Uuid, QPixmap>& icons, const QList<Uuid>& iconsOrder)
|
||||
void CustomIconModel::setIcons(const QHash<QUuid, QPixmap>& icons, const QList<QUuid>& iconsOrder)
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
@@ -80,21 +82,21 @@ QVariant CustomIconModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
|
||||
if (role == Qt::DecorationRole) {
|
||||
Uuid uuid = uuidFromIndex(index);
|
||||
QUuid uuid = uuidFromIndex(index);
|
||||
return m_icons.value(uuid);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Uuid CustomIconModel::uuidFromIndex(const QModelIndex& index) const
|
||||
QUuid CustomIconModel::uuidFromIndex(const QModelIndex& index) const
|
||||
{
|
||||
Q_ASSERT(index.isValid());
|
||||
|
||||
return m_iconsOrder.value(index.row());
|
||||
}
|
||||
|
||||
QModelIndex CustomIconModel::indexFromUuid(const Uuid& uuid) const
|
||||
QModelIndex CustomIconModel::indexFromUuid(const QUuid& uuid) const
|
||||
{
|
||||
int idx = m_iconsOrder.indexOf(uuid);
|
||||
if (idx > -1) {
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#include <QAbstractListModel>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "core/Uuid.h"
|
||||
|
||||
class DefaultIconModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -43,13 +41,13 @@ public:
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
void setIcons(const QHash<Uuid, QPixmap>& icons, const QList<Uuid>& iconsOrder);
|
||||
Uuid uuidFromIndex(const QModelIndex& index) const;
|
||||
QModelIndex indexFromUuid(const Uuid& uuid) const;
|
||||
void setIcons(const QHash<QUuid, QPixmap>& icons, const QList<QUuid>& iconsOrder);
|
||||
QUuid uuidFromIndex(const QModelIndex& index) const;
|
||||
QModelIndex indexFromUuid(const QUuid& uuid) const;
|
||||
|
||||
private:
|
||||
QHash<Uuid, QPixmap> m_icons;
|
||||
QList<Uuid> m_iconsOrder;
|
||||
QHash<QUuid, QPixmap> m_icons;
|
||||
QList<QUuid> m_iconsOrder;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_ICONMODELS_H
|
||||
|
||||
@@ -192,8 +192,8 @@ void CsvImportWidget::load(const QString& filename, Database* const db)
|
||||
m_parserModel->setFilename(filename);
|
||||
m_ui->labelFilename->setText(filename);
|
||||
Group* group = m_db->rootGroup();
|
||||
group->setUuid(Uuid::random());
|
||||
group->setNotes(tr("Imported from CSV file\nOriginal data: %1").arg(filename));
|
||||
group->setUuid(QUuid::createUuid());
|
||||
group->setNotes(tr("Imported from CSV file").append("\n").append(tr("Original data: ")) + filename);
|
||||
parse();
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ void CsvImportWidget::writeDatabase()
|
||||
if (not m_parserModel->data(m_parserModel->index(r, 1)).isValid())
|
||||
continue;
|
||||
Entry* entry = new Entry();
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
entry->setGroup(splitGroups(m_parserModel->data(m_parserModel->index(r, 0)).toString()));
|
||||
entry->setTitle(m_parserModel->data(m_parserModel->index(r, 1)).toString());
|
||||
entry->setUsername(m_parserModel->data(m_parserModel->index(r, 2)).toString());
|
||||
@@ -324,7 +324,7 @@ Group* CsvImportWidget::splitGroups(QString label)
|
||||
Group* brandNew = new Group();
|
||||
brandNew->setParent(current);
|
||||
brandNew->setName(groupName);
|
||||
brandNew->setUuid(Uuid::random());
|
||||
brandNew->setUuid(QUuid::createUuid());
|
||||
current = brandNew;
|
||||
} else {
|
||||
Q_ASSERT(children != nullptr);
|
||||
|
||||
@@ -224,8 +224,8 @@ bool GroupModel::dropMimeData(const QMimeData* data,
|
||||
Group* parentGroup = groupFromIndex(parent);
|
||||
|
||||
if (isGroup) {
|
||||
Uuid dbUuid;
|
||||
Uuid groupUuid;
|
||||
QUuid dbUuid;
|
||||
QUuid groupUuid;
|
||||
stream >> dbUuid >> groupUuid;
|
||||
|
||||
Database* db = Database::databaseByUuid(dbUuid);
|
||||
@@ -257,7 +257,7 @@ bool GroupModel::dropMimeData(const QMimeData* data,
|
||||
Database* targetDb = parentGroup->database();
|
||||
|
||||
if (sourceDb != targetDb) {
|
||||
QSet<Uuid> customIcons = group->customIconsRecursive();
|
||||
QSet<QUuid> customIcons = group->customIconsRecursive();
|
||||
targetDb->metadata()->copyCustomIcons(customIcons, sourceDb->metadata());
|
||||
}
|
||||
|
||||
@@ -268,8 +268,8 @@ bool GroupModel::dropMimeData(const QMimeData* data,
|
||||
}
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
Uuid dbUuid;
|
||||
Uuid entryUuid;
|
||||
QUuid dbUuid;
|
||||
QUuid entryUuid;
|
||||
stream >> dbUuid >> entryUuid;
|
||||
|
||||
Database* db = Database::databaseByUuid(dbUuid);
|
||||
@@ -291,7 +291,7 @@ bool GroupModel::dropMimeData(const QMimeData* data,
|
||||
|
||||
Database* sourceDb = dragEntry->group()->database();
|
||||
Database* targetDb = parentGroup->database();
|
||||
Uuid customIcon = entry->iconUuid();
|
||||
QUuid customIcon = entry->iconUuid();
|
||||
|
||||
if (sourceDb != targetDb && !customIcon.isNull() && !targetDb->metadata()->containsCustomIcon(customIcon)) {
|
||||
targetDb->metadata()->addCustomIcon(customIcon, sourceDb->metadata()->customIcon(customIcon));
|
||||
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
const QString errorString() const;
|
||||
bool isAgentRunning() const;
|
||||
bool addIdentity(OpenSSHKey& key, quint32 lifetime = 0, bool confirm = false);
|
||||
bool removeIdentity(OpenSSHKey& key);
|
||||
void removeIdentityAtLock(const OpenSSHKey& key, const Uuid& uuid);
|
||||
bool removeIdentity(OpenSSHKey& key) const;
|
||||
void removeIdentityAtLock(const OpenSSHKey& key, const QUuid& uuid);
|
||||
|
||||
signals:
|
||||
void error(const QString& message);
|
||||
|
||||
Reference in New Issue
Block a user