Skip to content

Commit

Permalink
Adds GZip decompression compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dannygb committed May 22, 2016
1 parent 258dcd9 commit 16ded32
Show file tree
Hide file tree
Showing 57 changed files with 10,099 additions and 24 deletions.
3 changes: 2 additions & 1 deletion KeePit.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ TEMPLATE = subdirs
#load Ubuntu specific features
load(ubuntu-click)

SUBDIRS += KeePit
SUBDIRS += KeePit \
ziplib

# specify the manifest file, this file is required for click
# packaging and for the IDE to create runconfigurations
Expand Down
20 changes: 10 additions & 10 deletions KeePit.pro.user
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.0, 2016-04-21T06:42:20. -->
<!-- Written by QtCreator 3.5.0, 2016-05-22T15:20:17. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{2cc89096-7ac7-402a-b71d-c1e097c9bbff}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
Expand Down Expand Up @@ -61,7 +61,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{be3ccc75-fa7f-49f4-aff7-5b2317ccab85}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
Expand Down Expand Up @@ -288,7 +288,7 @@
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">KeePit2</value>
Expand Down Expand Up @@ -451,12 +451,12 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">UbuntuProjectManager.UploadStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedFiles">
<value type="QString">/home/dan/build-KeePass3-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid-Release/keepass3.username_0.1_armhf.click</value>
<value type="QString">/home/dan/build-KeePit-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid-Release/keepit.dannygb_1.0_armhf.click</value>
<value type="QString">/home/dan/build-KeePit-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid-Release/keepit.dannygb_1.2_armhf.click</value>
<value type="QString">/home/dan/build-KeePass3-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid-Release/keepass3.dannygb_0.1_armhf.click</value>
<value type="QString">/home/dan/build-KeePit-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid-Release/keepit.dannygb_2.0_armhf.click</value>
<value type="QString">/usr/share/qtcreator/ubuntu/scripts/qtc_device_applaunch.py</value>
<value type="QString">/home/dan/build-KeePass3-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid-Release/keepass3.username_0.1_armhf.click</value>
<value type="QString">/home/dan/build-KeePit-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid-Release/keepit.dannygb_1.0_armhf.click</value>
<value type="QString">/home/dan/build-KeePit-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid-Release/keepit.dannygb_2.0_armhf.click</value>
</valuelist>
<valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedHosts">
<value type="QString">127.0.0.1</value>
Expand All @@ -483,12 +483,12 @@
<value type="QString">/var/lib/schroot/chroots/click-ubuntu-sdk-15.04-armhf</value>
</valuelist>
<valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedTimes">
<value type="QDateTime">2015-12-06T19:13:53</value>
<value type="QDateTime">2016-02-21T16:26:47</value>
<value type="QDateTime">2016-03-14T20:53:57</value>
<value type="QDateTime">2016-01-31T15:24:37</value>
<value type="QDateTime">2016-03-24T22:21:10</value>
<value type="QDateTime">2016-03-24T22:21:11</value>
<value type="QDateTime">2015-12-06T19:13:53</value>
<value type="QDateTime">2016-02-21T16:26:47</value>
<value type="QDateTime">2016-03-24T22:21:10</value>
</valuelist>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
Expand Down
12 changes: 10 additions & 2 deletions KeePit/KeePit.pro
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ SOURCES += main.cpp \
arrayextensions.cpp \
aes.cpp \
filehandler.cpp \
bytestream.cpp
bytestream.cpp \

RESOURCES += KeePit.qrc

Expand Down Expand Up @@ -333,7 +333,8 @@ HEADERS += \
arrayextensions.h \
aes.h \
filehandler.h \
bytestream.h
bytestream.h \
stdafx.h

DISTFILES += \
OpenDatabase.qml \
Expand All @@ -354,3 +355,10 @@ DISTFILES += \
KeePit.png \
KeePit.contenthub \
KeePit.apparmor

unix:!macx: LIBS += -L$$OUT_PWD/../ziplib/ -lziplib

INCLUDEPATH += $$PWD/../ziplib
DEPENDPATH += $$PWD/../ziplib

unix:!macx: PRE_TARGETDEPS += $$OUT_PWD/../ziplib/libziplib.a
2 changes: 1 addition & 1 deletion KeePit/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ MainView {
id: about
Dialog {
id: aboutDialog
title: i18n.tr("About (KeePit v2)")
title: i18n.tr("About (KeePit v2.0)")
text: i18n.tr("Copyright &copy; 2016 Dan Beavon<br/>This software is distributed under the terms of the GNU General Public License v2 or Later")
Button {
text: i18n.tr("Ok")
Expand Down
33 changes: 26 additions & 7 deletions KeePit/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "readkeyfile.h"
#include "filehandler.h"
#include "bytestream.h"
#include "../ziplib/GZipHelper.h"

using namespace std;

Expand Down Expand Up @@ -465,6 +466,7 @@ void Database::openFile(QString url, QString password, QString passKey) {

vector<char> payload;
uint recoveredOffset = 32;

for(uint i=recoveredOffset;i<recovered.size(); i++) {
payload.push_back(recovered[i]);
}
Expand All @@ -473,8 +475,26 @@ void Database::openFile(QString url, QString password, QString passKey) {
vector<char> read;
assert(read.size() == 0);

try {
try {
// Now lets read the payload
readPayload(&read, payload);

char *inter = new char[read.size()];
for(uint i = 0;i<read.size();i++) {
inter[i] = read[i];
}

// Are we gzipped, if so lets unzip:
if(uCompression == 1) { // We are compressed
// payload == the compressed buffer
CGZIP2A a((LPGZIP)inter, read.size());
read.clear();

for(uint i=0;i<a.Length; i++) {
read.push_back(a.psz[i]); // push uncompressed data back into read vector
}
}

} catch(exception &ex) {
emit error("Could not read payload (incorrect composite key?)");
return;
Expand Down Expand Up @@ -545,7 +565,6 @@ void Database::readHeaderField(ByteStream* byteStream, bool* endOfHeaderReached,
}
}

uint uCompression;
KdbxHeaderFieldID kdbID = (KdbxHeaderFieldID)btFieldID;
switch(kdbID)
{
Expand All @@ -568,11 +587,11 @@ void Database::readHeaderField(ByteStream* byteStream, bool* endOfHeaderReached,
m_pbCompression = new char[uSize];
copy(pbData, pbData + uSize, m_pbCompression);
uCompression = ByteStream::ReadByte(m_pbCompression);
if(uCompression != 0) {
*readError = true;
emit error("Compressed Databases are not currently supported");
return;
}
//if(uCompression != 0) {
// *readError = true;
// emit error("Compressed Databases are not currently supported");
// return;
//}
break;

case MasterSeed:
Expand Down
1 change: 1 addition & 0 deletions KeePit/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class Database : public QObject
bool foundAny = false;
vector<TreeNode*> dataTree;
vector<TreeNode*> current;
uint uCompression;
};

#endif // DATABASE_H
Expand Down
2 changes: 1 addition & 1 deletion KeePit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/// \return
///
int main(int argc, char *argv[])
{
{
QGuiApplication app(argc, argv);

Database fs;
Expand Down
8 changes: 8 additions & 0 deletions KeePit/stdafx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// gzipdemo.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
12 changes: 12 additions & 0 deletions KeePit/stdafx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <stdio.h>
//#include <tchar.h>

// TODO: reference additional headers your program requires here
Loading

0 comments on commit 16ded32

Please sign in to comment.