2010-09-13 23:24:36 +02:00
|
|
|
/*
|
|
|
|
* 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_KEEPASS2READER_H
|
|
|
|
#define KEEPASSX_KEEPASS2READER_H
|
|
|
|
|
2013-10-03 15:18:16 +02:00
|
|
|
#include <QCoreApplication>
|
2010-09-13 23:24:36 +02:00
|
|
|
|
|
|
|
#include "keys/CompositeKey.h"
|
2017-11-13 02:23:01 +08:00
|
|
|
#include "format/KeePass2.h"
|
2010-09-13 23:24:36 +02:00
|
|
|
|
|
|
|
class Database;
|
2011-11-12 12:20:08 +01:00
|
|
|
class QIODevice;
|
2010-09-13 23:24:36 +02:00
|
|
|
|
|
|
|
class KeePass2Reader
|
|
|
|
{
|
2012-01-11 19:18:35 +01:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(KeePass2Reader)
|
2010-09-13 23:24:36 +02:00
|
|
|
|
|
|
|
public:
|
2011-07-06 20:21:40 +02:00
|
|
|
KeePass2Reader();
|
2016-01-28 23:07:04 +01:00
|
|
|
Database* readDatabase(QIODevice* device, const CompositeKey& key, bool keepDatabase = false);
|
2010-09-13 23:24:36 +02:00
|
|
|
Database* readDatabase(const QString& filename, const CompositeKey& key);
|
2012-01-06 20:03:13 +01:00
|
|
|
bool hasError();
|
2010-09-13 23:24:36 +02:00
|
|
|
QString errorString();
|
2011-07-06 20:21:40 +02:00
|
|
|
void setSaveXml(bool save);
|
|
|
|
QByteArray xmlData();
|
2016-01-28 23:07:04 +01:00
|
|
|
QByteArray streamKey();
|
2017-11-13 02:23:01 +08:00
|
|
|
KeePass2::ProtectedStreamAlgo protectedStreamAlgo() const;
|
2010-09-13 23:24:36 +02:00
|
|
|
|
|
|
|
private:
|
2013-06-30 14:43:02 +02:00
|
|
|
void raiseError(const QString& errorMessage);
|
2010-09-13 23:24:36 +02:00
|
|
|
|
|
|
|
bool readHeaderField();
|
|
|
|
|
|
|
|
void setCipher(const QByteArray& data);
|
|
|
|
void setCompressionFlags(const QByteArray& data);
|
|
|
|
void setMasterSeed(const QByteArray& data);
|
|
|
|
void setTransformSeed(const QByteArray& data);
|
2016-12-02 04:12:57 +00:00
|
|
|
void setTransformRounds(const QByteArray& data);
|
2010-09-13 23:24:36 +02:00
|
|
|
void setEncryptionIV(const QByteArray& data);
|
|
|
|
void setProtectedStreamKey(const QByteArray& data);
|
|
|
|
void setStreamStartBytes(const QByteArray& data);
|
|
|
|
void setInnerRandomStreamID(const QByteArray& data);
|
|
|
|
|
|
|
|
QIODevice* m_device;
|
2012-09-25 22:33:36 +02:00
|
|
|
QIODevice* m_headerStream;
|
2010-09-13 23:24:36 +02:00
|
|
|
bool m_error;
|
|
|
|
QString m_errorStr;
|
|
|
|
bool m_headerEnd;
|
2011-07-06 20:21:40 +02:00
|
|
|
bool m_saveXml;
|
|
|
|
QByteArray m_xmlData;
|
2010-09-13 23:24:36 +02:00
|
|
|
|
2010-09-25 12:41:00 +02:00
|
|
|
Database* m_db;
|
2010-09-13 23:24:36 +02:00
|
|
|
QByteArray m_masterSeed;
|
|
|
|
QByteArray m_encryptionIV;
|
|
|
|
QByteArray m_streamStartBytes;
|
2011-01-13 22:31:17 +01:00
|
|
|
QByteArray m_protectedStreamKey;
|
2017-11-13 02:23:01 +08:00
|
|
|
KeePass2::ProtectedStreamAlgo m_irsAlgo;
|
2010-09-13 23:24:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // KEEPASSX_KEEPASS2READER_H
|