diff --git a/ObjectiveCExample/Podfile.lock b/ObjectiveCExample/Podfile.lock index f5dee85..3e336a6 100644 --- a/ObjectiveCExample/Podfile.lock +++ b/ObjectiveCExample/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - SSZipArchive (2.0.1) + - SSZipArchive (2.0.2) DEPENDENCIES: - SSZipArchive (from `..`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: ".." SPEC CHECKSUMS: - SSZipArchive: 6678776f378494909195d3f1b3f00d91e76084f9 + SSZipArchive: 5fdf578dbbb60000b23439f80fa04e81d00740ee PODFILE CHECKSUM: 7f4058a9cbc69b4e63808729577a8bb2098bc527 diff --git a/SSZipArchive.podspec b/SSZipArchive.podspec index 269e027..20480c6 100644 --- a/SSZipArchive.podspec +++ b/SSZipArchive.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SSZipArchive' - s.version = '2.0.1' + s.version = '2.0.2' s.summary = 'Utility class for zipping and unzipping files on iOS, tvOS, watchOS, and Mac.' s.description = 'SSZipArchive is a simple utility class for zipping and unzipping files on iOS, tvOS, watchOS, and Mac.' s.homepage = 'https://github.com/ZipArchive/ZipArchive' diff --git a/SSZipArchive/minizip/crypt.c b/SSZipArchive/minizip/crypt.c index df687d3..602e53f 100644 --- a/SSZipArchive/minizip/crypt.c +++ b/SSZipArchive/minizip/crypt.c @@ -129,8 +129,8 @@ int cryptrand(unsigned char *buf, unsigned int len) return rlen; } -int crypthead(const char *passwd, uint8_t *buf, int buf_size, - uint32_t *pkeys, const z_crc_t *pcrc_32_tab, uint32_t crc_for_crypting) +int crypthead(const char *passwd, uint8_t *buf, int buf_size, uint32_t *pkeys, + const z_crc_t *pcrc_32_tab, uint8_t verify1, uint8_t verify2) { uint8_t n = 0; /* index in random header */ uint8_t header[RAND_HEAD_LEN-2]; /* random header */ @@ -150,8 +150,8 @@ int crypthead(const char *passwd, uint8_t *buf, int buf_size, for (n = 0; n < RAND_HEAD_LEN-2; n++) buf[n] = (uint8_t)zencode(pkeys, pcrc_32_tab, header[n], t); - buf[n++] = (uint8_t)zencode(pkeys, pcrc_32_tab, (uint8_t)((crc_for_crypting >> 16) & 0xff), t); - buf[n++] = (uint8_t)zencode(pkeys, pcrc_32_tab, (uint8_t)((crc_for_crypting >> 24) & 0xff), t); + buf[n++] = (uint8_t)zencode(pkeys, pcrc_32_tab, verify1, t); + buf[n++] = (uint8_t)zencode(pkeys, pcrc_32_tab, verify2, t); return n; } diff --git a/SSZipArchive/minizip/crypt.h b/SSZipArchive/minizip/crypt.h index 4cee0ea..72e9536 100644 --- a/SSZipArchive/minizip/crypt.h +++ b/SSZipArchive/minizip/crypt.h @@ -46,7 +46,7 @@ int cryptrand(unsigned char *buf, unsigned int len); /* Create encryption header */ int crypthead(const char *passwd, uint8_t *buf, int buf_size, uint32_t *pkeys, - const z_crc_t *pcrc_32_tab, uint32_t crc_for_crypting); + const z_crc_t *pcrc_32_tab, uint8_t verify1, uint8_t verify2); /***************************************************************************/ diff --git a/SSZipArchive/minizip/minishared.c b/SSZipArchive/minizip/minishared.c index b43b12c..80f34a3 100644 --- a/SSZipArchive/minizip/minishared.c +++ b/SSZipArchive/minizip/minishared.c @@ -238,42 +238,6 @@ int is_large_file(const char *path) return (pos >= UINT32_MAX); } -int get_file_crc(const char *path, void *buf, uint32_t size_buf, uint32_t *result_crc) -{ - FILE *handle = NULL; - uint32_t calculate_crc = 0; - uint32_t size_read = 0; - int err = 0; - - handle = fopen64(path, "rb"); - if (handle == NULL) - { - err = -1; - } - else - { - do - { - size_read = (int)fread(buf, 1, size_buf, handle); - - if ((size_read < size_buf) && (feof(handle) == 0)) - { - printf("error in reading %s\n", path); - err = -1; - } - - if (size_read > 0) - calculate_crc = (uint32_t)crc32(calculate_crc, buf, size_read); - } - while ((err == Z_OK) && (size_read > 0)); - fclose(handle); - } - - printf("file %s crc %x\n", path, calculate_crc); - *result_crc = calculate_crc; - return err; -} - void display_zpos64(uint64_t n, int size_char) { /* To avoid compatibility problem we do here the conversion */ diff --git a/SSZipArchive/minizip/minishared.h b/SSZipArchive/minizip/minishared.h index c04fcc4..7656d23 100644 --- a/SSZipArchive/minizip/minishared.h +++ b/SSZipArchive/minizip/minishared.h @@ -36,9 +36,6 @@ int check_file_exists(const char *path); /* Check to see if a file is over 4GB and needs ZIP64 extension */ int is_large_file(const char *path); -/* Calculate the CRC32 of a file, because to encrypt a file, we need known the CRC32 of the file before */ -int get_file_crc(const char *path, void *buf, uint32_t size_buf, uint32_t *result_crc); - /* Print a 64-bit number for compatibility */ void display_zpos64(uint64_t n, int size_char); diff --git a/SSZipArchive/minizip/unzip.c b/SSZipArchive/minizip/unzip.c index 6a415c3..47b8962 100644 --- a/SSZipArchive/minizip/unzip.c +++ b/SSZipArchive/minizip/unzip.c @@ -33,8 +33,8 @@ # define AES_HEADERSIZE (11) # define AES_KEYSIZE(mode) (64 + (mode * 64)) -# include "aes.h" -# include "fileenc.h" +# include "aes/aes.h" +# include "aes/fileenc.h" #endif #ifdef HAVE_APPLE_COMPRESSION # include diff --git a/SSZipArchive/minizip/zip.c b/SSZipArchive/minizip/zip.c index 3f9e08f..dbb2265 100755 --- a/SSZipArchive/minizip/zip.c +++ b/SSZipArchive/minizip/zip.c @@ -1229,11 +1229,22 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, c { unsigned char buf_head[RAND_HEAD_LEN]; uint32_t size_head = 0; + uint8_t verify1 = 0; + uint8_t verify2 = 0; zi->ci.pcrc_32_tab = get_crc_table(); - /*init_keys(password, zi->ci.keys, zi->ci.pcrc_32_tab);*/ - size_head = crypthead(password, buf_head, RAND_HEAD_LEN, zi->ci.keys, zi->ci.pcrc_32_tab, (unsigned int)crc_for_crypting); + /* + Info-ZIP modification to ZipCrypto format: + If bit 3 of the general purpose bit flag is set, it uses high byte of 16-bit File Time. + + verify1 = (uint8_t)((crc_for_crypting >> 16) & 0xff); + verify2 = (uint8_t)((crc_for_crypting >> 24) & 0xff); */ + + verify1 = (uint8_t)((zi->ci.dos_date >> 16) & 0xff); + verify2 = (uint8_t)((zi->ci.dos_date >> 8) & 0xff); + + size_head = crypthead(password, buf_head, RAND_HEAD_LEN, zi->ci.keys, zi->ci.pcrc_32_tab, verify1, verify2); zi->ci.total_compressed += size_head; if (ZWRITE64(zi->z_filefunc, zi->filestream, buf_head, size_head) != size_head) diff --git a/SwiftExample/Podfile.lock b/SwiftExample/Podfile.lock index 0388f38..cd49d1a 100644 --- a/SwiftExample/Podfile.lock +++ b/SwiftExample/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - SSZipArchive (2.0.1) + - SSZipArchive (2.0.2) DEPENDENCIES: - SSZipArchive (from `..`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: ".." SPEC CHECKSUMS: - SSZipArchive: 6678776f378494909195d3f1b3f00d91e76084f9 + SSZipArchive: 5fdf578dbbb60000b23439f80fa04e81d00740ee PODFILE CHECKSUM: 0dc500eb72745751ccba7677de4da5534fcef36d