Skip to content
Permalink
Browse files

Add support for gzip compressed databases.

  • Loading branch information...
debfx committed Sep 23, 2010
1 parent f0e711a commit b8dfb9cc4d5133e0f09cd7533d15a4f1c19a40f2
@@ -49,6 +49,8 @@ find_package(Automoc4 REQUIRED)

find_package(Libgcrypt REQUIRED)

find_package(ZLIB REQUIRED)

add_subdirectory(src)
if( WITH_TESTS )
add_subdirectory(tests)
@@ -30,6 +30,10 @@ Files: share/icons/entries/*.png
Copyright: 2003-2004, David Vignoni <david@icon-king.com>
License: LGPL-2.1

Files: src/streams/qtiocompressor.*, src/streams/QtIOCompressor
Copyright: 2009, Nokia Corporation and/or its subsidiary(-ies)
License: LGPL-2.1 or GPL-3

Files: tests/modeltest.*
Copyright: 2007, Trolltech ASA
License: GPL-2

Large diffs are not rendered by default.

@@ -0,0 +1,23 @@
Nokia Qt LGPL Exception version 1.1

As an additional permission to the GNU Lesser General Public License
version 2.1, the object code form of a "work that uses the Library"
may incorporate material from a header file that is part of the
Library. You may distribute such object code under terms of your
choice, provided that:
(i) the header files of the Library have not been modified; and
(ii) the incorporated material is limited to numerical parameters,
data structure layouts, accessors, macros, inline functions and
templates; and
(iii) you comply with the terms of Section 6 of the GNU
Lesser General Public License version 2.1.

Moreover, you may apply this exception to a modified version of the
Library, provided that such modification does not involve copying
material from the Library into the modified Library?s header files
unless such material is limited to (i) numerical parameters; (ii) data
structure layouts; (iii) accessors; and (iv) small macros, templates
and inline functions of five lines or less in length.

Furthermore, you are not required to apply this additional permission
to a modified version of the Library.
@@ -43,6 +43,7 @@ set(keepassx_SOURCES
keys/PasswordKey.cpp
streams/HashedBlockStream.cpp
streams/LayeredStream.cpp
streams/qtiocompressor.cpp
streams/SymmetricCipherStream.cpp
)

@@ -55,4 +56,4 @@ qt4_wrap_ui(keepassx_SOURCES ${keepassx_FORMS})
automoc4_add_library( keepassx_core STATIC ${keepassx_SOURCES} )

automoc4_add_executable( ${PROGNAME} WIN32 MACOSX_BUNDLE main.cpp )
target_link_libraries( ${PROGNAME} keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${LIBGCRYPT_LIBS} )
target_link_libraries( ${PROGNAME} keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${LIBGCRYPT_LIBS} ${ZLIB_LIBRARIES} )
@@ -21,10 +21,10 @@
#include <QtCore/QFile>
#include <QtCore/QIODevice>

#include "KeePass2.h"
#include "KeePass2XmlReader.h"
#include "crypto/CryptoHash.h"
#include "streams/HashedBlockStream.h"
#include "streams/QtIOCompressor"
#include "streams/SymmetricCipherStream.h"

const QSysInfo::Endian KeePass2Reader::BYTEORDER = QSysInfo::LittleEndian;
@@ -80,8 +80,22 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
HashedBlockStream hashedStream(&cipherStream);
hashedStream.open(QIODevice::ReadOnly);

QIODevice* xmlDevice;
QScopedPointer<QtIOCompressor> ioCompressor;

if (m_compression == KeePass2::CompressionNone) {
xmlDevice = &hashedStream;
}
else {
ioCompressor.reset(new QtIOCompressor(&hashedStream));
ioCompressor->setStreamFormat(QtIOCompressor::GzipFormat);
ioCompressor->open(QIODevice::ReadOnly);
xmlDevice = ioCompressor.data();
}

KeePass2XmlReader xmlReader;
Database* db = xmlReader.readDatabase(&hashedStream);
Database* db = xmlReader.readDatabase(xmlDevice);
// TODO forward error messages from xmlReader
return db;
}

@@ -208,7 +222,7 @@ void KeePass2Reader::setCompressionFlags(const QByteArray& data)
raiseError("");
}
else {
m_compression = id;
m_compression = static_cast<KeePass2::CompressionAlgorithm>(id);
}
}
}
@@ -23,6 +23,7 @@
#include "core/Endian.h"
#include "core/Uuid.h"
#include "keys/CompositeKey.h"
#include "format/KeePass2.h"

class Database;

@@ -59,7 +60,7 @@ class KeePass2Reader
bool m_headerEnd;

Uuid m_cipher;
int m_compression;
KeePass2::CompressionAlgorithm m_compression;
QByteArray m_masterSeed;
QByteArray m_transformSeed;
quint64 m_transformRounds;
@@ -0,0 +1 @@
#include "qtiocompressor.h"

0 comments on commit b8dfb9c

Please sign in to comment.
You can’t perform that action at this time.