From: <lab...@us...> - 2018-12-12 23:32:47
|
Revision: 1568 http://sourceforge.net/p/opengtoolkit/svn/1568 Author: labviewer Date: 2018-12-12 23:32:45 +0000 (Wed, 12 Dec 2018) Log Message: ----------- Remove unneeded files and code from the project and make the code more multiplatform compatible Modified Paths: -------------- trunk/lvzip/c_source/Makefile trunk/lvzip/c_source/aes/brg_types.h trunk/lvzip/c_source/aes/entropy.c trunk/lvzip/c_source/aes/entropy.h trunk/lvzip/c_source/bzip2/bzlib.h trunk/lvzip/c_source/crypt.c trunk/lvzip/c_source/ioapi.c trunk/lvzip/c_source/lvapi.c trunk/lvzip/c_source/lvutil.c trunk/lvzip/c_source/unzip.c trunk/lvzip/c_source/unzip.h trunk/lvzip/c_source/zip.c trunk/lvzip/c_source/zip.h trunk/lvzip/c_source/zlibvc.dsp trunk/lvzip/c_source/zlibvc.vcproj Modified: trunk/lvzip/c_source/Makefile =================================================================== --- trunk/lvzip/c_source/Makefile 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/Makefile 2018-12-12 23:32:45 UTC (rev 1568) @@ -18,7 +18,7 @@ CC=gcc -CFLAGS=-O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN +CFLAGS=-O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DHAVE_AES -DHAVE_BZIP2 #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 #CFLAGS=-g -DDEBUG #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ @@ -25,7 +25,7 @@ # -Wstrict-prototypes -Wmissing-prototypes CINDIR=/usr/local/lv70/cintools -SFLAGS=-O3 -fPIC $(CC_ARCH_SPEC) -fvisibility=hidden -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -L$(CINDIR) +SFLAGS=-O3 -fPIC $(CC_ARCH_SPEC) -fvisibility=hidden -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DHAVE_AES -DHAVE_BZIP2 -DBZ_NO_STDIO -Ibzip2 -L$(CINDIR) LDFLAGS=-Wl,-soname=$(SHAREDLIBM) TEST_LDFLAGS=-L. libz.a LDSHARED=gcc @@ -55,19 +55,19 @@ man3dir = ${mandir}/man3 pkgconfigdir = ${libdir}/pkgconfig -OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o +OBJZ = adler32.o crc32.o crypt.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o OBJL = lvutil.o ioapi.o iomem.o mztools.o unzip.o zip.o utf.o -OBJE = aes/aescrypt.o aes/aeskey.o aes/aestab.o aes/entropy.o aes/fileenc.o aes/hmac.o aes/prng.o aes/pwd2key.o aes/sha1.o -OBJ2 = bzip2/blocksort.o bzip2/huffman.o bzip2/crctable.o bzip2/randtable.o bzip2/compress.o bzip2/decompress.o bzip2/bzlib.o +OBJE = aes/aescrypt.o aes/aeskey.o aes/aestab.o aes/fileenc.o aes/hmac.o aes/prng.o aes/pwd2key.o aes/sha1.o +OBJ2 = bzip2/blocksort.o bzip2/huffman.o bzip2/crctable.o bzip2/randtable.o bzip2/bzcompress.o bzip2/decompress.o bzip2/bzlib.o OBJC = $(OBJZ) $(OBJL) $(OBJG) $(OBJ2) $(OBJE) -PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo +PIC_OBJZ = adler32.lo crc32.lo crypt.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo PIC_OBJL = lvapi.lo lvutil.lo ioapi.lo iomem.lo mztools.lo unzip.lo zip.lo utf.lo -PIC_OBJE = aes/aescrypt.lo aes/aeskey.lo aes/aestab.lo aes/entropy.lo aes/fileenc.lo aes/hmac.lo aes/prng.lo aes/pwd2key.lo aes/sha1.lo -PIC_OBJ2 = bzip2/blocksort.lo bzip2/huffman.lo bzip2/crctable.lo bzip2/randtable.lo bzip2/compress.lo bzip2/decompress.lo bzip2/bzlib.lo +PIC_OBJE = aes/aescrypt.lo aes/aeskey.lo aes/aestab.lo aes/fileenc.lo aes/hmac.lo aes/prng.lo aes/pwd2key.lo aes/sha1.lo +PIC_OBJ2 = bzip2/blocksort.lo bzip2/huffman.lo bzip2/crctable.lo bzip2/randtable.lo bzip2/bzcompress.lo bzip2/decompress.lo bzip2/bzlib.lo PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJL) $(PIC_OBJG) $(PIC_OBJ2) $(PIC_OBJE) # to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo @@ -282,6 +282,7 @@ gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h crc32.o: zutil.h zlib.h zconf.h crc32.h +crypt.o: zutil.h zlib.h zconf.h crypt.h deflate.o: deflate.h zutil.h zlib.h zconf.h infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h @@ -292,6 +293,7 @@ gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h gzguts.h compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h crc32.lo: zutil.h zlib.h zconf.h crc32.h +crypt.lo: zutil.h zlib.h zconf.h crypt.h deflate.lo: deflate.h zutil.h zlib.h zconf.h infback.lo inflate.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h inffast.lo: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h Modified: trunk/lvzip/c_source/aes/brg_types.h =================================================================== --- trunk/lvzip/c_source/aes/brg_types.h 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/aes/brg_types.h 2018-12-12 23:32:45 UTC (rev 1568) @@ -57,6 +57,7 @@ # define intptr_t unsigned int # define ptrint_t intptr_t #elif defined( __GNUC__ ) && ( __GNUC__ >= 3 ) +# include <stdint.h> # define ptrint_t intptr_t #else # define ptrint_t int Modified: trunk/lvzip/c_source/aes/entropy.c =================================================================== --- trunk/lvzip/c_source/aes/entropy.c 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/aes/entropy.c 2018-12-12 23:32:45 UTC (rev 1568) @@ -1,5 +1,21 @@ #ifdef _WIN32 -#include <windows.h> +/* `RtlGenRandom` is used over `CryptGenRandom` on Microsoft Windows based systems: + * - `CryptGenRandom` requires pulling in `CryptoAPI` which causes unnecessary + * memory overhead if this API is not being used for other purposes + * - `RtlGenRandom` is thus called directly instead. A detailed explanation + * can be found here: https://blogs.msdn.microsoft.com/michael_howard/2005/01/14/cryptographically-secure-random-number-on-windows-without-using-cryptoapi/ + * + * In spite of the disclaimer on the `RtlGenRandom` documentation page that was + * written back in the Windows XP days, this function is here to stay. The CRT + * function `rand_s()` directly depends on it, so touching it would break many + * applications released since Windows XP. + * + * Also note that Rust, Firefox and BoringSSL (thus, Google Chrome and everything + * based on Chromium) also depend on it, and that libsodium allows the RNG to be + * replaced without patching nor recompiling the library. + */ +# include <windows.h> +# define RtlGenRandom SystemFunction036 #else #include <stdio.h> #include <fcntl.h> @@ -12,21 +28,14 @@ #endif #ifdef _WIN32 +BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength); int entropy_fun(unsigned char buf[], unsigned int len) { - HCRYPTPROV provider; + unsigned int i; unsigned __int64 pentium_tsc[1]; - unsigned int i; - int result = 0; + if (RtlGenRandom(buf, len)) + return len; - if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) - { - result = CryptGenRandom(provider, len, buf); - CryptReleaseContext(provider, 0); - if (result) - return len; - } - QueryPerformanceCounter((LARGE_INTEGER *)pentium_tsc); for(i = 0; i < 8 && i < len; ++i) Modified: trunk/lvzip/c_source/aes/entropy.h =================================================================== --- trunk/lvzip/c_source/aes/entropy.h 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/aes/entropy.h 2018-12-12 23:32:45 UTC (rev 1568) @@ -7,7 +7,7 @@ { #endif -int entropy_fun(unsigned char buf[], unsigned int len); +int entropy_fun(unsigned char buf[], unsigned int len); #if defined(__cplusplus) } Modified: trunk/lvzip/c_source/bzip2/bzlib.h =================================================================== --- trunk/lvzip/c_source/bzip2/bzlib.h 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/bzip2/bzlib.h 2018-12-12 23:32:45 UTC (rev 1568) @@ -1,282 +1,282 @@ - -/*-------------------------------------------------------------*/ -/*--- Public header file for the library. ---*/ -/*--- bzlib.h ---*/ -/*-------------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.6 of 6 September 2010 - Copyright (C) 1996-2010 Julian Seward <js...@bz...> - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - - -#ifndef _BZLIB_H -#define _BZLIB_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define BZ_RUN 0 -#define BZ_FLUSH 1 -#define BZ_FINISH 2 - -#define BZ_OK 0 -#define BZ_RUN_OK 1 -#define BZ_FLUSH_OK 2 -#define BZ_FINISH_OK 3 -#define BZ_STREAM_END 4 -#define BZ_SEQUENCE_ERROR (-1) -#define BZ_PARAM_ERROR (-2) -#define BZ_MEM_ERROR (-3) -#define BZ_DATA_ERROR (-4) -#define BZ_DATA_ERROR_MAGIC (-5) -#define BZ_IO_ERROR (-6) -#define BZ_UNEXPECTED_EOF (-7) -#define BZ_OUTBUFF_FULL (-8) -#define BZ_CONFIG_ERROR (-9) - -typedef - struct { - char *next_in; - unsigned int avail_in; - unsigned int total_in_lo32; - unsigned int total_in_hi32; - - char *next_out; - unsigned int avail_out; - unsigned int total_out_lo32; - unsigned int total_out_hi32; - - void *state; - - void *(*bzalloc)(void *,int,int); - void (*bzfree)(void *,void *); - void *opaque; - } - bz_stream; - - -#ifndef BZ_IMPORT -#define BZ_EXPORT -#endif - -#ifndef BZ_NO_STDIO -/* Need a definitition for FILE */ -#include <stdio.h> -#endif - -#ifdef _WIN32 -# include <windows.h> -# ifdef small - /* windows.h define small to char */ -# undef small -# endif -# ifdef BZ_EXPORT -# define BZ_API(func) WINAPI func -# define BZ_EXTERN extern -# else - /* import windows dll dynamically */ -# define BZ_API(func) (WINAPI * func) -# define BZ_EXTERN -# endif -#else -# define BZ_API(func) func -# define BZ_EXTERN extern -#endif - - -/*-- Core (low-level) library functions --*/ - -BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( - bz_stream* strm, - int blockSize100k, - int verbosity, - int workFactor - ); - -BZ_EXTERN int BZ_API(BZ2_bzCompress) ( - bz_stream* strm, - int action - ); - -BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( - bz_stream* strm - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( - bz_stream *strm, - int verbosity, - int small - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( - bz_stream* strm - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( - bz_stream *strm - ); - - - -/*-- High(er) level library functions --*/ -#ifndef BZ_NO_STDIO -#define BZ_MAX_UNUSED 5000 +/*-------------------------------------------------------------*/ +/*--- Public header file for the library. ---*/ +/*--- bzlib.h ---*/ +/*-------------------------------------------------------------*/ +/* ------------------------------------------------------------------ + This file is part of bzip2/libbzip2, a program and library for + lossless, block-sorting data compression. + + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward <js...@bz...> + + Please read the WARNING, DISCLAIMER and PATENTS sections in the + README file. + + This program is released under the terms of the license contained + in the file LICENSE. + ------------------------------------------------------------------ */ + + +#ifndef _BZLIB_H +#define _BZLIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define BZ_RUN 0 +#define BZ_FLUSH 1 +#define BZ_FINISH 2 + +#define BZ_OK 0 +#define BZ_RUN_OK 1 +#define BZ_FLUSH_OK 2 +#define BZ_FINISH_OK 3 +#define BZ_STREAM_END 4 +#define BZ_SEQUENCE_ERROR (-1) +#define BZ_PARAM_ERROR (-2) +#define BZ_MEM_ERROR (-3) +#define BZ_DATA_ERROR (-4) +#define BZ_DATA_ERROR_MAGIC (-5) +#define BZ_IO_ERROR (-6) +#define BZ_UNEXPECTED_EOF (-7) +#define BZ_OUTBUFF_FULL (-8) +#define BZ_CONFIG_ERROR (-9) + +typedef + struct { + char *next_in; + unsigned int avail_in; + unsigned int total_in_lo32; + unsigned int total_in_hi32; + + char *next_out; + unsigned int avail_out; + unsigned int total_out_lo32; + unsigned int total_out_hi32; + + void *state; + + void *(*bzalloc)(void *,int,int); + void (*bzfree)(void *,void *); + void *opaque; + } + bz_stream; + + +#ifndef BZ_IMPORT +#define BZ_EXPORT +#endif + +#ifndef BZ_NO_STDIO +/* Need a definitition for FILE */ +#include <stdio.h> +#endif + +#ifdef _WIN32 +# include <windows.h> +# ifdef small + /* windows.h define small to char */ +# undef small +# endif +# ifdef BZ_EXPORT +# define BZ_API(func) WINAPI func +# define BZ_EXTERN extern +# else + /* import windows dll dynamically */ +# define BZ_API(func) (WINAPI * func) +# define BZ_EXTERN +# endif +#else +# define BZ_API(func) func +# define BZ_EXTERN extern +#endif + + +/*-- Core (low-level) library functions --*/ + +BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( + bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN int BZ_API(BZ2_bzCompress) ( + bz_stream* strm, + int action + ); + +BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( + bz_stream* strm + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( + bz_stream *strm, + int verbosity, + int small + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( + bz_stream* strm + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( + bz_stream *strm + ); + + + +/*-- High(er) level library functions --*/ + +#ifndef BZ_NO_STDIO +#define BZ_MAX_UNUSED 5000 + typedef void BZFILE; - -BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( - int* bzerror, - FILE* f, - int verbosity, - int small, - void* unused, - int nUnused - ); - -BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( - int* bzerror, - BZFILE* b - ); - -BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( - int* bzerror, - BZFILE* b, - void** unused, - int* nUnused - ); - -BZ_EXTERN int BZ_API(BZ2_bzRead) ( - int* bzerror, - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( - int* bzerror, - FILE* f, - int blockSize100k, - int verbosity, - int workFactor - ); - -BZ_EXTERN void BZ_API(BZ2_bzWrite) ( - int* bzerror, - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in, - unsigned int* nbytes_out - ); - -BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in_lo32, - unsigned int* nbytes_in_hi32, - unsigned int* nbytes_out_lo32, - unsigned int* nbytes_out_hi32 - ); -#endif - - -/*-- Utility functions --*/ - -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( - char* dest, - unsigned int* destLen, - char* source, - unsigned int sourceLen, - int blockSize100k, - int verbosity, - int workFactor - ); - -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( - char* dest, - unsigned int* destLen, - char* source, - unsigned int sourceLen, - int small, - int verbosity - ); - - -/*-- - Code contributed by Yoshioka Tsuneo (ts...@rr...) - to support better zlib compatibility. - This code is not _officially_ part of libbzip2 (yet); - I haven't tested it, documented it, or considered the - threading-safeness of it. - If this code breaks, please contact both Yoshioka and me. ---*/ - -BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( - void - ); - -#ifndef BZ_NO_STDIO -BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( - const char *path, - const char *mode - ); - -BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( - int fd, - const char *mode - ); - -BZ_EXTERN int BZ_API(BZ2_bzread) ( - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN int BZ_API(BZ2_bzwrite) ( - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN int BZ_API(BZ2_bzflush) ( - BZFILE* b - ); - -BZ_EXTERN void BZ_API(BZ2_bzclose) ( - BZFILE* b - ); - -BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( - BZFILE *b, - int *errnum - ); -#endif - -#ifdef __cplusplus -} -#endif - -#endif - -/*-------------------------------------------------------------*/ -/*--- end bzlib.h ---*/ -/*-------------------------------------------------------------*/ + +BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( + int* bzerror, + FILE* f, + int verbosity, + int small, + void* unused, + int nUnused + ); + +BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( + int* bzerror, + BZFILE* b + ); + +BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( + int* bzerror, + BZFILE* b, + void** unused, + int* nUnused + ); + +BZ_EXTERN int BZ_API(BZ2_bzRead) ( + int* bzerror, + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( + int* bzerror, + FILE* f, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN void BZ_API(BZ2_bzWrite) ( + int* bzerror, + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in, + unsigned int* nbytes_out + ); + +BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in_lo32, + unsigned int* nbytes_in_hi32, + unsigned int* nbytes_out_lo32, + unsigned int* nbytes_out_hi32 + ); +#endif + + +/*-- Utility functions --*/ + +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( + char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int blockSize100k, + int verbosity, + int workFactor + ); + +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( + char* dest, + unsigned int* destLen, + char* source, + unsigned int sourceLen, + int small, + int verbosity + ); + + +/*-- + Code contributed by Yoshioka Tsuneo (ts...@rr...) + to support better zlib compatibility. + This code is not _officially_ part of libbzip2 (yet); + I haven't tested it, documented it, or considered the + threading-safeness of it. + If this code breaks, please contact both Yoshioka and me. +--*/ + +BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( + void + ); + +#ifndef BZ_NO_STDIO +BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( + const char *path, + const char *mode + ); + +BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( + int fd, + const char *mode + ); + +BZ_EXTERN int BZ_API(BZ2_bzread) ( + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN int BZ_API(BZ2_bzwrite) ( + BZFILE* b, + void* buf, + int len + ); + +BZ_EXTERN int BZ_API(BZ2_bzflush) ( + BZFILE* b + ); + +BZ_EXTERN void BZ_API(BZ2_bzclose) ( + BZFILE* b + ); + +BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( + BZFILE *b, + int *errnum + ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +/*-------------------------------------------------------------*/ +/*--- end bzlib.h ---*/ +/*-------------------------------------------------------------*/ Modified: trunk/lvzip/c_source/crypt.c =================================================================== --- trunk/lvzip/c_source/crypt.c 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/crypt.c 2018-12-12 23:32:45 UTC (rev 1568) @@ -30,7 +30,8 @@ #ifdef _WIN32 # include <windows.h> -# include <wincrypt.h> +# define RtlGenRandom SystemFunction036 +BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength); #else # include <sys/stat.h> # include <fcntl.h> @@ -87,32 +88,26 @@ int cryptrand(unsigned char *buf, unsigned int len) { #ifdef _WIN32 - HCRYPTPROV provider; - unsigned __int64 pentium_tsc[1]; - int rlen = 0; - int result = 0; +#if !EMBEDDED + BOOL result = RtlGenRandom(buf, len); + if (!result) +#endif + { + unsigned __int64 pentium_tsc[1]; + int rlen; - - if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) - { - result = CryptGenRandom(provider, len, buf); - CryptReleaseContext(provider, 0); - if (result) - return len; - } - - for (rlen = 0; rlen < (int)len; ++rlen) - { - if (rlen % 8 == 0) - QueryPerformanceCounter((LARGE_INTEGER *)pentium_tsc); - buf[rlen] = ((unsigned char*)pentium_tsc)[rlen % 8]; - } - - return rlen; + for (rlen = 0; rlen < (int)len; ++rlen) + { + if (rlen % 8 == 0) + QueryPerformanceCounter((LARGE_INTEGER *)pentium_tsc); + buf[rlen] = ((unsigned char*)pentium_tsc)[rlen % 8]; + } + return rlen; + } #else arc4random_buf(buf, len); +#endif return len; -#endif } int crypthead(const char *passwd, uint8_t *buf, int buf_size, uint32_t *pkeys, Modified: trunk/lvzip/c_source/ioapi.c =================================================================== --- trunk/lvzip/c_source/ioapi.c 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/ioapi.c 2018-12-12 23:32:45 UTC (rev 1568) @@ -63,6 +63,7 @@ return position; } +#ifndef WIN32 void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32) { p_filefunc64_32->zfile_func64.zopen64_file = NULL; @@ -352,3 +353,4 @@ pzlib_filefunc_def->zerror_file = ferror_file_func; pzlib_filefunc_def->opaque = NULL; } +#endif Modified: trunk/lvzip/c_source/lvapi.c =================================================================== --- trunk/lvzip/c_source/lvapi.c 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/lvapi.c 2018-12-12 23:32:45 UTC (rev 1568) @@ -183,13 +183,13 @@ LibAPI(int) lvzlib_compress(Bytef *dest, uInt32 *destLen, const Bytef *source, uInt32 sourceLen, int level) { - return compress2(dest, destLen, source, sourceLen, level); + return compress2(dest, (uLong*)destLen, source, (uLong)sourceLen, level); } LibAPI(int) lvzlib_uncompress(Bytef *dest, uInt32 *destLen, const Bytef *source, uInt32 sourceLen) { - return uncompress(dest, destLen, source, sourceLen); + return uncompress(dest, (uLong*)destLen, source, (uLong)sourceLen); } LibAPI(uInt32) lvzlib_crc32(uInt32 crc, const Bytef *buf, uInt32 len) Modified: trunk/lvzip/c_source/lvutil.c =================================================================== --- trunk/lvzip/c_source/lvutil.c 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/lvutil.c 2018-12-12 23:32:45 UTC (rev 1568) @@ -2810,7 +2810,7 @@ { zlib_filefunc64_def* pzlib_filefunc_def = (zlib_filefunc64_def*)LStrBuf(*filefunc_def); LStrLen(*filefunc_def) = sizeof(zlib_filefunc64_def); -#if Win32 && !defined(EMBEDDED) +#if Win32 fill_win32_filefunc64A(pzlib_filefunc_def); #else fill_fopen64_filefunc(pzlib_filefunc_def); Modified: trunk/lvzip/c_source/unzip.c =================================================================== --- trunk/lvzip/c_source/unzip.c 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/unzip.c 2018-12-12 23:32:45 UTC (rev 1568) @@ -356,7 +356,11 @@ us.z_filefunc.ztell32_file = NULL; if (pzlib_filefunc64_32_def == NULL) - fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); +#if WIN32 + fill_win32_filefunc64A(&us.z_filefunc.zfile_func64); +#else + fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); +#endif else us.z_filefunc = *pzlib_filefunc64_32_def; @@ -495,6 +499,7 @@ return (unzFile)s; } +#if 0 extern unzFile ZEXPORT unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc32_def) { if (pzlib_filefunc32_def != NULL) @@ -505,6 +510,7 @@ } return unzOpenInternal(path, NULL); } +#endif extern unzFile ZEXPORT unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def) { @@ -905,7 +911,7 @@ unz_file_info64 file_info64; int err = UNZ_OK; - err = unzGetCurrentFileInfoInternal(file, pfile_info ? &file_info64 : NULL, NULL, filename, filename_size, + err = unzGetCurrentFileInfoInternal(file, &file_info64, NULL, filename, filename_size, extrafield, extrafield_size, comment, comment_size); if ((err == UNZ_OK) && (pfile_info != NULL)) Modified: trunk/lvzip/c_source/unzip.h =================================================================== --- trunk/lvzip/c_source/unzip.h 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/unzip.h 2018-12-12 23:32:45 UTC (rev 1568) @@ -29,7 +29,10 @@ #ifndef _ZLIBIOAPI_H #include "ioapi.h" +#if WIN32 +#include "iowin.h" #endif +#endif #ifdef HAVE_BZIP2 #include "bzlib.h" Modified: trunk/lvzip/c_source/zip.c =================================================================== --- trunk/lvzip/c_source/zip.c 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/zip.c 2018-12-12 23:32:45 UTC (rev 1568) @@ -622,8 +622,12 @@ ziinit.z_filefunc.ztell32_file = NULL; if (pzlib_filefunc64_32_def == NULL) +#if WIN32 + fill_win32_filefunc64A(&ziinit.z_filefunc.zfile_func64); +#else fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); - else +#endif + else ziinit.z_filefunc = *pzlib_filefunc64_32_def; if (append == APPEND_STATUS_CREATE) @@ -847,19 +851,7 @@ return(zipFile)zi; } -extern zipFile ZEXPORT zipOpen2(const char *path, int append, const char **globalcomment, - zlib_filefunc_def *pzlib_filefunc32_def) -{ - if (pzlib_filefunc32_def != NULL) - { - zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; - fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); - return zipOpen4(path, append, 0, globalcomment, &zlib_filefunc64_32_def_fill); - } - return zipOpen4(path, append, 0, globalcomment, NULL); -} - -extern zipFile ZEXPORT zipOpen2_64(const void *path, int append, const char **globalcomment, +extern zipFile ZEXPORT zipOpen3_64(const void *path, int append, uint64_t disk_size, const char **globalcomment, zlib_filefunc64_def *pzlib_filefunc_def) { if (pzlib_filefunc_def != NULL) @@ -868,11 +860,12 @@ zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; zlib_filefunc64_32_def_fill.ztell32_file = NULL; zlib_filefunc64_32_def_fill.zseek32_file = NULL; - return zipOpen4(path, append, 0, globalcomment, &zlib_filefunc64_32_def_fill); + return zipOpen4(path, append, disk_size, globalcomment, &zlib_filefunc64_32_def_fill); } - return zipOpen4(path, append, 0, globalcomment, NULL); + return zipOpen4(path, append, disk_size, globalcomment, NULL); } +#if 0 extern zipFile ZEXPORT zipOpen3(const char *path, int append, uint64_t disk_size, const char **globalcomment, zlib_filefunc_def *pzlib_filefunc32_def) { @@ -885,7 +878,19 @@ return zipOpen4(path, append, disk_size, globalcomment, NULL); } -extern zipFile ZEXPORT zipOpen3_64(const void *path, int append, uint64_t disk_size, const char **globalcomment, +extern zipFile ZEXPORT zipOpen2(const char *path, int append, const char **globalcomment, + zlib_filefunc_def *pzlib_filefunc32_def) +{ + if (pzlib_filefunc32_def != NULL) + { + zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; + fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); + return zipOpen4(path, append, 0, globalcomment, &zlib_filefunc64_32_def_fill); + } + return zipOpen4(path, append, 0, globalcomment, NULL); +} + +extern zipFile ZEXPORT zipOpen2_64(const void *path, int append, const char **globalcomment, zlib_filefunc64_def *pzlib_filefunc_def) { if (pzlib_filefunc_def != NULL) @@ -894,9 +899,9 @@ zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; zlib_filefunc64_32_def_fill.ztell32_file = NULL; zlib_filefunc64_32_def_fill.zseek32_file = NULL; - return zipOpen4(path, append, disk_size, globalcomment, &zlib_filefunc64_32_def_fill); + return zipOpen4(path, append, 0, globalcomment, &zlib_filefunc64_32_def_fill); } - return zipOpen4(path, append, disk_size, globalcomment, NULL); + return zipOpen4(path, append, 0, globalcomment, NULL); } extern zipFile ZEXPORT zipOpen(const char *path, int append) @@ -908,6 +913,7 @@ { return zipOpen3(path, append, 0, NULL, NULL); } +#endif extern int ZEXPORT zipOpenNewFileInZip_internal(zipFile file, const char *filename, Modified: trunk/lvzip/c_source/zip.h =================================================================== --- trunk/lvzip/c_source/zip.h 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/zip.h 2018-12-12 23:32:45 UTC (rev 1568) @@ -27,6 +27,9 @@ #ifndef _ZLIBIOAPI_H # include "ioapi.h" +# if WIN32 +# include "iowin.h" +# endif #endif #ifdef HAVE_BZIP2 Modified: trunk/lvzip/c_source/zlibvc.dsp =================================================================== --- trunk/lvzip/c_source/zlibvc.dsp 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/zlibvc.dsp 2018-12-12 23:32:45 UTC (rev 1568) @@ -115,7 +115,7 @@ LIB32=link.exe -lib CPP=cl.exe # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "NO_vsnprintf" /D "HAVE_BZIP2" /D "BZ_NO_STDIO" /D "EMBEDDED" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /I "bzip2" /D "WIN32" /D "NDEBUG" /D "NO_vsnprintf" /D "HAVE_AES" /D "HAVE_BZIP2" /D "BZ_NO_STDIO" /D "EMBEDDED" /FR /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "bzip2" /D "WIN32" /D "NDEBUG" /D "NO_vsnprintf" /D "HAVE_AES" /D "HAVE_BZIP2" /D "BZ_NO_STDIO" /D "EMBEDDED" /FR /FD /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -128,7 +128,8 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 /nologo /subsystem:windows /dll /pdb:none /machine:I386 -# ADD LINK32 advapi32.lib user32.lib kernel32.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /out:"Win32_DLL_Embedded\lvzlib.dll" +# ADD LINK32 advapi32.lib msvcrt.lib user32.lib kernel32.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /out:"Win32_DLL_Embedded\lvzlib.dll" +# SUBTRACT LINK32 /nodefaultlib !ELSEIF "$(CFG)" == "zlibvc - Win32 DLL ASM Release" @@ -423,6 +424,10 @@ # End Source File # Begin Source File +SOURCE=.\gzguts.h +# End Source File +# Begin Source File + SOURCE=.\inffast.h # End Source File # Begin Source File @@ -451,6 +456,10 @@ # End Source File # Begin Source File +SOURCE=.\lvapi.h +# End Source File +# Begin Source File + SOURCE=.\lvutil.h # End Source File # Begin Source File @@ -729,18 +738,6 @@ # End Source File # Begin Source File -SOURCE=.\aes\aes_ni.c -# End Source File -# Begin Source File - -SOURCE=.\aes\aes_ni.h -# End Source File -# Begin Source File - -SOURCE=.\aes\aes_via_ace.h -# End Source File -# Begin Source File - SOURCE=.\aes\aescrypt.c # End Source File # Begin Source File @@ -769,14 +766,6 @@ # End Source File # Begin Source File -SOURCE=.\aes\entropy.c -# End Source File -# Begin Source File - -SOURCE=.\aes\entropy.h -# End Source File -# Begin Source File - SOURCE=.\aes\fileenc.c # End Source File # Begin Source File Modified: trunk/lvzip/c_source/zlibvc.vcproj =================================================================== --- trunk/lvzip/c_source/zlibvc.vcproj 2018-12-12 11:22:02 UTC (rev 1567) +++ trunk/lvzip/c_source/zlibvc.vcproj 2018-12-12 23:32:45 UTC (rev 1568) @@ -2625,14 +2625,6 @@ > </File> <File - RelativePath=".\aes\entropy.c" - > - </File> - <File - RelativePath=".\aes\entropy.h" - > - </File> - <File RelativePath=".\aes\fileenc.c" > </File> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |