mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-29 07:43:36 -05:00
parent
cc6f524168
commit
7fd8154ea8
@ -26,6 +26,7 @@
|
|||||||
#include "core/Entry.h"
|
#include "core/Entry.h"
|
||||||
#include "core/Group.h"
|
#include "core/Group.h"
|
||||||
#include "core/Metadata.h"
|
#include "core/Metadata.h"
|
||||||
|
#include "core/Tools.h"
|
||||||
#include "crypto/CryptoHash.h"
|
#include "crypto/CryptoHash.h"
|
||||||
#include "format/KeePass1.h"
|
#include "format/KeePass1.h"
|
||||||
#include "keys/CompositeKey.h"
|
#include "keys/CompositeKey.h"
|
||||||
@ -314,17 +315,13 @@ bool KeePass1Reader::verifyKey(SymmetricCipherStream* cipherStream)
|
|||||||
{
|
{
|
||||||
CryptoHash contentHash(CryptoHash::Sha256);
|
CryptoHash contentHash(CryptoHash::Sha256);
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
buffer.resize(16384);
|
|
||||||
qint64 readResult;
|
|
||||||
do {
|
do {
|
||||||
readResult = cipherStream->read(buffer.data(), buffer.size());
|
if (!Tools::readFromDevice(cipherStream, buffer)) {
|
||||||
if (readResult > 0) {
|
return false;
|
||||||
if (readResult != buffer.size()) {
|
|
||||||
buffer.resize(readResult);
|
|
||||||
}
|
}
|
||||||
contentHash.addData(buffer);
|
contentHash.addData(buffer);
|
||||||
}
|
} while (!buffer.isEmpty());
|
||||||
} while (readResult == buffer.size());
|
|
||||||
|
|
||||||
return contentHash.result() == m_contentHashHeader;
|
return contentHash.result() == m_contentHashHeader;
|
||||||
}
|
}
|
||||||
@ -791,6 +788,49 @@ bool KeePass1Reader::isMetaStream(const Entry* entry)
|
|||||||
&& entry->iconNumber() == 0;
|
&& entry->iconNumber() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray KeePass1Reader::readKeyfile(QIODevice* device)
|
||||||
|
{
|
||||||
|
if (device->size() == 0) {
|
||||||
|
return QByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device->size() == 32) {
|
||||||
|
QByteArray data = device->read(32);
|
||||||
|
if (data.size() != 32) {
|
||||||
|
return QByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device->size() == 64) {
|
||||||
|
QByteArray data = device->read(64);
|
||||||
|
|
||||||
|
if (data.size() != 64) {
|
||||||
|
return QByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tools::isHex(data)) {
|
||||||
|
return QByteArray::fromHex(data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
device->seek(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CryptoHash cryptoHash(CryptoHash::Sha256);
|
||||||
|
QByteArray buffer;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (!Tools::readFromDevice(device, buffer)) {
|
||||||
|
return QByteArray();
|
||||||
|
}
|
||||||
|
cryptoHash.addData(buffer);
|
||||||
|
} while (!buffer.isEmpty());
|
||||||
|
|
||||||
|
return cryptoHash.result();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QByteArray KeePass1Key::rawKey() const
|
QByteArray KeePass1Key::rawKey() const
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,7 @@ public:
|
|||||||
const QByteArray& keyfileData);
|
const QByteArray& keyfileData);
|
||||||
Database* readDatabase(const QString& filename, const QString& password,
|
Database* readDatabase(const QString& filename, const QString& password,
|
||||||
const QByteArray& keyfileData);
|
const QByteArray& keyfileData);
|
||||||
|
static QByteArray readKeyfile(QIODevice* device);
|
||||||
bool hasError();
|
bool hasError();
|
||||||
QString errorString();
|
QString errorString();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user