diff --git a/LICENSE.md b/LICENSE.md
index 6e9d215..60b90fa 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -34,4 +34,8 @@ Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
See src/openssl/LICENCE
+### miniz (deflate.cpp)
+
+Public domain
+Rich Geldreich (richgel99@gmail.com)
diff --git a/README.md b/README.md
index 7fca233..a0e295f 100644
--- a/README.md
+++ b/README.md
@@ -3,15 +3,15 @@ by _Jonas Minnberg_ (jonasmi@unity3d.com)
* Parallell zip compression using *Info-ZIP* deflate or *Intel* fast deflate
* On-the-fly Jar signing
-* Created with the goal of fast APK creation.
+* Created with the goal of fast APK creation
-* Check LICENCE.md for license
+* Check _LICENCE.md_ for license information
## Build (Unix/OSX)
* Make sure you have *yasm* and *openssl* installed.
* `make`
-* `WITH_INTEL=0 make` - Build without Intel code
+* `WITH_INTEL=0 make` - Build without Intel code.
* `./test.py` - Simple functional test
## Build (Windows)
@@ -25,6 +25,7 @@ by _Jonas Minnberg_ (jonasmi@unity3d.com)
fastzip
fastzip ...
+ fastzip --help
## Speed Tests
diff --git a/src/asn.cpp b/src/asn.cpp
index 1f9ac4c..8dcf060 100644
--- a/src/asn.cpp
+++ b/src/asn.cpp
@@ -69,7 +69,7 @@ namespace asn1
}
else if (der.tag == 0x02)
{
- printf("%llx\n", der.value);
+ printf("%llx\n", (unsigned long long)der.value);
}
else if (der.tag == 03 || der.tag == 4 || der.tag == 6)
{
diff --git a/src/asn.h b/src/asn.h
index ba594d1..7d6b25b 100644
--- a/src/asn.h
+++ b/src/asn.h
@@ -11,7 +11,7 @@
namespace asn1
{
-// Routines for ASN.1 reading and creation
+ // Routines for ASN.1 reading and creation
class MemBuffer
{
diff --git a/src/crypto.cpp b/src/crypto.cpp
index 4680e7b..acdb3ce 100644
--- a/src/crypto.cpp
+++ b/src/crypto.cpp
@@ -138,16 +138,13 @@ vector recoverKey(const string &password, const vector &protec
plainKey[i] = (uint8_t)(encrKey[i] ^ xorKey[i]);
}
- /*
- * Check the integrity of the recovered key by concatenating it with
- * the password, digesting the concatenation, and comparing the
- * result of the digest operation with the digest provided at the end
- * of protectedKey
. If the two digest values are
- * different, throw an exception.
- */
+
+ // Check the integrity of the recovered key by concatenating it with
+ // the password, digesting the concatenation, and comparing the
+ // result of the digest operation with the digest provided at the end
+ // of 'protectedKey'. If the two digest values are
+ // different, throw an exception.
SHA1_Update(&context, &passwdBytes[0], passwdBytes.size());
- // Arrays.fill(passwdBytes, (uint8_t)0x00);
- // passwdBytes = null;
SHA1_Update(&context, &plainKey[0], plainKey.size());
SHA1_Final(&digest[0], &context);
@@ -216,21 +213,17 @@ vector KeyStore::getKey(const string &pass, const string &name)
auto alias = membuf.readString();
auto timestamp = membuf.read();
- // printf("%d Alias %s\n", i, alias.c_str());
-
assert(tag == 1);
auto length = membuf.read();
DER keyData = readDER(membuf.readBuffer(length).buffer());
if (!foundKey && (name == "" || alias == name))
{
- // printf("%02x\n", keyData.tag);
for (int i = 0; i < keyData.size(); i++)
{
if (keyData[i].tag == 0x04)
{
privateKey = keyData[i].data;
- // printf("Found private key %lx bytes\n", privateKey.size());
foundKey = true;
break;
}
@@ -239,8 +232,8 @@ vector KeyStore::getKey(const string &pass, const string &name)
auto ccount = membuf.read();
auto certName = membuf.readString();
- // printf("%d %s\n", ccount, certName.c_str());
- for (unsigned j = 0; j < ccount; j++)
+
+ for (unsigned j = 0; j < ccount; j++)
{
auto clen = membuf.read();
auto certBuf = membuf.readBuffer(clen);
@@ -248,18 +241,11 @@ vector KeyStore::getKey(const string &pass, const string &name)
{
certificate = certBuf.buffer();
DER certData = readDER(certificate);
- // dumpDER(certificate);
for (int i = 0; i < certData[0].size(); i++)
{
- // printf("%02x\n", certDatag173.tag);
if (certData[0][i].tag == 0x30 && certData[0][i][0].tag == 0x31)
- {
- // printf("FOUND\n");
- // certMetaData = MemBuffer(certData[0][i].data);
- // dumpDER(certMetaData);
break;
- }
}
}
}
@@ -273,8 +259,8 @@ vector KeyStore::getKey(const string &pass, const string &name)
auto plainKey = recoverKey(pass, privateKey);
DER keyData = readDER(plainKey);
- // dumpDER(MemBuffer(plainKey));
- for (int j = 0; j < keyData.size(); j++)
+
+ for (int j = 0; j < keyData.size(); j++)
{
if (keyData[j].tag == 0x04)
{
diff --git a/src/crypto.h b/src/crypto.h
index 8f092b5..ea7fb37 100644
--- a/src/crypto.h
+++ b/src/crypto.h
@@ -42,9 +42,6 @@ class KeyStore
asn1::MemBuffer membuf;
std::vector certificate;
- // std::vector privateKey;
- // std::unordered_map> keys;
- // MemBuffer certMetaData;
};
#endif // CRYPTO_H
diff --git a/src/fastzip.cpp b/src/fastzip.cpp
index 40ad304..9f56f82 100644
--- a/src/fastzip.cpp
+++ b/src/fastzip.cpp
@@ -55,7 +55,6 @@ static int store_compressed(FILE *fp, int inSize, uint8_t *target, uint8_t *sha)
uint8_t *fileData = target;
fread(fileData, 1, inSize, fp);
- // printf("%02x %02x\n", fileData[0], fileData[1]);
int total = 0;
if (sha)
{
@@ -65,8 +64,8 @@ static int store_compressed(FILE *fp, int inSize, uint8_t *target, uint8_t *sha)
mz_stream stream;
memset(&stream, 0, sizeof(stream));
int rc = mz_inflateInit2(&stream, -MZ_DEFAULT_WINDOW_BITS);
- // printf("RC %d\n", rc);
- stream.next_in = fileData;
+
+ stream.next_in = fileData;
stream.avail_in = inSize;
stream.next_out = buf;
@@ -86,8 +85,8 @@ static int store_compressed(FILE *fp, int inSize, uint8_t *target, uint8_t *sha)
}
total += (bufSize - stream.avail_out);
}
- // printf("Total %d bytes unpacked\n", total);
- mz_inflate(&stream, MZ_FINISH);
+
+ mz_inflate(&stream, MZ_FINISH);
SHA1_Final(sha, &context);
}
@@ -125,7 +124,7 @@ static PackResult store_uncompressed(FILE *fp, int inSize, uint8_t *out, size_t
#ifdef WITH_INTEL
-static PackResult intel_deflate(FILE *fp, int inSize, uint8_t *buffer, size_t *outSize,
+static PackResult intel_deflate(FILE *fp, size_t inSize, uint8_t *buffer, size_t *outSize,
uint32_t *checksum, uint8_t *sha, int earlyOut)
{
LZ_Stream2 stream __attribute__((aligned(16)));
@@ -135,11 +134,8 @@ static PackResult intel_deflate(FILE *fp, int inSize, uint8_t *buffer, size_t *o
if (fread(fileData, 1, inSize, fp) != inSize)
return RC_FAILED;
- // uint8_t *fileData = new uint8_t [inSize];
uint8_t *inBuf = fileData;
- // fread(fileData, 1, inSize, fp);
-
if (sha)
{
SHA_CTX context;
@@ -212,7 +208,6 @@ static PackResult intel_deflate(FILE *fp, int inSize, uint8_t *buffer, size_t *o
int percent = (int)(*outSize * 100 / inSize);
if (earlyOut && (buffer + *outSize < fileData))
{
- // printf("Ratio at end: %d%%\n", percent);
if (percent >= earlyOut)
{
*outSize = inSize;
@@ -225,7 +220,6 @@ static PackResult intel_deflate(FILE *fp, int inSize, uint8_t *buffer, size_t *o
}
}
- // delete [] fileData;
return RC_COMPRESSED;
}
@@ -325,8 +319,6 @@ void Fastzip::packZipData(FILE *fp, int size, PackFormat inFormat, PackFormat ou
outSize = size;
}
- // printf("%s %s", target.name.c_str(), base64_encode(target.sha, SHA_LEN).c_str());
-
target.data = outBuf;
target.dataSize = outSize;
}
@@ -432,7 +424,6 @@ void Fastzip::exec()
throw fastzip_exception("No paths specified");
if (fileNames.size() >= 65535)
{
- // throw fastzip_exception("Can not put more than 64K files in one archive");
warning("More than 64K files, adding 64bit features.");
}
if (zipfile == "")
@@ -582,12 +573,7 @@ void Fastzip::exec()
if (doSeq)
{
while (fileName.index != currentIndex)
- {
- // printf("%s:%d != %d\n", fileName.target.c_str(),
- // fileName.index,
- // currentIndex);
seq_cv.wait(lock);
- }
}
if (doSign)
{
@@ -603,7 +589,7 @@ void Fastzip::exec()
}
if (doSeq)
seq_cv.notify_all();
- delete entry.data;
+ delete [] entry.data;
}
else
{
@@ -627,8 +613,6 @@ void Fastzip::exec()
for (int i = 0; i < threadCount; i++)
workerThreads[i].join();
- // intf("%ld %ld\n", (long)0xff000000, sizeof(long));
-
if (ftell_x(zipArchive.getFile()) > (int64_t)0xff000000)
throw fastzip_exception("Resulting file too large");
@@ -753,7 +737,6 @@ void Fastzip::sign(ZipArchive &zipArchive, const string &digestFile)
RSA_sign(NID_sha1, digest, SHA_LEN, &sign[0], &signLen, rsa);
- // printf("signLen %d\n", signLen);
sign.resize(signLen);
auto data =
diff --git a/src/utils.h b/src/utils.h
index 9a1a817..a0cfa94 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -6,7 +6,6 @@
#include
#include
#include
-//#include
#include
#include
#include
@@ -28,9 +27,6 @@
#define fseek_x fseek
#endif
-// template class CONTAINER>
-// std::vector> split(const CONTAINER &s, const std::string &delim, unsigned limit);
-
template
std::vector > split(const std::basic_string &s,
const std::string &delim = " ", unsigned limit = 0)
@@ -176,9 +172,6 @@ template class UniQueue : public std::deque void emplace_front(S&&... s) {}
-
private:
void cleanup()
{
diff --git a/test.py b/test.py
index 74da96d..eabf9ab 100755
--- a/test.py
+++ b/test.py
@@ -4,9 +4,9 @@
import os;
try :
- print subprocess.check_output('./fastzip -8 infozip.zip infozip'.split())
+ print subprocess.check_output('./fastzip -8 infozip.zip src/infozip'.split())
print subprocess.check_output('./fastzip -0 obj.zip obj'.split())
- print subprocess.check_output('./fastzip -v --sign -Z infozip.zip igzip.zip igzip -0 -Z obj.zip fastzip=fs.stored -9 fastzip=packed/fastzip'.split())
+ print subprocess.check_output('./fastzip -j -v --sign -Z infozip.zip igzip.zip src/igzip -0 -Z obj.zip fastzip=fs.stored -9 fastzip=packed/fastzip'.split())
print subprocess.check_output('unzip -lv igzip.zip'.split())
output = subprocess.check_output('unzip -t igzip.zip'.split())
if output.find('No errors detected') >= 0 :