8000
$ curl -LO https://github.com/nmoinvaz/minizip/arch 8000 ive/2.7.0.tar.gz $ tar -xvf 2.7.0.tar.gz $ cd minizip-2.7.0 $ cmake . $ make $ clang test-crypt.c -I. -L. -lminizip -lbz2 -lz
test-crypt.c:
test-crypt.c
#include <string.h> #include <stdio.h> #include <stdlib.h> #include "mz.h" #include "mz_zip.h" #include "mz_compat.h" int main(void) { zip_fileinfo zfi; const unsigned char content[] = "abcdefghijklmnopqrstuvvvwwwxxx"; zipFile hZip; // create .zip printf("zcreat: %p\n", (void *)(hZip = zipOpen2_64("test.zip", APPEND_STATUS_CREATE, NULL, NULL))); memset(&zfi, 0, sizeof(zfi)); printf("zaddfi: %d\n", zipOpenNewFileInZip4_64(hZip, "test.txt", &zfi, NULL, 0, NULL, 0, NULL, MZ_COMPRESS_METHOD_LZMA, 6, 0, -MAX_WBITS, DEF_MEM_LEVEL, 0, "password", 0x4c72ad0a /* crc of 'content' */, 0, 0, 0)); printf("zwrite: %d\n", zipWriteInFileInZip(hZip, content, sizeof(content))); printf("zfclos: %d\n", zipCloseFileInZip(hZip)); printf("zclose: %d\n", zipClose(hZip, NULL)); return 0; }
actual output:
zcreat: 0x7fbdf2c02cc0 zaddfi: -102 zwrite: -1 zfclos: -102 zclose: 0
expected (and actual result with 2.6.0):
zcreat: 0x7fd15ac02cc0 zaddfi: 0 zwrite: 0 zfclos: 0 zclose: 0
(Tested on macOS 10.14)
Used crypto module is mz_crypt_brg.c.
mz_crypt_brg.c
I am very surprised by this. I worked on Travis CI to test all the possible cases.
I would at some point like to make a native version for macOS of the mz_crypt file.
Fixed hmac implementation in brg library. #334
I think I got it. Thanks.
Thanks! Though in latest dev, the above sample no longer compiles, with these errors:
dev
test-crypt.c:22:53: error: use of undeclared identifier 'MAX_WBITS' -MAX_WBITS, DEF_MEM_LEVEL, 0, ^ test-crypt.c:22:64: error: use of undeclared identifier 'DEF_MEM_LEVEL' -MAX_WBITS, DEF_MEM_LEVEL, 0, ^ 2 errors generated.
Ref this comment: f79ec42#commitcomment-31132281
Activity
[-]Encryption fails with 2.7.0[/-][+]LZMA encryption fails with 2.7.0[/+]vszakats commentedon Nov 1, 2018
Used crypto module is
mz_crypt_brg.c.nmoinvaz commentedon Nov 1, 2018
I am very surprised by this. I worked on Travis CI to test all the possible cases.
nmoinvaz commentedon Nov 1, 2018
I would at some point like to make a native version for macOS of the mz_crypt file.
Fixed hmac implementation in brg library. #334
nmoinvaz commentedon Nov 1, 2018
I think I got it. Thanks.
vszakats commentedon Nov 1, 2018
Thanks! Though in latest
dev, the above sample no longer compiles, with these errors:vszakats commentedon Nov 1, 2018
Ref this comment: f79ec42#commitcomment-31132281