mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Replaced Uuid with QUuid
This commit is contained in:
parent
dcece140a0
commit
ad4423d226
@ -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);
|
||||
|
@ -38,7 +38,7 @@ void TestDeletedObjects::createAndDelete(Database* db, int delObjectsSize)
|
||||
|
||||
Group* g = new Group();
|
||||
g->setParent(root);
|
||||
Uuid gUuid = Uuid::random();
|
||||
QUuid gUuid = QUuid::createUuid();
|
||||
g->setUuid(gUuid);
|
||||
delete g;
|
||||
QCOMPARE(db->deletedObjects().size(), ++delObjectsSize);
|
||||
@ -47,19 +47,19 @@ void TestDeletedObjects::createAndDelete(Database* db, int delObjectsSize)
|
||||
|
||||
Group* g1 = new Group();
|
||||
g1->setParent(root);
|
||||
Uuid g1Uuid = Uuid::random();
|
||||
QUuid g1Uuid = QUuid::createUuid();
|
||||
g1->setUuid(g1Uuid);
|
||||
Entry* e1 = new Entry();
|
||||
e1->setGroup(g1);
|
||||
Uuid e1Uuid = Uuid::random();
|
||||
QUuid e1Uuid = QUuid::createUuid();
|
||||
e1->setUuid(e1Uuid);
|
||||
Group* g2 = new Group();
|
||||
g2->setParent(g1);
|
||||
Uuid g2Uuid = Uuid::random();
|
||||
QUuid g2Uuid = QUuid::createUuid();
|
||||
g2->setUuid(g2Uuid);
|
||||
Entry* e2 = new Entry();
|
||||
e2->setGroup(g2);
|
||||
Uuid e2Uuid = Uuid::random();
|
||||
QUuid e2Uuid = QUuid::createUuid();
|
||||
e2->setUuid(e2Uuid);
|
||||
|
||||
delete g1;
|
||||
@ -74,7 +74,7 @@ void TestDeletedObjects::createAndDelete(Database* db, int delObjectsSize)
|
||||
|
||||
Entry* e3 = new Entry();
|
||||
e3->setGroup(root);
|
||||
Uuid e3Uuid = Uuid::random();
|
||||
QUuid e3Uuid = QUuid::createUuid();
|
||||
e3->setUuid(e3Uuid);
|
||||
|
||||
delete e3;
|
||||
@ -132,11 +132,11 @@ void TestDeletedObjects::testDatabaseChange()
|
||||
|
||||
Group* g1 = new Group();
|
||||
g1->setParent(root);
|
||||
Uuid g1Uuid = Uuid::random();
|
||||
QUuid g1Uuid = QUuid::createUuid();
|
||||
g1->setUuid(g1Uuid);
|
||||
Entry* e1 = new Entry();
|
||||
e1->setGroup(g1);
|
||||
Uuid e1Uuid = Uuid::random();
|
||||
QUuid e1Uuid = QUuid::createUuid();
|
||||
e1->setUuid(e1Uuid);
|
||||
g1->setParent(root2);
|
||||
|
||||
|
@ -82,7 +82,7 @@ void TestEntry::testCopyDataFrom()
|
||||
void TestEntry::testClone()
|
||||
{
|
||||
QScopedPointer<Entry> entryOrg(new Entry());
|
||||
entryOrg->setUuid(Uuid::random());
|
||||
entryOrg->setUuid(QUuid::createUuid());
|
||||
entryOrg->setTitle("Original Title");
|
||||
entryOrg->beginUpdate();
|
||||
entryOrg->setTitle("New Title");
|
||||
@ -205,7 +205,7 @@ void TestEntry::testResolveRecursivePlaceholders()
|
||||
|
||||
auto* entry1 = new Entry();
|
||||
entry1->setGroup(root);
|
||||
entry1->setUuid(Uuid::random());
|
||||
entry1->setUuid(QUuid::createUuid());
|
||||
entry1->setTitle("{USERNAME}");
|
||||
entry1->setUsername("{PASSWORD}");
|
||||
entry1->setPassword("{URL}");
|
||||
@ -215,10 +215,10 @@ void TestEntry::testResolveRecursivePlaceholders()
|
||||
|
||||
auto* entry2 = new Entry();
|
||||
entry2->setGroup(root);
|
||||
entry2->setUuid(Uuid::random());
|
||||
entry2->setUuid(QUuid::createUuid());
|
||||
entry2->setTitle("Entry2Title");
|
||||
entry2->setUsername("{S:CustomUserNameAttribute}");
|
||||
entry2->setPassword(QString("{REF:P@I:%1}").arg(entry1->uuid().toHex()));
|
||||
entry2->setPassword(QString("{REF:P@I:%1}").arg(QString(entry1->uuid().toRfc4122().toHex())));
|
||||
entry2->setUrl("http://{S:IpAddress}:{S:Port}/{S:Uri}");
|
||||
entry2->attributes()->set("CustomUserNameAttribute", "CustomUserNameValue");
|
||||
entry2->attributes()->set("IpAddress", "127.0.0.1");
|
||||
@ -227,11 +227,11 @@ void TestEntry::testResolveRecursivePlaceholders()
|
||||
|
||||
auto* entry3 = new Entry();
|
||||
entry3->setGroup(root);
|
||||
entry3->setUuid(Uuid::random());
|
||||
entry3->setTitle(QString("{REF:T@I:%1}").arg(entry2->uuid().toHex()));
|
||||
entry3->setUsername(QString("{REF:U@I:%1}").arg(entry2->uuid().toHex()));
|
||||
entry3->setPassword(QString("{REF:P@I:%1}").arg(entry2->uuid().toHex()));
|
||||
entry3->setUrl(QString("{REF:A@I:%1}").arg(entry2->uuid().toHex()));
|
||||
entry3->setUuid(QUuid::createUuid());
|
||||
entry3->setTitle(QString("{REF:T@I:%1}").arg(QString(entry2->uuid().toRfc4122().toHex())));
|
||||
entry3->setUsername(QString("{REF:U@I:%1}").arg(QString(entry2->uuid().toRfc4122().toHex())));
|
||||
entry3->setPassword(QString("{REF:P@I:%1}").arg(QString(entry2->uuid().toRfc4122().toHex())));
|
||||
entry3->setUrl(QString("{REF:A@I:%1}").arg(QString(entry2->uuid().toRfc4122().toHex())));
|
||||
|
||||
QCOMPARE(entry3->resolveMultiplePlaceholders(entry3->title()), QString("Entry2Title"));
|
||||
QCOMPARE(entry3->resolveMultiplePlaceholders(entry3->username()), QString("CustomUserNameValue"));
|
||||
@ -240,11 +240,11 @@ void TestEntry::testResolveRecursivePlaceholders()
|
||||
|
||||
auto* entry4 = new Entry();
|
||||
entry4->setGroup(root);
|
||||
entry4->setUuid(Uuid::random());
|
||||
entry4->setTitle(QString("{REF:T@I:%1}").arg(entry3->uuid().toHex()));
|
||||
entry4->setUsername(QString("{REF:U@I:%1}").arg(entry3->uuid().toHex()));
|
||||
entry4->setPassword(QString("{REF:P@I:%1}").arg(entry3->uuid().toHex()));
|
||||
entry4->setUrl(QString("{REF:A@I:%1}").arg(entry3->uuid().toHex()));
|
||||
entry4->setUuid(QUuid::createUuid());
|
||||
entry4->setTitle(QString("{REF:T@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex())));
|
||||
entry4->setUsername(QString("{REF:U@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex())));
|
||||
entry4->setPassword(QString("{REF:P@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex())));
|
||||
entry4->setUrl(QString("{REF:A@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex())));
|
||||
|
||||
QCOMPARE(entry4->resolveMultiplePlaceholders(entry4->title()), QString("Entry2Title"));
|
||||
QCOMPARE(entry4->resolveMultiplePlaceholders(entry4->username()), QString("CustomUserNameValue"));
|
||||
@ -253,7 +253,7 @@ void TestEntry::testResolveRecursivePlaceholders()
|
||||
|
||||
auto* entry5 = new Entry();
|
||||
entry5->setGroup(root);
|
||||
entry5->setUuid(Uuid::random());
|
||||
entry5->setUuid(QUuid::createUuid());
|
||||
entry5->attributes()->set("Scheme", "http");
|
||||
entry5->attributes()->set("Host", "host.org");
|
||||
entry5->attributes()->set("Port", "2017");
|
||||
@ -271,8 +271,8 @@ void TestEntry::testResolveRecursivePlaceholders()
|
||||
|
||||
auto* entry6 = new Entry();
|
||||
entry6->setGroup(root);
|
||||
entry6->setUuid(Uuid::random());
|
||||
entry6->setTitle(QString("{REF:T@I:%1}").arg(entry3->uuid().toHex()));
|
||||
entry6->setUuid(QUuid::createUuid());
|
||||
entry6->setTitle(QString("{REF:T@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex())));
|
||||
entry6->setUsername(QString("{TITLE}"));
|
||||
entry6->setPassword(QString("{PASSWORD}"));
|
||||
|
||||
@ -299,7 +299,7 @@ void TestEntry::testResolveReferencePlaceholders()
|
||||
|
||||
auto* entry1 = new Entry();
|
||||
entry1->setGroup(root);
|
||||
entry1->setUuid(Uuid::random());
|
||||
entry1->setUuid(QUuid::createUuid());
|
||||
entry1->setTitle("Title1");
|
||||
entry1->setUsername("Username1");
|
||||
entry1->setPassword("Password1");
|
||||
@ -311,7 +311,7 @@ void TestEntry::testResolveReferencePlaceholders()
|
||||
group->setParent(root);
|
||||
auto* entry2 = new Entry();
|
||||
entry2->setGroup(group);
|
||||
entry2->setUuid(Uuid::random());
|
||||
entry2->setUuid(QUuid::createUuid());
|
||||
entry2->setTitle("Title2");
|
||||
entry2->setUsername("Username2");
|
||||
entry2->setPassword("Password2");
|
||||
@ -321,7 +321,7 @@ void TestEntry::testResolveReferencePlaceholders()
|
||||
|
||||
auto* entry3 = new Entry();
|
||||
entry3->setGroup(group);
|
||||
entry3->setUuid(Uuid::random());
|
||||
entry3->setUuid(QUuid::createUuid());
|
||||
entry3->setTitle("{S:AttributeTitle}");
|
||||
entry3->setUsername("{S:AttributeUsername}");
|
||||
entry3->setPassword("{S:AttributePassword}");
|
||||
@ -335,9 +335,9 @@ void TestEntry::testResolveReferencePlaceholders()
|
||||
|
||||
auto* tstEntry = new Entry();
|
||||
tstEntry->setGroup(root);
|
||||
tstEntry->setUuid(Uuid::random());
|
||||
tstEntry->setUuid(QUuid::createUuid());
|
||||
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@I:%1}").arg(entry1->uuid().toHex())),
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@I:%1}").arg(QString(entry1->uuid().toRfc4122().toHex()))),
|
||||
entry1->title());
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@T:%1}").arg(entry1->title())), entry1->title());
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@U:%1}").arg(entry1->username())), entry1->title());
|
||||
@ -348,7 +348,7 @@ void TestEntry::testResolveReferencePlaceholders()
|
||||
QString("{REF:T@O:%1}").arg(entry1->attributes()->value("CustomAttribute1"))),
|
||||
entry1->title());
|
||||
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@I:%1}").arg(entry1->uuid().toHex())),
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@I:%1}").arg(QString(entry1->uuid().toRfc4122().toHex()))),
|
||||
entry1->title());
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@T:%1}").arg(entry1->title())), entry1->title());
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:U@U:%1}").arg(entry1->username())),
|
||||
@ -358,7 +358,7 @@ void TestEntry::testResolveReferencePlaceholders()
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:A@A:%1}").arg(entry1->url())), entry1->url());
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:N@N:%1}").arg(entry1->notes())), entry1->notes());
|
||||
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@I:%1}").arg(entry2->uuid().toHex())),
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@I:%1}").arg(QString(entry2->uuid().toRfc4122().toHex()))),
|
||||
entry2->title());
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@T:%1}").arg(entry2->title())), entry2->title());
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@U:%1}").arg(entry2->username())), entry2->title());
|
||||
@ -377,38 +377,23 @@ void TestEntry::testResolveReferencePlaceholders()
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:A@A:%1}").arg(entry2->url())), entry2->url());
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:N@N:%1}").arg(entry2->notes())), entry2->notes());
|
||||
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@I:%1}").arg(entry3->uuid().toHex())),
|
||||
entry3->attributes()->value("AttributeTitle"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:U@I:%1}").arg(entry3->uuid().toHex())),
|
||||
entry3->attributes()->value("AttributeUsername"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:P@I:%1}").arg(entry3->uuid().toHex())),
|
||||
entry3->attributes()->value("AttributePassword"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:A@I:%1}").arg(entry3->uuid().toHex())),
|
||||
entry3->attributes()->value("AttributeUrl"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:N@I:%1}").arg(entry3->uuid().toHex())),
|
||||
entry3->attributes()->value("AttributeNotes"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex()))), entry3->attributes()->value("AttributeTitle"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:U@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex()))), entry3->attributes()->value("AttributeUsername"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:P@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex()))), entry3->attributes()->value("AttributePassword"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:A@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex()))), entry3->attributes()->value("AttributeUrl"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:N@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex()))), entry3->attributes()->value("AttributeNotes"));
|
||||
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@I:%1}").arg(entry3->uuid().toHex().toUpper())),
|
||||
entry3->attributes()->value("AttributeTitle"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:U@I:%1}").arg(entry3->uuid().toHex().toUpper())),
|
||||
entry3->attributes()->value("AttributeUsername"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:P@I:%1}").arg(entry3->uuid().toHex().toUpper())),
|
||||
entry3->attributes()->value("AttributePassword"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:A@I:%1}").arg(entry3->uuid().toHex().toUpper())),
|
||||
entry3->attributes()->value("AttributeUrl"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:N@I:%1}").arg(entry3->uuid().toHex().toUpper())),
|
||||
entry3->attributes()->value("AttributeNotes"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:T@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex().toUpper()))), entry3->attributes()->value("AttributeTitle"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:U@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex().toUpper()))), entry3->attributes()->value("AttributeUsername"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:P@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex().toUpper()))), entry3->attributes()->value("AttributePassword"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:A@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex().toUpper()))), entry3->attributes()->value("AttributeUrl"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:N@I:%1}").arg(QString(entry3->uuid().toRfc4122().toHex().toUpper()))), entry3->attributes()->value("AttributeNotes"));
|
||||
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:t@i:%1}").arg(entry3->uuid().toHex().toLower())),
|
||||
entry3->attributes()->value("AttributeTitle"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:u@i:%1}").arg(entry3->uuid().toHex().toLower())),
|
||||
entry3->attributes()->value("AttributeUsername"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:p@i:%1}").arg(entry3->uuid().toHex().toLower())),
|
||||
entry3->attributes()->value("AttributePassword"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:a@i:%1}").arg(entry3->uuid().toHex().toLower())),
|
||||
entry3->attributes()->value("AttributeUrl"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:n@i:%1}").arg(entry3->uuid().toHex().toLower())),
|
||||
entry3->attributes()->value("AttributeNotes"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:t@i:%1}").arg(QString(entry3->uuid().toRfc4122().toHex().toLower()))), entry3->attributes()->value("AttributeTitle"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:u@i:%1}").arg(QString(entry3->uuid().toRfc4122().toHex().toLower()))), entry3->attributes()->value("AttributeUsername"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:p@i:%1}").arg(QString(entry3->uuid().toRfc4122().toHex().toLower()))), entry3->attributes()->value("AttributePassword"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:a@i:%1}").arg(QString(entry3->uuid().toRfc4122().toHex().toLower()))), entry3->attributes()->value("AttributeUrl"));
|
||||
QCOMPARE(tstEntry->resolveMultiplePlaceholders(QString("{REF:n@i:%1}").arg(QString(entry3->uuid().toRfc4122().toHex().toLower()))), entry3->attributes()->value("AttributeNotes"));
|
||||
}
|
||||
|
||||
void TestEntry::testResolveNonIdPlaceholdersToUuid()
|
||||
@ -419,27 +404,27 @@ void TestEntry::testResolveNonIdPlaceholdersToUuid()
|
||||
auto* referencedEntryTitle = new Entry();
|
||||
referencedEntryTitle->setGroup(root);
|
||||
referencedEntryTitle->setTitle("myTitle");
|
||||
referencedEntryTitle->setUuid(Uuid::random());
|
||||
referencedEntryTitle->setUuid(QUuid::createUuid());
|
||||
|
||||
auto* referencedEntryUsername = new Entry();
|
||||
referencedEntryUsername->setGroup(root);
|
||||
referencedEntryUsername->setUsername("myUser");
|
||||
referencedEntryUsername->setUuid(Uuid::random());
|
||||
referencedEntryUsername->setUuid(QUuid::createUuid());
|
||||
|
||||
auto* referencedEntryPassword = new Entry();
|
||||
referencedEntryPassword->setGroup(root);
|
||||
referencedEntryPassword->setPassword("myPassword");
|
||||
referencedEntryPassword->setUuid(Uuid::random());
|
||||
referencedEntryPassword->setUuid(QUuid::createUuid());
|
||||
|
||||
auto* referencedEntryUrl = new Entry();
|
||||
referencedEntryUrl->setGroup(root);
|
||||
referencedEntryUrl->setUrl("myUrl");
|
||||
referencedEntryUrl->setUuid(Uuid::random());
|
||||
referencedEntryUrl->setUuid(QUuid::createUuid());
|
||||
|
||||
auto* referencedEntryNotes = new Entry();
|
||||
referencedEntryNotes->setGroup(root);
|
||||
referencedEntryNotes->setNotes("myNotes");
|
||||
referencedEntryNotes->setUuid(Uuid::random());
|
||||
referencedEntryNotes->setUuid(QUuid::createUuid());
|
||||
|
||||
const QList<QChar> placeholders{'T', 'U', 'P', 'A', 'N'};
|
||||
for (const QChar& searchIn : placeholders) {
|
||||
@ -475,8 +460,9 @@ void TestEntry::testResolveNonIdPlaceholdersToUuid()
|
||||
newEntry->setGroup(root);
|
||||
newEntry->setNotes(newEntryNotesRaw);
|
||||
|
||||
const QString newEntryNotesResolved = newEntry->resolveMultiplePlaceholders(newEntry->notes());
|
||||
QCOMPARE(newEntryNotesResolved, QString(referencedEntry->uuid().toHex()));
|
||||
const QString newEntryNotesResolved =
|
||||
newEntry->resolveMultiplePlaceholders(newEntry->notes());
|
||||
QCOMPARE(newEntryNotesResolved, QString(referencedEntry->uuid().toRfc4122().toHex()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,7 +473,7 @@ void TestEntry::testResolveClonedEntry()
|
||||
|
||||
auto* original = new Entry();
|
||||
original->setGroup(root);
|
||||
original->setUuid(Uuid::random());
|
||||
original->setUuid(QUuid::createUuid());
|
||||
original->setTitle("Title");
|
||||
original->setUsername("SomeUsername");
|
||||
original->setPassword("SomePassword");
|
||||
|
@ -217,15 +217,14 @@ void TestEntryModel::testCustomIconModel()
|
||||
|
||||
QCOMPARE(model->rowCount(), 0);
|
||||
|
||||
QHash<Uuid, QPixmap> icons;
|
||||
QList<Uuid> iconsOrder;
|
||||
QHash<QUuid, QPixmap> icons;
|
||||
QList<QUuid> iconsOrder;
|
||||
|
||||
Uuid iconUuid(QByteArray(16, '2'));
|
||||
QUuid iconUuid(QByteArray(16, '2'));
|
||||
icons.insert(iconUuid, QPixmap());
|
||||
iconsOrder << iconUuid;
|
||||
|
||||
Uuid iconUuid2(QByteArray(16, '1'));
|
||||
QImage icon2;
|
||||
QUuid iconUuid2(QByteArray(16, '1'));
|
||||
icons.insert(iconUuid2, QPixmap());
|
||||
iconsOrder << iconUuid2;
|
||||
|
||||
|
@ -26,15 +26,7 @@
|
||||
|
||||
namespace QTest
|
||||
{
|
||||
|
||||
template <> inline char* toString(const Uuid& uuid)
|
||||
{
|
||||
QByteArray ba = "Uuid(";
|
||||
ba += uuid.toHex().toLatin1().constData();
|
||||
ba += ")";
|
||||
return qstrdup(ba.constData());
|
||||
}
|
||||
|
||||
|
||||
template <> inline char* toString(const Group::TriState& triState)
|
||||
{
|
||||
QString value;
|
||||
|
@ -93,7 +93,7 @@ void TestGroup::testParenting()
|
||||
g4->setName("test");
|
||||
g3->setName("test");
|
||||
g1->setName("test");
|
||||
g3->setIcon(Uuid::random());
|
||||
g3->setIcon(QUuid::createUuid());
|
||||
g1->setIcon(2);
|
||||
QCOMPARE(spy.count(), 6);
|
||||
delete db;
|
||||
@ -293,12 +293,12 @@ void TestGroup::testCopyCustomIcon()
|
||||
{
|
||||
QScopedPointer<Database> dbSource(new Database());
|
||||
|
||||
Uuid groupIconUuid = Uuid::random();
|
||||
QUuid groupIconUuid = QUuid::createUuid();
|
||||
QImage groupIcon(16, 16, QImage::Format_RGB32);
|
||||
groupIcon.setPixel(0, 0, qRgb(255, 0, 0));
|
||||
dbSource->metadata()->addCustomIcon(groupIconUuid, groupIcon);
|
||||
|
||||
Uuid entryIconUuid = Uuid::random();
|
||||
QUuid entryIconUuid = QUuid::createUuid();
|
||||
QImage entryIcon(16, 16, QImage::Format_RGB32);
|
||||
entryIcon.setPixel(0, 0, qRgb(255, 0, 0));
|
||||
dbSource->metadata()->addCustomIcon(entryIconUuid, entryIcon);
|
||||
@ -412,25 +412,25 @@ void TestGroup::testCopyCustomIcons()
|
||||
|
||||
QScopedPointer<Group> group1(new Group());
|
||||
group1->setParent(dbSource->rootGroup());
|
||||
Uuid group1Icon = Uuid::random();
|
||||
QUuid group1Icon = QUuid::createUuid();
|
||||
dbSource->metadata()->addCustomIcon(group1Icon, iconImage1);
|
||||
group1->setIcon(group1Icon);
|
||||
|
||||
QScopedPointer<Group> group2(new Group());
|
||||
group2->setParent(group1.data());
|
||||
Uuid group2Icon = Uuid::random();
|
||||
QUuid group2Icon = QUuid::createUuid();
|
||||
dbSource->metadata()->addCustomIcon(group2Icon, iconImage1);
|
||||
group2->setIcon(group2Icon);
|
||||
|
||||
QScopedPointer<Entry> entry1(new Entry());
|
||||
entry1->setGroup(group2.data());
|
||||
Uuid entry1IconOld = Uuid::random();
|
||||
QUuid entry1IconOld = QUuid::createUuid();
|
||||
dbSource->metadata()->addCustomIcon(entry1IconOld, iconImage1);
|
||||
entry1->setIcon(entry1IconOld);
|
||||
|
||||
// add history item
|
||||
entry1->beginUpdate();
|
||||
Uuid entry1IconNew = Uuid::random();
|
||||
QUuid entry1IconNew = QUuid::createUuid();
|
||||
dbSource->metadata()->addCustomIcon(entry1IconNew, iconImage1);
|
||||
entry1->setIcon(entry1IconNew);
|
||||
entry1->endUpdate();
|
||||
@ -459,7 +459,7 @@ void TestGroup::testFindEntry()
|
||||
Entry* entry1 = new Entry();
|
||||
entry1->setTitle(QString("entry1"));
|
||||
entry1->setGroup(db->rootGroup());
|
||||
entry1->setUuid(Uuid::random());
|
||||
entry1->setUuid(QUuid::createUuid());
|
||||
|
||||
Group* group1 = new Group();
|
||||
group1->setName("group1");
|
||||
@ -468,13 +468,13 @@ void TestGroup::testFindEntry()
|
||||
|
||||
entry2->setTitle(QString("entry2"));
|
||||
entry2->setGroup(group1);
|
||||
entry2->setUuid(Uuid::random());
|
||||
entry2->setUuid(QUuid::createUuid());
|
||||
|
||||
group1->setParent(db->rootGroup());
|
||||
|
||||
Entry* entry;
|
||||
|
||||
entry = db->rootGroup()->findEntry(entry1->uuid().toHex());
|
||||
entry = db->rootGroup()->findEntry(entry1->uuid().toRfc4122().toHex());
|
||||
QVERIFY(entry != nullptr);
|
||||
QCOMPARE(entry->title(), QString("entry1"));
|
||||
|
||||
@ -491,7 +491,7 @@ void TestGroup::testFindEntry()
|
||||
entry = db->rootGroup()->findEntry(QString("//entry1"));
|
||||
QVERIFY(entry == nullptr);
|
||||
|
||||
entry = db->rootGroup()->findEntry(entry2->uuid().toHex());
|
||||
entry = db->rootGroup()->findEntry(entry2->uuid().toRfc4122().toHex());
|
||||
QVERIFY(entry != nullptr);
|
||||
QCOMPARE(entry->title(), QString("entry2"));
|
||||
|
||||
@ -602,7 +602,7 @@ void TestGroup::testPrint()
|
||||
Entry* entry1 = new Entry();
|
||||
entry1->setTitle(QString("entry1"));
|
||||
entry1->setGroup(db->rootGroup());
|
||||
entry1->setUuid(Uuid::random());
|
||||
entry1->setUuid(QUuid::createUuid());
|
||||
|
||||
output = db->rootGroup()->print();
|
||||
QCOMPARE(output, QString("entry1\n"));
|
||||
@ -614,7 +614,7 @@ void TestGroup::testPrint()
|
||||
|
||||
entry2->setTitle(QString("entry2"));
|
||||
entry2->setGroup(group1);
|
||||
entry2->setUuid(Uuid::random());
|
||||
entry2->setUuid(QUuid::createUuid());
|
||||
|
||||
group1->setParent(db->rootGroup());
|
||||
|
||||
|
@ -71,7 +71,7 @@ void TestKdbx2::testFormat200()
|
||||
QScopedPointer<Database> db(reader.readDatabase(filename, key));
|
||||
QCOMPARE(reader.version(), KeePass2::FILE_VERSION_2 & KeePass2::FILE_VERSION_CRITICAL_MASK);
|
||||
|
||||
QVERIFY(!reader.hasError());
|
||||
QVERIFY2(!reader.hasError(), reader.errorString().toStdString().c_str());
|
||||
verifyKdbx2Db(db.data());
|
||||
}
|
||||
|
||||
@ -82,6 +82,8 @@ void TestKdbx2::testFormat200Upgrade()
|
||||
key.addKey(PasswordKey("a"));
|
||||
KeePass2Reader reader;
|
||||
QScopedPointer<Database> db(reader.readDatabase(filename, key));
|
||||
QVERIFY2(!reader.hasError(), reader.errorString().toStdString().c_str());
|
||||
QVERIFY(!db.isNull());
|
||||
QCOMPARE(reader.version(), KeePass2::FILE_VERSION_2 & KeePass2::FILE_VERSION_CRITICAL_MASK);
|
||||
QCOMPARE(db->kdf()->uuid(), KeePass2::KDF_AES_KDBX3);
|
||||
|
||||
|
@ -109,7 +109,7 @@ void TestKdbx4::writeKdbx(QIODevice* device, Database* db, bool& hasError, QStri
|
||||
QCOMPARE(writer.version(), KeePass2::FILE_VERSION_4);
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(Uuid);
|
||||
Q_DECLARE_METATYPE(QUuid)
|
||||
void TestKdbx4::testFormat400()
|
||||
{
|
||||
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/Format400.kdbx");
|
||||
@ -136,8 +136,8 @@ void TestKdbx4::testFormat400()
|
||||
|
||||
void TestKdbx4::testFormat400Upgrade()
|
||||
{
|
||||
QFETCH(Uuid, kdfUuid);
|
||||
QFETCH(Uuid, cipherUuid);
|
||||
QFETCH(QUuid, kdfUuid);
|
||||
QFETCH(QUuid, cipherUuid);
|
||||
QFETCH(bool, addCustomData);
|
||||
QFETCH(quint32, expectedVersion);
|
||||
|
||||
@ -191,8 +191,8 @@ void TestKdbx4::testFormat400Upgrade()
|
||||
// clang-format off
|
||||
void TestKdbx4::testFormat400Upgrade_data()
|
||||
{
|
||||
QTest::addColumn<Uuid>("kdfUuid");
|
||||
QTest::addColumn<Uuid>("cipherUuid");
|
||||
QTest::addColumn<QUuid>("kdfUuid");
|
||||
QTest::addColumn<QUuid>("cipherUuid");
|
||||
QTest::addColumn<bool>("addCustomData");
|
||||
QTest::addColumn<quint32>("expectedVersion");
|
||||
|
||||
@ -265,20 +265,20 @@ void TestKdbx4::testUpgradeMasterKeyIntegrity()
|
||||
} else if (upgradeAction == "group-customdata") {
|
||||
auto group = new Group();
|
||||
group->setParent(db->rootGroup());
|
||||
group->setUuid(Uuid::random());
|
||||
group->setUuid(QUuid::createUuid());
|
||||
group->customData()->set("abc", "def");
|
||||
} else if (upgradeAction == "rootentry-customdata") {
|
||||
auto entry = new Entry();
|
||||
entry->setGroup(db->rootGroup());
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
entry->customData()->set("abc", "def");
|
||||
} else if (upgradeAction == "entry-customdata") {
|
||||
auto group = new Group();
|
||||
group->setParent(db->rootGroup());
|
||||
group->setUuid(Uuid::random());
|
||||
group->setUuid(QUuid::createUuid());
|
||||
auto entry = new Entry();
|
||||
entry->setGroup(group);
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
entry->customData()->set("abc", "def");
|
||||
} else {
|
||||
QFAIL(qPrintable(QString("Unknown action: %s").arg(upgradeAction)));
|
||||
@ -362,14 +362,14 @@ void TestKdbx4::testCustomData()
|
||||
// test copied custom group data
|
||||
auto* group = new Group();
|
||||
group->setParent(root);
|
||||
group->setUuid(Uuid::random());
|
||||
group->setUuid(QUuid::createUuid());
|
||||
group->customData()->copyDataFrom(root->customData());
|
||||
QCOMPARE(*group->customData(), *root->customData());
|
||||
|
||||
// test copied custom entry data
|
||||
auto* entry = new Entry();
|
||||
entry->setGroup(group);
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
entry->customData()->copyDataFrom(group->customData());
|
||||
QCOMPARE(*entry->customData(), *root->customData());
|
||||
|
||||
|
@ -47,18 +47,18 @@ void TestKeePass2Format::initTestCase()
|
||||
m_kdbxSourceDb->setKey(key);
|
||||
m_kdbxSourceDb->metadata()->setName("TESTDB");
|
||||
Group* group = m_kdbxSourceDb->rootGroup();
|
||||
group->setUuid(Uuid::random());
|
||||
group->setUuid(QUuid::createUuid());
|
||||
group->setNotes("I'm a note!");
|
||||
auto entry = new Entry();
|
||||
entry->setPassword(QString::fromUtf8("\xc3\xa4\xa3\xb6\xc3\xbc\xe9\x9b\xbb\xe7\xb4\x85"));
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
entry->attributes()->set("test", "protectedTest", true);
|
||||
QVERIFY(entry->attributes()->isProtected("test"));
|
||||
entry->attachments()->set("myattach.txt", QByteArray("this is an attachment"));
|
||||
entry->attachments()->set("aaa.txt", QByteArray("also an attachment"));
|
||||
entry->setGroup(group);
|
||||
auto groupNew = new Group();
|
||||
groupNew->setUuid(Uuid::random());
|
||||
groupNew->setUuid(QUuid::createUuid());
|
||||
groupNew->setName("TESTGROUP");
|
||||
groupNew->setNotes("I'm a sub group note!");
|
||||
groupNew->setParent(group);
|
||||
@ -108,7 +108,7 @@ void TestKeePass2Format::testXmlMetadata()
|
||||
void TestKeePass2Format::testXmlCustomIcons()
|
||||
{
|
||||
QCOMPARE(m_xmlDb->metadata()->customIcons().size(), 1);
|
||||
Uuid uuid = Uuid::fromBase64("++vyI+daLk6omox4a6kQGA==");
|
||||
QUuid uuid = QUuid::fromRfc4122(QByteArray::fromBase64("++vyI+daLk6omox4a6kQGA=="));
|
||||
QVERIFY(m_xmlDb->metadata()->customIcons().contains(uuid));
|
||||
QImage icon = m_xmlDb->metadata()->customIcon(uuid);
|
||||
QCOMPARE(icon.width(), 16);
|
||||
@ -128,11 +128,11 @@ void TestKeePass2Format::testXmlGroupRoot()
|
||||
{
|
||||
const Group* group = m_xmlDb->rootGroup();
|
||||
QVERIFY(group);
|
||||
QCOMPARE(group->uuid().toBase64(), QString("lmU+9n0aeESKZvcEze+bRg=="));
|
||||
QCOMPARE(group->uuid(), QUuid::fromRfc4122(QByteArray::fromBase64("lmU+9n0aeESKZvcEze+bRg==")));
|
||||
QCOMPARE(group->name(), QString("NewDatabase"));
|
||||
QCOMPARE(group->notes(), QString(""));
|
||||
QCOMPARE(group->iconNumber(), 49);
|
||||
QCOMPARE(group->iconUuid(), Uuid());
|
||||
QCOMPARE(group->iconUuid(), QUuid());
|
||||
QVERIFY(group->isExpanded());
|
||||
TimeInfo ti = group->timeInfo();
|
||||
QCOMPARE(ti.lastModificationTime(), Test::datetime(2010, 8, 8, 17, 24, 27));
|
||||
@ -145,7 +145,7 @@ void TestKeePass2Format::testXmlGroupRoot()
|
||||
QCOMPARE(group->defaultAutoTypeSequence(), QString(""));
|
||||
QCOMPARE(group->autoTypeEnabled(), Group::Inherit);
|
||||
QCOMPARE(group->searchingEnabled(), Group::Inherit);
|
||||
QCOMPARE(group->lastTopVisibleEntry()->uuid().toBase64(), QString("+wSUOv6qf0OzW8/ZHAs2sA=="));
|
||||
QCOMPARE(group->lastTopVisibleEntry()->uuid(), QUuid::fromRfc4122(QByteArray::fromBase64("+wSUOv6qf0OzW8/ZHAs2sA==")));
|
||||
QCOMPARE(group->children().size(), 3);
|
||||
QVERIFY(m_xmlDb->metadata()->recycleBin() == m_xmlDb->rootGroup()->children().at(2));
|
||||
|
||||
@ -156,11 +156,11 @@ void TestKeePass2Format::testXmlGroup1()
|
||||
{
|
||||
const Group* group = m_xmlDb->rootGroup()->children().at(0);
|
||||
|
||||
QCOMPARE(group->uuid().toBase64(), QString("AaUYVdXsI02h4T1RiAlgtg=="));
|
||||
QCOMPARE(group->uuid(), QUuid::fromRfc4122(QByteArray::fromBase64("AaUYVdXsI02h4T1RiAlgtg==")));
|
||||
QCOMPARE(group->name(), QString("General"));
|
||||
QCOMPARE(group->notes(), QString("Group Notez"));
|
||||
QCOMPARE(group->iconNumber(), 48);
|
||||
QCOMPARE(group->iconUuid(), Uuid());
|
||||
QCOMPARE(group->iconUuid(), QUuid());
|
||||
QCOMPARE(group->isExpanded(), true);
|
||||
QCOMPARE(group->defaultAutoTypeSequence(), QString("{Password}{ENTER}"));
|
||||
QCOMPARE(group->autoTypeEnabled(), Group::Enable);
|
||||
@ -172,19 +172,19 @@ void TestKeePass2Format::testXmlGroup2()
|
||||
{
|
||||
const Group* group = m_xmlDb->rootGroup()->children().at(1);
|
||||
|
||||
QCOMPARE(group->uuid().toBase64(), QString("1h4NtL5DK0yVyvaEnN//4A=="));
|
||||
QCOMPARE(group->uuid(), QUuid::fromRfc4122(QByteArray::fromBase64("1h4NtL5DK0yVyvaEnN//4A==")));
|
||||
QCOMPARE(group->name(), QString("Windows"));
|
||||
QCOMPARE(group->isExpanded(), false);
|
||||
|
||||
QCOMPARE(group->children().size(), 1);
|
||||
const Group* child = group->children().first();
|
||||
|
||||
QCOMPARE(child->uuid().toBase64(), QString("HoYE/BjLfUSW257pCHJ/eA=="));
|
||||
QCOMPARE(child->uuid(), QUuid::fromRfc4122(QByteArray::fromBase64("HoYE/BjLfUSW257pCHJ/eA==")));
|
||||
QCOMPARE(child->name(), QString("Subsub"));
|
||||
QCOMPARE(child->entries().size(), 1);
|
||||
|
||||
const Entry* entry = child->entries().first();
|
||||
QCOMPARE(entry->uuid().toBase64(), QString("GZpdQvGXOU2kaKRL/IVAGg=="));
|
||||
QCOMPARE(entry->uuid(), QUuid::fromRfc4122(QByteArray::fromBase64("GZpdQvGXOU2kaKRL/IVAGg==")));
|
||||
QCOMPARE(entry->title(), QString("Subsub Entry"));
|
||||
}
|
||||
|
||||
@ -192,10 +192,10 @@ void TestKeePass2Format::testXmlEntry1()
|
||||
{
|
||||
const Entry* entry = m_xmlDb->rootGroup()->entries().at(0);
|
||||
|
||||
QCOMPARE(entry->uuid().toBase64(), QString("+wSUOv6qf0OzW8/ZHAs2sA=="));
|
||||
QCOMPARE(entry->uuid(), QUuid::fromRfc4122(QByteArray::fromBase64("+wSUOv6qf0OzW8/ZHAs2sA==")));
|
||||
QCOMPARE(entry->historyItems().size(), 2);
|
||||
QCOMPARE(entry->iconNumber(), 0);
|
||||
QCOMPARE(entry->iconUuid(), Uuid());
|
||||
QCOMPARE(entry->iconUuid(), QUuid());
|
||||
QVERIFY(!entry->foregroundColor().isValid());
|
||||
QVERIFY(!entry->backgroundColor().isValid());
|
||||
QCOMPARE(entry->overrideUrl(), QString(""));
|
||||
@ -254,9 +254,9 @@ void TestKeePass2Format::testXmlEntry2()
|
||||
{
|
||||
const Entry* entry = m_xmlDb->rootGroup()->entries().at(1);
|
||||
|
||||
QCOMPARE(entry->uuid().toBase64(), QString("4jbADG37hkiLh2O0qUdaOQ=="));
|
||||
QCOMPARE(entry->uuid(), QUuid::fromRfc4122(QByteArray::fromBase64("4jbADG37hkiLh2O0qUdaOQ==")));
|
||||
QCOMPARE(entry->iconNumber(), 0);
|
||||
QCOMPARE(entry->iconUuid().toBase64(), QString("++vyI+daLk6omox4a6kQGA=="));
|
||||
QCOMPARE(entry->iconUuid(), QUuid::fromRfc4122(QByteArray::fromBase64("++vyI+daLk6omox4a6kQGA==")));
|
||||
// TODO: test entry->icon()
|
||||
QCOMPARE(entry->foregroundColor(), QColor(255, 0, 0));
|
||||
QCOMPARE(entry->backgroundColor(), QColor(255, 255, 0));
|
||||
@ -330,11 +330,11 @@ void TestKeePass2Format::testXmlDeletedObjects()
|
||||
DeletedObject delObj;
|
||||
|
||||
delObj = objList.takeFirst();
|
||||
QCOMPARE(delObj.uuid.toBase64(), QString("5K/bzWCSmkCv5OZxYl4N/w=="));
|
||||
QCOMPARE(delObj.uuid, QUuid::fromRfc4122(QByteArray::fromBase64("5K/bzWCSmkCv5OZxYl4N/w==")));
|
||||
QCOMPARE(delObj.deletionTime, Test::datetime(2010, 8, 25, 16, 14, 12));
|
||||
|
||||
delObj = objList.takeFirst();
|
||||
QCOMPARE(delObj.uuid.toBase64(), QString("80h8uSNWgkKhKCp1TgXF7g=="));
|
||||
QCOMPARE(delObj.uuid, QUuid::fromRfc4122(QByteArray::fromBase64("80h8uSNWgkKhKCp1TgXF7g==")));
|
||||
QCOMPARE(delObj.deletionTime, Test::datetime(2010, 8, 25, 16, 14, 14));
|
||||
|
||||
QVERIFY(objList.isEmpty());
|
||||
@ -424,7 +424,7 @@ void TestKeePass2Format::testXmlInvalidXmlChars()
|
||||
QString().append(QChar(0x31)).append(QChar(0xD801)).append(QChar(0xDC37)).append(QChar(0x32));
|
||||
|
||||
auto entry = new Entry();
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
entry->setGroup(dbWrite->rootGroup());
|
||||
entry->attributes()->set("PlainInvalid", strPlainInvalid);
|
||||
entry->attributes()->set("PlainValid", strPlainValid);
|
||||
@ -577,12 +577,12 @@ void TestKeePass2Format::testDuplicateAttachments()
|
||||
|
||||
auto entry1 = new Entry();
|
||||
entry1->setGroup(db->rootGroup());
|
||||
entry1->setUuid(Uuid("aaaaaaaaaaaaaaaa"));
|
||||
entry1->setUuid(QUuid::fromRfc4122(QByteArray::fromHex("aaaaaaaaaaaaaaaa")));
|
||||
entry1->attachments()->set("a", attachment1);
|
||||
|
||||
auto entry2 = new Entry();
|
||||
entry2->setGroup(db->rootGroup());
|
||||
entry2->setUuid(Uuid("bbbbbbbbbbbbbbbb"));
|
||||
entry2->setUuid(QUuid::fromRfc4122(QByteArray::fromHex("bbbbbbbbbbbbbbbb")));
|
||||
entry2->attachments()->set("b1", attachment1);
|
||||
entry2->beginUpdate();
|
||||
entry2->attachments()->set("b2", attachment1);
|
||||
@ -596,7 +596,7 @@ void TestKeePass2Format::testDuplicateAttachments()
|
||||
|
||||
auto entry3 = new Entry();
|
||||
entry3->setGroup(db->rootGroup());
|
||||
entry3->setUuid(Uuid("cccccccccccccccc"));
|
||||
entry3->setUuid(QUuid::fromRfc4122(QByteArray::fromHex("cccccccccccccccc")));
|
||||
entry3->attachments()->set("c1", attachment2);
|
||||
entry3->attachments()->set("c2", attachment2);
|
||||
entry3->attachments()->set("c3", attachment3);
|
||||
|
@ -216,8 +216,7 @@ void TestMerge::testResolveConflictKeepBoth()
|
||||
QVERIFY2(olderEntry->attributes()->hasKey("merged"), "older entry is marked with an attribute \"merged\"");
|
||||
QCOMPARE(olderEntry->historyItems().isEmpty(), false);
|
||||
|
||||
QVERIFY2(olderEntry->uuid().toHex() != updatedEntry->uuid().toHex(),
|
||||
"KeepBoth should not reuse the UUIDs when cloning.");
|
||||
QVERIFY2(olderEntry->uuid() != updatedEntry->uuid(), "KeepBoth should not reuse the UUIDs when cloning.");
|
||||
|
||||
delete dbSource;
|
||||
delete dbDestination;
|
||||
@ -308,7 +307,7 @@ void TestMerge::testCreateNewGroups()
|
||||
QTest::qSleep(1);
|
||||
Group* group3 = new Group();
|
||||
group3->setName("group3");
|
||||
group3->setUuid(Uuid::random());
|
||||
group3->setUuid(QUuid::createUuid());
|
||||
group3->setParent(dbSource->rootGroup());
|
||||
|
||||
dbDestination->merge(dbSource);
|
||||
@ -331,7 +330,7 @@ void TestMerge::testMoveEntryIntoNewGroup()
|
||||
QTest::qSleep(1);
|
||||
Group* group3 = new Group();
|
||||
group3->setName("group3");
|
||||
group3->setUuid(Uuid::random());
|
||||
group3->setUuid(QUuid::createUuid());
|
||||
group3->setParent(dbSource->rootGroup());
|
||||
|
||||
Entry* entry1 = dbSource->rootGroup()->findEntry("entry1");
|
||||
@ -367,13 +366,13 @@ void TestMerge::testUpdateEntryDifferentLocation()
|
||||
|
||||
Group* group3 = new Group();
|
||||
group3->setName("group3");
|
||||
group3->setUuid(Uuid::random());
|
||||
group3->setUuid(QUuid::createUuid());
|
||||
group3->setParent(dbDestination->rootGroup());
|
||||
|
||||
Entry* entry1 = dbDestination->rootGroup()->findEntry("entry1");
|
||||
QVERIFY(entry1 != nullptr);
|
||||
entry1->setGroup(group3);
|
||||
Uuid uuidBeforeSyncing = entry1->uuid();
|
||||
QUuid uuidBeforeSyncing = entry1->uuid();
|
||||
|
||||
// Change the entry in the source db.
|
||||
QTest::qSleep(1);
|
||||
@ -413,7 +412,7 @@ void TestMerge::testUpdateGroup()
|
||||
Group* group2 = dbSource->rootGroup()->findChildByName("group2");
|
||||
group2->setName("group2 renamed");
|
||||
group2->setNotes("updated notes");
|
||||
Uuid customIconId = Uuid::random();
|
||||
QUuid customIconId = QUuid::createUuid();
|
||||
QImage customIcon;
|
||||
dbSource->metadata()->addCustomIcon(customIconId, customIcon);
|
||||
group2->setIcon(customIconId);
|
||||
@ -422,7 +421,7 @@ void TestMerge::testUpdateGroup()
|
||||
QVERIFY(entry1 != nullptr);
|
||||
entry1->setGroup(group2);
|
||||
entry1->setTitle("entry1 renamed");
|
||||
Uuid uuidBeforeSyncing = entry1->uuid();
|
||||
QUuid uuidBeforeSyncing = entry1->uuid();
|
||||
|
||||
dbDestination->merge(dbSource);
|
||||
|
||||
@ -446,7 +445,7 @@ void TestMerge::testUpdateGroupLocation()
|
||||
{
|
||||
Database* dbDestination = createTestDatabase();
|
||||
Group* group3 = new Group();
|
||||
Uuid group3Uuid = Uuid::random();
|
||||
QUuid group3Uuid = QUuid::createUuid();
|
||||
group3->setUuid(group3Uuid);
|
||||
group3->setName("group3");
|
||||
group3->setParent(dbDestination->rootGroup()->findChildByName("group1"));
|
||||
@ -509,7 +508,7 @@ void TestMerge::testMergeCustomIcons()
|
||||
Database* dbDestination = new Database();
|
||||
Database* dbSource = createTestDatabase();
|
||||
|
||||
Uuid customIconId = Uuid::random();
|
||||
QUuid customIconId = QUuid::createUuid();
|
||||
QImage customIcon;
|
||||
|
||||
dbSource->metadata()->addCustomIcon(customIconId, customIcon);
|
||||
@ -566,11 +565,11 @@ Database* TestMerge::createTestDatabase()
|
||||
|
||||
Group* group1 = new Group();
|
||||
group1->setName("group1");
|
||||
group1->setUuid(Uuid::random());
|
||||
group1->setUuid(QUuid::createUuid());
|
||||
|
||||
Group* group2 = new Group();
|
||||
group2->setName("group2");
|
||||
group2->setUuid(Uuid::random());
|
||||
group2->setUuid(QUuid::createUuid());
|
||||
|
||||
Entry* entry1 = new Entry();
|
||||
Entry* entry2 = new Entry();
|
||||
@ -578,14 +577,14 @@ Database* TestMerge::createTestDatabase()
|
||||
// Give Entry 1 a history
|
||||
entry1->beginUpdate();
|
||||
entry1->setGroup(group1);
|
||||
entry1->setUuid(Uuid::random());
|
||||
entry1->setUuid(QUuid::createUuid());
|
||||
entry1->setTitle("entry1");
|
||||
entry1->endUpdate();
|
||||
|
||||
// Give Entry 2 a history
|
||||
entry2->beginUpdate();
|
||||
entry2->setGroup(group1);
|
||||
entry2->setUuid(Uuid::random());
|
||||
entry2->setUuid(QUuid::createUuid());
|
||||
entry2->setTitle("entry2");
|
||||
entry2->endUpdate();
|
||||
|
||||
|
@ -115,7 +115,7 @@ void TestModified::testGroupSets()
|
||||
|
||||
QSignalSpy spyModified(db.data(), SIGNAL(modifiedImmediate()));
|
||||
|
||||
root->setUuid(Uuid::random());
|
||||
root->setUuid(QUuid::createUuid());
|
||||
QCOMPARE(spyModified.count(), ++spyCount);
|
||||
root->setUuid(root->uuid());
|
||||
QCOMPARE(spyModified.count(), spyCount);
|
||||
@ -135,12 +135,13 @@ void TestModified::testGroupSets()
|
||||
root->setIcon(root->iconNumber());
|
||||
QCOMPARE(spyModified.count(), spyCount);
|
||||
|
||||
root->setIcon(Uuid::random());
|
||||
root->setIcon(QUuid::createUuid());
|
||||
QCOMPARE(spyModified.count(), ++spyCount);
|
||||
root->setIcon(root->iconUuid());
|
||||
QCOMPARE(spyModified.count(), spyCount);
|
||||
|
||||
group->setUuid(Uuid::random());
|
||||
|
||||
group->setUuid(QUuid::createUuid());
|
||||
QCOMPARE(spyModified.count(), ++spyCount);
|
||||
group->setUuid(group->uuid());
|
||||
QCOMPARE(spyModified.count(), spyCount);
|
||||
@ -160,7 +161,7 @@ void TestModified::testGroupSets()
|
||||
group->setIcon(group->iconNumber());
|
||||
QCOMPARE(spyModified.count(), spyCount);
|
||||
|
||||
group->setIcon(Uuid::random());
|
||||
group->setIcon(QUuid::createUuid());
|
||||
QCOMPARE(spyModified.count(), ++spyCount);
|
||||
group->setIcon(group->iconUuid());
|
||||
QCOMPARE(spyModified.count(), spyCount);
|
||||
@ -179,7 +180,7 @@ void TestModified::testEntrySets()
|
||||
|
||||
QSignalSpy spyModified(db.data(), SIGNAL(modifiedImmediate()));
|
||||
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
QCOMPARE(spyModified.count(), ++spyCount);
|
||||
entry->setUuid(entry->uuid());
|
||||
QCOMPARE(spyModified.count(), spyCount);
|
||||
@ -214,7 +215,7 @@ void TestModified::testEntrySets()
|
||||
entry->setIcon(entry->iconNumber());
|
||||
QCOMPARE(spyModified.count(), spyCount);
|
||||
|
||||
entry->setIcon(Uuid::random());
|
||||
entry->setIcon(QUuid::createUuid());
|
||||
QCOMPARE(spyModified.count(), ++spyCount);
|
||||
entry->setIcon(entry->iconUuid());
|
||||
QCOMPARE(spyModified.count(), spyCount);
|
||||
@ -283,7 +284,7 @@ void TestModified::testHistoryItems()
|
||||
{
|
||||
QScopedPointer<Entry> entry(new Entry());
|
||||
QDateTime created = entry->timeInfo().creationTime();
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setUuid(QUuid::createUuid());
|
||||
entry->setTitle("a");
|
||||
entry->setTags("a");
|
||||
QScopedPointer<EntryAttributes> attributes(new EntryAttributes());
|
||||
|
Loading…
Reference in New Issue
Block a user