mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-25 15:55:38 -04:00
Replaced Uuid with QUuid
This commit is contained in:
parent
dcece140a0
commit
ad4423d226
49 changed files with 413 additions and 612 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue