mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add ability to grab the raw xml string of kdbx databases.
This commit is contained in:
parent
a104e859cf
commit
ef8935431c
@ -29,6 +29,11 @@
|
||||
#include "streams/QtIOCompressor"
|
||||
#include "streams/SymmetricCipherStream.h"
|
||||
|
||||
KeePass2Reader::KeePass2Reader()
|
||||
{
|
||||
m_saveXml = false;
|
||||
}
|
||||
|
||||
Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& key)
|
||||
{
|
||||
m_db = new Database();
|
||||
@ -102,6 +107,15 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
||||
SymmetricCipher protectedStream(SymmetricCipher::Salsa20, SymmetricCipher::Stream, SymmetricCipher::Decrypt,
|
||||
protectedStreamKey, KeePass2::INNER_STREAM_SALSA20_IV);
|
||||
|
||||
QScopedPointer<QBuffer> buffer;
|
||||
|
||||
if (m_saveXml) {
|
||||
m_xmlData = xmlDevice->readAll();
|
||||
buffer.reset(new QBuffer(&m_xmlData));
|
||||
buffer->open(QIODevice::ReadOnly);
|
||||
xmlDevice = buffer.data();
|
||||
}
|
||||
|
||||
KeePass2XmlReader xmlReader;
|
||||
xmlReader.readDatabase(xmlDevice, m_db, &protectedStream);
|
||||
// TODO forward error messages from xmlReader
|
||||
@ -128,6 +142,16 @@ QString KeePass2Reader::errorString()
|
||||
return QString();
|
||||
}
|
||||
|
||||
void KeePass2Reader::setSaveXml(bool save)
|
||||
{
|
||||
m_saveXml = save;
|
||||
}
|
||||
|
||||
QByteArray KeePass2Reader::xmlData()
|
||||
{
|
||||
return m_xmlData;
|
||||
}
|
||||
|
||||
void KeePass2Reader::raiseError(const QString& str)
|
||||
{
|
||||
// TODO
|
||||
|
@ -31,10 +31,13 @@ class KeePass2Reader
|
||||
Q_DECLARE_TR_FUNCTIONS(KeePass2Reader);
|
||||
|
||||
public:
|
||||
KeePass2Reader();
|
||||
Database* readDatabase(QIODevice* device, const CompositeKey& key);
|
||||
Database* readDatabase(const QString& filename, const CompositeKey& key);
|
||||
bool error();
|
||||
QString errorString();
|
||||
void setSaveXml(bool save);
|
||||
QByteArray xmlData();
|
||||
|
||||
private:
|
||||
void raiseError(const QString& str);
|
||||
@ -55,6 +58,8 @@ private:
|
||||
bool m_error;
|
||||
QString m_errorStr;
|
||||
bool m_headerEnd;
|
||||
bool m_saveXml;
|
||||
QByteArray m_xmlData;
|
||||
|
||||
Database* m_db;
|
||||
QByteArray m_masterSeed;
|
||||
|
Loading…
Reference in New Issue
Block a user