From c563a2434898906e459264b2e4941d20b3ebc133 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Tue, 25 Dec 2018 12:46:59 +0530 Subject: [PATCH] minizip: Remove zip encryption code We can now remove -DNOCRYPT cflag while compiling Signed-off-by: Roopesh Chander --- WireGuard/WireGuard.xcodeproj/project.pbxproj | 2 - .../ZipArchive/3rdparty/minizip/unzip.c | 54 ------------------- .../ZipArchive/3rdparty/minizip/zip.c | 49 ----------------- 3 files changed, 105 deletions(-) diff --git a/WireGuard/WireGuard.xcodeproj/project.pbxproj b/WireGuard/WireGuard.xcodeproj/project.pbxproj index 92a2abf..5b7efcf 100644 --- a/WireGuard/WireGuard.xcodeproj/project.pbxproj +++ b/WireGuard/WireGuard.xcodeproj/project.pbxproj @@ -977,7 +977,6 @@ "$(inherited)", "@executable_path/Frameworks", ); - "OTHER_CFLAGS[arch=*]" = "-DNOCRYPT"; PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "WireGuard/WireGuard-Bridging-Header.h"; @@ -997,7 +996,6 @@ "$(inherited)", "@executable_path/Frameworks", ); - "OTHER_CFLAGS[arch=*]" = "-DNOCRYPT"; PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "WireGuard/WireGuard-Bridging-Header.h"; diff --git a/WireGuard/WireGuard/ZipArchive/3rdparty/minizip/unzip.c b/WireGuard/WireGuard/ZipArchive/3rdparty/minizip/unzip.c index 1b3fa2d..bdd18d8 100644 --- a/WireGuard/WireGuard/ZipArchive/3rdparty/minizip/unzip.c +++ b/WireGuard/WireGuard/ZipArchive/3rdparty/minizip/unzip.c @@ -68,10 +68,6 @@ #include #include -#ifndef NOUNCRYPT - #define NOUNCRYPT -#endif - #include "zlib.h" #include "unzip.h" @@ -185,18 +181,8 @@ typedef struct int encrypted; int isZip64; - -# ifndef NOUNCRYPT - unsigned long keys[3]; /* keys defining the pseudo-random sequence */ - const z_crc_t* pcrc_32_tab; -# endif } unz64_s; - -#ifndef NOUNCRYPT -#include "crypt.h" -#endif - /* =========================================================================== Read a byte from a gz_stream; update next_in and avail_in. Return EOF for end of file. @@ -1478,12 +1464,8 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, file_in_zip64_read_info_s* pfile_in_zip_read_info; ZPOS64_T offset_local_extrafield; /* offset of the local extra field */ uInt size_local_extrafield; /* size of the local extra field */ -# ifndef NOUNCRYPT - char source[12]; -# else if (password != NULL) return UNZ_PARAMERROR; -# endif if (file==NULL) return UNZ_PARAMERROR; @@ -1612,29 +1594,6 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, s->pfile_in_zip_read = pfile_in_zip_read_info; s->encrypted = 0; -# ifndef NOUNCRYPT - if (password != NULL) - { - int i; - s->pcrc_32_tab = get_crc_table(); - init_keys(password,s->keys,s->pcrc_32_tab); - if (ZSEEK64(s->z_filefunc, s->filestream, - s->pfile_in_zip_read->pos_in_zipfile + - s->pfile_in_zip_read->byte_before_the_zipfile, - SEEK_SET)!=0) - return UNZ_INTERNALERROR; - if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12) - return UNZ_INTERNALERROR; - - for (i = 0; i<12; i++) - zdecode(s->keys,s->pcrc_32_tab,source[i]); - - s->pfile_in_zip_read->pos_in_zipfile+=12; - s->encrypted=1; - } -# endif - - return UNZ_OK; } @@ -1739,19 +1698,6 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) uReadThis)!=uReadThis) return UNZ_ERRNO; - -# ifndef NOUNCRYPT - if(s->encrypted) - { - uInt i; - for(i=0;iread_buffer[i] = - zdecode(s->keys,s->pcrc_32_tab, - pfile_in_zip_read_info->read_buffer[i]); - } -# endif - - pfile_in_zip_read_info->pos_in_zipfile += uReadThis; pfile_in_zip_read_info->rest_read_compressed-=uReadThis; diff --git a/WireGuard/WireGuard/ZipArchive/3rdparty/minizip/zip.c b/WireGuard/WireGuard/ZipArchive/3rdparty/minizip/zip.c index 278af01..9002d66 100644 --- a/WireGuard/WireGuard/ZipArchive/3rdparty/minizip/zip.c +++ b/WireGuard/WireGuard/ZipArchive/3rdparty/minizip/zip.c @@ -153,11 +153,6 @@ typedef struct ZPOS64_T pos_zip64extrainfo; ZPOS64_T totalCompressedData; ZPOS64_T totalUncompressedData; -#ifndef NOCRYPT - unsigned long keys[3]; /* keys defining the pseudo-random sequence */ - const z_crc_t* pcrc_32_tab; - int crypt_header_size; -#endif } curfile64_info; typedef struct @@ -178,12 +173,6 @@ typedef struct } zip64_internal; - -#ifndef NOCRYPT -#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED -#include "crypt.h" -#endif - local linkedlist_datablock_internal* allocate_new_datablock() { linkedlist_datablock_internal* ldi; @@ -1064,12 +1053,6 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, uInt i; int err = ZIP_OK; -# ifdef NOCRYPT - (void)(crcForCrypting); - if (password != NULL) - return ZIP_PARAMERROR; -# endif - if (file == NULL) return ZIP_PARAMERROR; @@ -1237,24 +1220,6 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, } -# ifndef NOCRYPT - zi->ci.crypt_header_size = 0; - if ((err==Z_OK) && (password != NULL)) - { - unsigned char bufHead[RAND_HEAD_LEN]; - unsigned int sizeHead; - zi->ci.encrypt = 1; - zi->ci.pcrc_32_tab = get_crc_table(); - /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ - - sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); - zi->ci.crypt_header_size = sizeHead; - - if (ZWRITE64(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) - err = ZIP_ERRNO; - } -# endif - if (err==Z_OK) zi->in_opened_file_inzip = 1; return err; @@ -1362,16 +1327,6 @@ local int zip64FlushWriteBuffer(zip64_internal* zi) { int err=ZIP_OK; - if (zi->ci.encrypt != 0) - { -#ifndef NOCRYPT - uInt i; - int t; - for (i=0;ici.pos_in_buffered_data;i++) - zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, zi->ci.buffered_data[i],t); -#endif - } - if (ZWRITE64(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) != zi->ci.pos_in_buffered_data) err = ZIP_ERRNO; @@ -1602,10 +1557,6 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s } compressed_size = zi->ci.totalCompressedData; -# ifndef NOCRYPT - compressed_size += zi->ci.crypt_header_size; -# endif - // update Current Item crc and sizes, if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff) {