mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Merge pull request #12736 from mitaclaw/minizip-ng-update
Externals: Update minizip-ng to 4.0.5 and convert to submodule
This commit is contained in:
@@ -78,3 +78,6 @@
|
||||
[submodule "Externals/tinygltf/tinygltf"]
|
||||
path = Externals/tinygltf/tinygltf
|
||||
url = https://github.com/syoyo/tinygltf.git
|
||||
[submodule "Externals/minizip-ng/minizip-ng"]
|
||||
path = Externals/minizip-ng/minizip-ng
|
||||
url = https://github.com/zlib-ng/minizip-ng
|
||||
|
||||
@@ -79,7 +79,7 @@ function(dolphin_find_optional_system_library_pkgconfig library search alias bun
|
||||
dolphin_optional_system_library(${library})
|
||||
string(TOUPPER ${library} upperlib)
|
||||
if(RESOLVED_USE_SYSTEM_${upperlib})
|
||||
pkg_check_modules(${library} ${search} ${ARGN} IMPORTED_TARGET)
|
||||
pkg_search_module(${library} ${search} ${ARGN} IMPORTED_TARGET)
|
||||
if((NOT ${library}_FOUND) AND (NOT ${RESOLVED_USE_SYSTEM_${upperlib}} STREQUAL "AUTO"))
|
||||
message(FATAL_ERROR "No system ${library} was found. Please install it or set USE_SYSTEM_${upperlib} to AUTO or OFF.")
|
||||
endif()
|
||||
|
||||
+3
-3
@@ -674,9 +674,9 @@ dolphin_find_optional_system_library_pkgconfig(ZSTD libzstd>=1.4.0 zstd::zstd Ex
|
||||
|
||||
dolphin_find_optional_system_library_pkgconfig(ZLIB zlib-ng ZLIB::ZLIB Externals/zlib-ng)
|
||||
|
||||
# https://github.com/zlib-ng/minizip-ng/commit/6c5f265a55f1a12a7a016cd2962feff91cff5d2e
|
||||
add_definitions(-DMZ_COMPAT_VERSION=110) # This macro is for forwards compatibility with 4.0.4+
|
||||
dolphin_find_optional_system_library_pkgconfig(MINIZIP minizip>=3.0.0 minizip::minizip Externals/minizip)
|
||||
dolphin_find_optional_system_library_pkgconfig(MINIZIP
|
||||
"minizip-ng>=4.0.4;minizip>=4.0.4" minizip::minizip Externals/minizip-ng
|
||||
)
|
||||
|
||||
dolphin_find_optional_system_library(LZO Externals/LZO)
|
||||
|
||||
|
||||
Vendored
+88
@@ -0,0 +1,88 @@
|
||||
project(minizip C)
|
||||
|
||||
add_library(minizip STATIC
|
||||
minizip-ng/mz.h
|
||||
minizip-ng/mz_compat.c
|
||||
minizip-ng/mz_compat.h
|
||||
minizip-ng/mz_crypt.c
|
||||
minizip-ng/mz_crypt.h
|
||||
minizip-ng/mz_os.c
|
||||
minizip-ng/mz_os.h
|
||||
minizip-ng/mz_strm.c
|
||||
minizip-ng/mz_strm.h
|
||||
minizip-ng/mz_strm_buf.c
|
||||
minizip-ng/mz_strm_buf.h
|
||||
# minizip-ng/mz_strm_bzip.c
|
||||
# minizip-ng/mz_strm_bzip.h
|
||||
# minizip-ng/mz_strm_libcomp.c
|
||||
# minizip-ng/mz_strm_libcomp.h
|
||||
# minizip-ng/mz_strm_lzma.c
|
||||
# minizip-ng/mz_strm_lzma.h
|
||||
minizip-ng/mz_strm_mem.c
|
||||
minizip-ng/mz_strm_mem.h
|
||||
minizip-ng/mz_strm_os.h
|
||||
# minizip-ng/mz_strm_pkcrypt.c
|
||||
# minizip-ng/mz_strm_pkcrypt.h
|
||||
minizip-ng/mz_strm_split.c
|
||||
minizip-ng/mz_strm_split.h
|
||||
# minizip-ng/mz_strm_wzaes.c
|
||||
# minizip-ng/mz_strm_wzaes.h
|
||||
minizip-ng/mz_strm_zlib.c
|
||||
minizip-ng/mz_strm_zlib.h
|
||||
# minizip-ng/mz_strm_zstd.c
|
||||
# minizip-ng/mz_strm_zstd.h
|
||||
minizip-ng/mz_zip.c
|
||||
minizip-ng/mz_zip.h
|
||||
minizip-ng/mz_zip_rw.c
|
||||
minizip-ng/mz_zip_rw.h
|
||||
)
|
||||
dolphin_disable_warnings(minizip)
|
||||
|
||||
if (UNIX)
|
||||
target_sources(minizip PRIVATE
|
||||
minizip-ng/mz_os_posix.c
|
||||
minizip-ng/mz_strm_os_posix.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
target_sources(minizip PRIVATE
|
||||
minizip-ng/mz_os_win32.c
|
||||
minizip-ng/mz_strm_os_win32.c
|
||||
)
|
||||
endif()
|
||||
|
||||
# Unused files
|
||||
# minizip-ng/minigzip.c
|
||||
# minizip-ng/minizip.c
|
||||
# minizip-ng/mz_crypt_apple.c
|
||||
# minizip-ng/mz_crypt_openssl.c
|
||||
# minizip-ng/mz_crypt_winvista.c
|
||||
# minizip-ng/mz_crypt_winxp.c
|
||||
|
||||
target_include_directories(minizip PUBLIC minizip-ng)
|
||||
|
||||
target_compile_definitions(minizip PRIVATE HAVE_ZLIB ZLIB_COMPAT MZ_ZIP_NO_CRYPTO MZ_ZIP_NO_ENCRYPTION)
|
||||
if (UNIX)
|
||||
target_compile_definitions(minizip PRIVATE _POSIX_C_SOURCE=200112L)
|
||||
target_compile_definitions(minizip PRIVATE __USE_LARGEFILE64 _LARGEFILE64_SOURCE)
|
||||
endif()
|
||||
|
||||
check_include_file(stdint.h HAVE_STDINT_H)
|
||||
if (HAVE_STDINT_H)
|
||||
target_compile_definitions(minizip PRIVATE HAVE_STDINT_H)
|
||||
endif()
|
||||
|
||||
check_include_file(inttypes.h HAVE_INTTYPES_H)
|
||||
if (HAVE_INTTYPES_H)
|
||||
target_compile_definitions(minizip PRIVATE HAVE_INTTYPES_H)
|
||||
endif()
|
||||
|
||||
check_function_exists(fseeko HAVE_FSEEKO)
|
||||
if (NOT HAVE_FSEEKO)
|
||||
target_compile_definitions(minizip PRIVATE NO_FSEEKO)
|
||||
endif()
|
||||
|
||||
target_link_libraries(minizip PUBLIC ZLIB::ZLIB)
|
||||
|
||||
add_library(minizip::minizip ALIAS minizip)
|
||||
@@ -2,11 +2,11 @@
|
||||
<Project>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ExternalsDir)minizip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ExternalsDir)minizip-ng\minizip-ng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(ExternalsDir)minizip\minizip.vcxproj">
|
||||
<ProjectReference Include="$(ExternalsDir)minizip-ng\minizip-ng.vcxproj">
|
||||
<Project>{23114507-079a-4418-9707-cfa81a03ca99}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
+1
Submodule Externals/minizip-ng/minizip-ng added at 3eed562ef0
+24
-33
@@ -21,41 +21,32 @@
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="CMakeLists.txt" />
|
||||
<ClCompile Include="minizip-ng\mz_compat.c" />
|
||||
<ClCompile Include="minizip-ng\mz_crypt.c" />
|
||||
<ClCompile Include="minizip-ng\mz_os.c" />
|
||||
<ClCompile Include="minizip-ng\mz_os_win32.c" />
|
||||
<ClCompile Include="minizip-ng\mz_strm.c" />
|
||||
<ClCompile Include="minizip-ng\mz_strm_buf.c" />
|
||||
<ClCompile Include="minizip-ng\mz_strm_mem.c" />
|
||||
<ClCompile Include="minizip-ng\mz_strm_os_win32.c" />
|
||||
<ClCompile Include="minizip-ng\mz_strm_split.c" />
|
||||
<ClCompile Include="minizip-ng\mz_strm_zlib.c" />
|
||||
<ClCompile Include="minizip-ng\mz_zip.c" />
|
||||
<ClCompile Include="minizip-ng\mz_zip_rw.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="mz_compat.c" />
|
||||
<ClCompile Include="mz_crypt.c" />
|
||||
<ClCompile Include="mz_os.c" />
|
||||
<ClCompile Include="mz_os_win32.c" />
|
||||
<ClCompile Include="mz_strm.c" />
|
||||
<ClCompile Include="mz_strm_buf.c" />
|
||||
<ClCompile Include="mz_strm_mem.c" />
|
||||
<ClCompile Include="mz_strm_os_win32.c" />
|
||||
<ClCompile Include="mz_strm_split.c" />
|
||||
<ClCompile Include="mz_strm_zlib.c" />
|
||||
<ClCompile Include="mz_zip.c" />
|
||||
<ClCompile Include="mz_zip_rw.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="mz.h" />
|
||||
<ClInclude Include="mz_compat.h" />
|
||||
<ClInclude Include="mz_crypt.h" />
|
||||
<ClInclude Include="mz_os.h" />
|
||||
<ClInclude Include="mz_strm.h" />
|
||||
<ClInclude Include="mz_strm_buf.h" />
|
||||
<ClInclude Include="mz_strm_mem.h" />
|
||||
<ClInclude Include="mz_strm_os.h" />
|
||||
<ClInclude Include="mz_strm_split.h" />
|
||||
<ClInclude Include="mz_strm_zlib.h" />
|
||||
<ClInclude Include="mz_zip.h" />
|
||||
<ClInclude Include="mz_zip_rw.h" />
|
||||
<ClInclude Include="unzip.h" />
|
||||
<ClInclude Include="zip.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="LICENSE" />
|
||||
<None Include="README" />
|
||||
<ClInclude Include="minizip-ng\mz.h" />
|
||||
<ClInclude Include="minizip-ng\mz_compat.h" />
|
||||
<ClInclude Include="minizip-ng\mz_crypt.h" />
|
||||
<ClInclude Include="minizip-ng\mz_os.h" />
|
||||
<ClInclude Include="minizip-ng\mz_strm.h" />
|
||||
<ClInclude Include="minizip-ng\mz_strm_buf.h" />
|
||||
<ClInclude Include="minizip-ng\mz_strm_mem.h" />
|
||||
<ClInclude Include="minizip-ng\mz_strm_os.h" />
|
||||
<ClInclude Include="minizip-ng\mz_strm_split.h" />
|
||||
<ClInclude Include="minizip-ng\mz_strm_zlib.h" />
|
||||
<ClInclude Include="minizip-ng\mz_zip.h" />
|
||||
<ClInclude Include="minizip-ng\mz_zip_rw.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(ExternalsDir)zlib-ng\exports.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
Vendored
-70
@@ -1,70 +0,0 @@
|
||||
project(minizip C)
|
||||
|
||||
add_library(minizip STATIC
|
||||
mz.h
|
||||
mz_compat.c
|
||||
mz_compat.h
|
||||
mz_crypt.c
|
||||
mz_crypt.h
|
||||
mz_os.c
|
||||
mz_os.h
|
||||
mz_strm.c
|
||||
mz_strm.h
|
||||
mz_strm_buf.c
|
||||
mz_strm_buf.h
|
||||
mz_strm_mem.c
|
||||
mz_strm_mem.h
|
||||
mz_strm_os.h
|
||||
mz_strm_split.c
|
||||
mz_strm_split.h
|
||||
mz_strm_zlib.c
|
||||
mz_strm_zlib.h
|
||||
mz_zip.c
|
||||
mz_zip.h
|
||||
mz_zip_rw.c
|
||||
mz_zip_rw.h
|
||||
unzip.h
|
||||
zip.h
|
||||
)
|
||||
dolphin_disable_warnings(minizip)
|
||||
|
||||
if (UNIX)
|
||||
target_sources(minizip PRIVATE
|
||||
mz_os_posix.c
|
||||
mz_strm_os_posix.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
target_sources(minizip PRIVATE
|
||||
mz_os_win32.c
|
||||
mz_strm_os_win32.c
|
||||
)
|
||||
endif()
|
||||
|
||||
target_include_directories(minizip PUBLIC .)
|
||||
|
||||
target_compile_definitions(minizip PRIVATE HAVE_ZLIB ZLIB_COMPAT MZ_ZIP_NO_CRYPTO MZ_ZIP_NO_ENCRYPTION)
|
||||
if (UNIX)
|
||||
target_compile_definitions(minizip PRIVATE _POSIX_C_SOURCE=200112L)
|
||||
target_compile_definitions(minizip PRIVATE __USE_LARGEFILE64 _LARGEFILE64_SOURCE)
|
||||
endif()
|
||||
|
||||
check_include_file(stdint.h HAVE_STDINT_H)
|
||||
if (HAVE_STDINT_H)
|
||||
target_compile_definitions(minizip PRIVATE HAVE_STDINT_H)
|
||||
endif()
|
||||
|
||||
check_include_file(inttypes.h HAVE_INTTYPES_H)
|
||||
if (HAVE_INTTYPES_H)
|
||||
target_compile_definitions(minizip PRIVATE HAVE_INTTYPES_H)
|
||||
endif()
|
||||
|
||||
check_function_exists(fseeko HAVE_FSEEKO)
|
||||
if (NOT HAVE_FSEEKO)
|
||||
target_compile_definitions(minizip PRIVATE NO_FSEEKO)
|
||||
endif()
|
||||
|
||||
target_link_libraries(minizip PUBLIC ZLIB::ZLIB)
|
||||
|
||||
add_library(minizip::minizip ALIAS minizip)
|
||||
-1015
File diff suppressed because it is too large
Load Diff
Vendored
-17
@@ -1,17 +0,0 @@
|
||||
Condition of use and distribution are the same as zlib:
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgement in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
minizip-ng, Version 3.0.4 (2021-11-29)
|
||||
https://github.com/zlib-ng/minizip-ng
|
||||
Revision: 95987e98b4862c055b8cf91d6e7ce5f9153ddc24
|
||||
Vendored
-182
@@ -1,182 +0,0 @@
|
||||
/* minigzip.c
|
||||
part of the minizip-ng project
|
||||
|
||||
Copyright (C) 2010-2021 Nathan Moinvaziri
|
||||
https://github.com/zlib-ng/minizip-ng
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
See the accompanying LICENSE file for the full text of the license.
|
||||
*/
|
||||
|
||||
|
||||
#include "mz.h"
|
||||
#include "mz_os.h"
|
||||
#include "mz_strm.h"
|
||||
#include "mz_strm_os.h"
|
||||
#include "mz_strm_zlib.h"
|
||||
|
||||
#include <stdio.h> /* printf */
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define MZ_GZIP_COMPRESS (1)
|
||||
#define MZ_GZIP_DECOMPRESS (2)
|
||||
|
||||
int32_t minigzip_banner(void);
|
||||
int32_t minigzip_help(void);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
int32_t minigzip_banner(void) {
|
||||
printf("Minigzip %s - https://github.com/zlib-ng/minizip-ng\n", MZ_VERSION);
|
||||
printf("---------------------------------------------------\n");
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t minigzip_help(void) {
|
||||
printf("Usage: minigzip [-x] [-d] [-0 to -9] [files]\n\n" \
|
||||
" -x Extract file\n" \
|
||||
" -d Destination directory\n" \
|
||||
" -0 Store only\n" \
|
||||
" -1 Compress faster\n" \
|
||||
" -9 Compress better\n\n");
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
int32_t minigzip_copy(const char *path, const char *destination, int16_t operation, int16_t level) {
|
||||
void *target_stream = NULL;
|
||||
void *source_stream = NULL;
|
||||
void *zlib_stream = NULL;
|
||||
const char *filename = NULL;
|
||||
char target_path[1024];
|
||||
int32_t err = 0;
|
||||
|
||||
|
||||
memset(target_path, 0, sizeof(target_path));
|
||||
|
||||
if (destination != NULL) {
|
||||
if (mz_os_file_exists(destination) != MZ_OK)
|
||||
mz_dir_make(destination);
|
||||
}
|
||||
|
||||
if (operation == MZ_GZIP_COMPRESS) {
|
||||
mz_path_combine(target_path, path, sizeof(target_path));
|
||||
strncat(target_path, ".gz", sizeof(target_path) - strlen(target_path) - 1);
|
||||
printf("Compressing to %s\n", target_path);
|
||||
} else if (operation == MZ_GZIP_DECOMPRESS) {
|
||||
if (destination != NULL)
|
||||
mz_path_combine(target_path, destination, sizeof(target_path));
|
||||
|
||||
if (mz_path_get_filename(path, &filename) != MZ_OK)
|
||||
filename = path;
|
||||
|
||||
mz_path_combine(target_path, filename, sizeof(target_path));
|
||||
mz_path_remove_extension(target_path);
|
||||
printf("Decompressing to %s\n", target_path);
|
||||
}
|
||||
|
||||
mz_stream_zlib_create(&zlib_stream);
|
||||
mz_stream_zlib_set_prop_int64(zlib_stream, MZ_STREAM_PROP_COMPRESS_WINDOW, 15 + 16);
|
||||
|
||||
mz_stream_os_create(&source_stream);
|
||||
err = mz_stream_os_open(source_stream, path, MZ_OPEN_MODE_READ);
|
||||
|
||||
if (err == MZ_OK) {
|
||||
mz_stream_os_create(&target_stream);
|
||||
err = mz_stream_os_open(target_stream, target_path, MZ_OPEN_MODE_CREATE | MZ_OPEN_MODE_WRITE);
|
||||
|
||||
if (err == MZ_OK) {
|
||||
if (operation == MZ_GZIP_COMPRESS) {
|
||||
mz_stream_zlib_set_prop_int64(zlib_stream, MZ_STREAM_PROP_COMPRESS_LEVEL, level);
|
||||
mz_stream_zlib_open(zlib_stream, target_path, MZ_OPEN_MODE_WRITE);
|
||||
mz_stream_set_base(zlib_stream, target_stream);
|
||||
err = mz_stream_copy_to_end(zlib_stream, source_stream);
|
||||
} else if (operation == MZ_GZIP_DECOMPRESS) {
|
||||
mz_stream_zlib_open(zlib_stream, path, MZ_OPEN_MODE_READ);
|
||||
mz_stream_set_base(zlib_stream, source_stream);
|
||||
err = mz_stream_copy_to_end(target_stream, zlib_stream);
|
||||
}
|
||||
|
||||
if (err != MZ_OK)
|
||||
printf("Error %d in zlib stream (%d)\n", err, mz_stream_zlib_error(zlib_stream));
|
||||
else
|
||||
printf("Operation completed successfully\n");
|
||||
|
||||
mz_stream_zlib_close(zlib_stream);
|
||||
} else {
|
||||
printf("Error %d opening target path %s\n", err, target_path);
|
||||
}
|
||||
|
||||
mz_stream_os_close(target_stream);
|
||||
mz_stream_os_delete(&target_stream);
|
||||
} else {
|
||||
printf("Error %d opening source path %s\n", err, path);
|
||||
}
|
||||
|
||||
mz_stream_os_close(source_stream);
|
||||
mz_stream_os_delete(&source_stream);
|
||||
|
||||
mz_stream_zlib_delete(&zlib_stream);
|
||||
return err;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#if !defined(MZ_ZIP_NO_MAIN)
|
||||
int main(int argc, const char *argv[]) {
|
||||
int16_t operation_level = MZ_COMPRESS_LEVEL_DEFAULT;
|
||||
int32_t path_arg = 0;
|
||||
int32_t err = 0;
|
||||
int32_t i = 0;
|
||||
uint8_t operation = MZ_GZIP_COMPRESS;
|
||||
const char *path = NULL;
|
||||
const char *destination = NULL;
|
||||
|
||||
|
||||
minigzip_banner();
|
||||
if (argc == 1) {
|
||||
minigzip_help();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Parse command line options */
|
||||
for (i = 1; i < argc; i += 1) {
|
||||
printf("%s ", argv[i]);
|
||||
if (argv[i][0] == '-') {
|
||||
char c = argv[i][1];
|
||||
if ((c == 'x') || (c == 'X'))
|
||||
operation = MZ_GZIP_DECOMPRESS;
|
||||
else if ((c >= '0') && (c <= '9'))
|
||||
operation_level = (c - '0');
|
||||
else if (((c == 'd') || (c == 'D')) && (i + 1 < argc)) {
|
||||
destination = argv[i + 1];
|
||||
printf("%s ", argv[i + 1]);
|
||||
i += 1;
|
||||
} else {
|
||||
err = MZ_SUPPORT_ERROR;
|
||||
}
|
||||
} else if (path_arg == 0) {
|
||||
path_arg = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if (err == MZ_SUPPORT_ERROR) {
|
||||
printf("Feature not supported\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
if (path_arg == 0) {
|
||||
minigzip_help();
|
||||
return 0;
|
||||
}
|
||||
|
||||
path = argv[path_arg];
|
||||
err = minigzip_copy(path, destination, operation, operation_level);
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
Vendored
-671
File diff suppressed because it is too large
Load Diff
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
sharedlibdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
|
||||
Name: @PROJECT_NAME@
|
||||
Description: Minizip zip file manipulation library
|
||||
Version: @VERSION@
|
||||
|
||||
Requires: zlib
|
||||
Libs: -L${libdir} -L${sharedlibdir} -l@PROJECT_NAME@
|
||||
Libs.private:@PC_PRIVATE_LIBS@
|
||||
Cflags: -I${includedir}
|
||||
Vendored
-274
@@ -1,274 +0,0 @@
|
||||
/* mz.h -- Errors codes, zip flags and magic
|
||||
part of the minizip-ng project
|
||||
|
||||
Copyright (C) 2010-2021 Nathan Moinvaziri
|
||||
https://github.com/zlib-ng/minizip-ng
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
See the accompanying LICENSE file for the full text of the license.
|
||||
*/
|
||||
|
||||
#ifndef MZ_H
|
||||
#define MZ_H
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* MZ_VERSION */
|
||||
#define MZ_VERSION ("3.0.4")
|
||||
#define MZ_VERSION_BUILD (030004)
|
||||
|
||||
/* MZ_ERROR */
|
||||
#define MZ_OK (0) /* zlib */
|
||||
#define MZ_STREAM_ERROR (-1) /* zlib */
|
||||
#define MZ_DATA_ERROR (-3) /* zlib */
|
||||
#define MZ_MEM_ERROR (-4) /* zlib */
|
||||
#define MZ_BUF_ERROR (-5) /* zlib */
|
||||
#define MZ_VERSION_ERROR (-6) /* zlib */
|
||||
|
||||
#define MZ_END_OF_LIST (-100)
|
||||
#define MZ_END_OF_STREAM (-101)
|
||||
|
||||
#define MZ_PARAM_ERROR (-102)
|
||||
#define MZ_FORMAT_ERROR (-103)
|
||||
#define MZ_INTERNAL_ERROR (-104)
|
||||
#define MZ_CRC_ERROR (-105)
|
||||
#define MZ_CRYPT_ERROR (-106)
|
||||
#define MZ_EXIST_ERROR (-107)
|
||||
#define MZ_PASSWORD_ERROR (-108)
|
||||
#define MZ_SUPPORT_ERROR (-109)
|
||||
#define MZ_HASH_ERROR (-110)
|
||||
#define MZ_OPEN_ERROR (-111)
|
||||
#define MZ_CLOSE_ERROR (-112)
|
||||
#define MZ_SEEK_ERROR (-113)
|
||||
#define MZ_TELL_ERROR (-114)
|
||||
#define MZ_READ_ERROR (-115)
|
||||
#define MZ_WRITE_ERROR (-116)
|
||||
#define MZ_SIGN_ERROR (-117)
|
||||
#define MZ_SYMLINK_ERROR (-118)
|
||||
|
||||
/* MZ_OPEN */
|
||||
#define MZ_OPEN_MODE_READ (0x01)
|
||||
#define MZ_OPEN_MODE_WRITE (0x02)
|
||||
#define MZ_OPEN_MODE_READWRITE (MZ_OPEN_MODE_READ | MZ_OPEN_MODE_WRITE)
|
||||
#define MZ_OPEN_MODE_APPEND (0x04)
|
||||
#define MZ_OPEN_MODE_CREATE (0x08)
|
||||
#define MZ_OPEN_MODE_EXISTING (0x10)
|
||||
|
||||
/* MZ_SEEK */
|
||||
#define MZ_SEEK_SET (0)
|
||||
#define MZ_SEEK_CUR (1)
|
||||
#define MZ_SEEK_END (2)
|
||||
|
||||
/* MZ_COMPRESS */
|
||||
#define MZ_COMPRESS_METHOD_STORE (0)
|
||||
#define MZ_COMPRESS_METHOD_DEFLATE (8)
|
||||
#define MZ_COMPRESS_METHOD_BZIP2 (12)
|
||||
#define MZ_COMPRESS_METHOD_LZMA (14)
|
||||
#define MZ_COMPRESS_METHOD_ZSTD (93)
|
||||
#define MZ_COMPRESS_METHOD_XZ (95)
|
||||
#define MZ_COMPRESS_METHOD_AES (99)
|
||||
|
||||
#define MZ_COMPRESS_LEVEL_DEFAULT (-1)
|
||||
#define MZ_COMPRESS_LEVEL_FAST (2)
|
||||
#define MZ_COMPRESS_LEVEL_NORMAL (6)
|
||||
#define MZ_COMPRESS_LEVEL_BEST (9)
|
||||
|
||||
/* MZ_ZIP_FLAG */
|
||||
#define MZ_ZIP_FLAG_ENCRYPTED (1 << 0)
|
||||
#define MZ_ZIP_FLAG_LZMA_EOS_MARKER (1 << 1)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_MAX (1 << 1)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_NORMAL (0)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_FAST (1 << 2)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_SUPER_FAST (MZ_ZIP_FLAG_DEFLATE_FAST | \
|
||||
MZ_ZIP_FLAG_DEFLATE_MAX)
|
||||
#define MZ_ZIP_FLAG_DATA_DESCRIPTOR (1 << 3)
|
||||
#define MZ_ZIP_FLAG_UTF8 (1 << 11)
|
||||
#define MZ_ZIP_FLAG_MASK_LOCAL_INFO (1 << 13)
|
||||
|
||||
/* MZ_ZIP_EXTENSION */
|
||||
#define MZ_ZIP_EXTENSION_ZIP64 (0x0001)
|
||||
#define MZ_ZIP_EXTENSION_NTFS (0x000a)
|
||||
#define MZ_ZIP_EXTENSION_AES (0x9901)
|
||||
#define MZ_ZIP_EXTENSION_UNIX1 (0x000d)
|
||||
#define MZ_ZIP_EXTENSION_SIGN (0x10c5)
|
||||
#define MZ_ZIP_EXTENSION_HASH (0x1a51)
|
||||
#define MZ_ZIP_EXTENSION_CDCD (0xcdcd)
|
||||
|
||||
/* MZ_ZIP64 */
|
||||
#define MZ_ZIP64_AUTO (0)
|
||||
#define MZ_ZIP64_FORCE (1)
|
||||
#define MZ_ZIP64_DISABLE (2)
|
||||
|
||||
/* MZ_HOST_SYSTEM */
|
||||
#define MZ_HOST_SYSTEM(VERSION_MADEBY) ((uint8_t)(VERSION_MADEBY >> 8))
|
||||
#define MZ_HOST_SYSTEM_MSDOS (0)
|
||||
#define MZ_HOST_SYSTEM_UNIX (3)
|
||||
#define MZ_HOST_SYSTEM_WINDOWS_NTFS (10)
|
||||
#define MZ_HOST_SYSTEM_RISCOS (13)
|
||||
#define MZ_HOST_SYSTEM_OSX_DARWIN (19)
|
||||
|
||||
/* MZ_PKCRYPT */
|
||||
#define MZ_PKCRYPT_HEADER_SIZE (12)
|
||||
|
||||
/* MZ_AES */
|
||||
#define MZ_AES_VERSION (1)
|
||||
#define MZ_AES_ENCRYPTION_MODE_128 (0x01)
|
||||
#define MZ_AES_ENCRYPTION_MODE_192 (0x02)
|
||||
#define MZ_AES_ENCRYPTION_MODE_256 (0x03)
|
||||
#define MZ_AES_KEY_LENGTH(MODE) (8 * (MODE & 3) + 8)
|
||||
#define MZ_AES_KEY_LENGTH_MAX (32)
|
||||
#define MZ_AES_BLOCK_SIZE (16)
|
||||
#define MZ_AES_HEADER_SIZE(MODE) ((4 * (MODE & 3) + 4) + 2)
|
||||
#define MZ_AES_FOOTER_SIZE (10)
|
||||
|
||||
/* MZ_HASH */
|
||||
#define MZ_HASH_MD5 (10)
|
||||
#define MZ_HASH_MD5_SIZE (16)
|
||||
#define MZ_HASH_SHA1 (20)
|
||||
#define MZ_HASH_SHA1_SIZE (20)
|
||||
#define MZ_HASH_SHA256 (23)
|
||||
#define MZ_HASH_SHA256_SIZE (32)
|
||||
#define MZ_HASH_MAX_SIZE (256)
|
||||
|
||||
/* MZ_ENCODING */
|
||||
#define MZ_ENCODING_CODEPAGE_437 (437)
|
||||
#define MZ_ENCODING_CODEPAGE_932 (932)
|
||||
#define MZ_ENCODING_CODEPAGE_936 (936)
|
||||
#define MZ_ENCODING_CODEPAGE_950 (950)
|
||||
#define MZ_ENCODING_UTF8 (65001)
|
||||
|
||||
/* MZ_UTILITY */
|
||||
#define MZ_UNUSED(SYMBOL) ((void)SYMBOL)
|
||||
|
||||
#ifndef MZ_CUSTOM_ALLOC
|
||||
#define MZ_ALLOC(SIZE) (malloc((SIZE)))
|
||||
#endif
|
||||
#ifndef MZ_CUSTOM_FREE
|
||||
#define MZ_FREE(PTR) (free(PTR))
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && defined(MZ_EXPORTS)
|
||||
#define MZ_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define MZ_EXPORT
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#include <stdlib.h> /* size_t, NULL, malloc */
|
||||
#include <time.h> /* time_t, time() */
|
||||
#include <string.h> /* memset, strncpy, strlen */
|
||||
#include <limits.h>
|
||||
|
||||
#if defined(HAVE_STDINT_H)
|
||||
# include <stdint.h>
|
||||
#elif defined(__has_include)
|
||||
# if __has_include(<stdint.h>)
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef INT8_MAX
|
||||
typedef signed char int8_t;
|
||||
#endif
|
||||
#ifndef INT16_MAX
|
||||
typedef short int16_t;
|
||||
#endif
|
||||
#ifndef INT32_MAX
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
#ifndef INT64_MAX
|
||||
typedef long long int64_t;
|
||||
#endif
|
||||
#ifndef UINT8_MAX
|
||||
typedef unsigned char uint8_t;
|
||||
#endif
|
||||
#ifndef UINT16_MAX
|
||||
typedef unsigned short uint16_t;
|
||||
#endif
|
||||
#ifndef UINT32_MAX
|
||||
typedef unsigned int uint32_t;
|
||||
#endif
|
||||
#ifndef UINT64_MAX
|
||||
typedef unsigned long long uint64_t;
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INTTYPES_H)
|
||||
# include <inttypes.h>
|
||||
#elif defined(__has_include)
|
||||
# if __has_include(<inttypes.h>)
|
||||
# include <inttypes.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PRId8
|
||||
# define PRId8 "hhd"
|
||||
#endif
|
||||
#ifndef PRIu8
|
||||
# define PRIu8 "hhu"
|
||||
#endif
|
||||
#ifndef PRIx8
|
||||
# define PRIx8 "hhx"
|
||||
#endif
|
||||
#ifndef PRId16
|
||||
# define PRId16 "hd"
|
||||
#endif
|
||||
#ifndef PRIu16
|
||||
# define PRIu16 "hu"
|
||||
#endif
|
||||
#ifndef PRIx16
|
||||
# define PRIx16 "hx"
|
||||
#endif
|
||||
#ifndef PRId32
|
||||
# define PRId32 "d"
|
||||
#endif
|
||||
#ifndef PRIu32
|
||||
# define PRIu32 "u"
|
||||
#endif
|
||||
#ifndef PRIx32
|
||||
# define PRIx32 "x"
|
||||
#endif
|
||||
#if ULONG_MAX == 0xfffffffful
|
||||
# ifndef PRId64
|
||||
# define PRId64 "ld"
|
||||
# endif
|
||||
# ifndef PRIu64
|
||||
# define PRIu64 "lu"
|
||||
# endif
|
||||
# ifndef PRIx64
|
||||
# define PRIx64 "lx"
|
||||
# endif
|
||||
#else
|
||||
# ifndef PRId64
|
||||
# define PRId64 "lld"
|
||||
# endif
|
||||
# ifndef PRIu64
|
||||
# define PRIu64 "llu"
|
||||
# endif
|
||||
# ifndef PRIx64
|
||||
# define PRIx64 "llx"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef INT16_MAX
|
||||
# define INT16_MAX 32767
|
||||
#endif
|
||||
#ifndef INT32_MAX
|
||||
# define INT32_MAX 2147483647L
|
||||
#endif
|
||||
#ifndef INT64_MAX
|
||||
# define INT64_MAX 9223372036854775807LL
|
||||
#endif
|
||||
#ifndef UINT16_MAX
|
||||
# define UINT16_MAX 65535U
|
||||
#endif
|
||||
#ifndef UINT32_MAX
|
||||
# define UINT32_MAX 4294967295UL
|
||||
#endif
|
||||
#ifndef UINT64_MAX
|
||||
# define UINT64_MAX 18446744073709551615ULL
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#endif
|
||||
Vendored
-1303
File diff suppressed because it is too large
Load Diff
Vendored
-396
@@ -1,396 +0,0 @@
|
||||
/* mz_compat.h -- Backwards compatible interface for older versions
|
||||
part of the minizip-ng project
|
||||
|
||||
Copyright (C) 2010-2021 Nathan Moinvaziri
|
||||
https://github.com/zlib-ng/minizip-ng
|
||||
Copyright (C) 1998-2010 Gilles Vollant
|
||||
https://www.winimage.com/zLibDll/minizip.html
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
See the accompanying LICENSE file for the full text of the license.
|
||||
*/
|
||||
|
||||
#ifndef MZ_COMPAT_H
|
||||
#define MZ_COMPAT_H
|
||||
|
||||
#include "mz.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#if defined(HAVE_ZLIB) && defined(MAX_MEM_LEVEL)
|
||||
#ifndef DEF_MEM_LEVEL
|
||||
# if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
# else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
#ifndef MAX_WBITS
|
||||
#define MAX_WBITS (15)
|
||||
#endif
|
||||
#ifndef DEF_MEM_LEVEL
|
||||
#define DEF_MEM_LEVEL (8)
|
||||
#endif
|
||||
|
||||
#ifndef ZEXPORT
|
||||
# define ZEXPORT MZ_EXPORT
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagzipFile__ { int unused; } zip_file__;
|
||||
typedef zip_file__ *zipFile;
|
||||
#else
|
||||
typedef void *zipFile;
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef uint64_t ZPOS64_T;
|
||||
|
||||
#ifndef ZCALLBACK
|
||||
#define ZCALLBACK
|
||||
#endif
|
||||
|
||||
typedef void* (ZCALLBACK *open_file_func) (void *opaque, const char *filename, int mode);
|
||||
typedef void* (ZCALLBACK *open64_file_func) (void *opaque, const void *filename, int mode);
|
||||
typedef unsigned long (ZCALLBACK *read_file_func) (void *opaque, void *stream, void* buf, unsigned long size);
|
||||
typedef unsigned long (ZCALLBACK *write_file_func) (void *opaque, void *stream, const void* buf,
|
||||
unsigned long size);
|
||||
typedef int (ZCALLBACK *close_file_func) (void *opaque, void *stream);
|
||||
typedef int (ZCALLBACK *testerror_file_func)(void *opaque, void *stream);
|
||||
typedef long (ZCALLBACK *tell_file_func) (void *opaque, void *stream);
|
||||
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (void *opaque, void *stream);
|
||||
typedef long (ZCALLBACK *seek_file_func) (void *opaque, void *stream, unsigned long offset, int origin);
|
||||
typedef long (ZCALLBACK *seek64_file_func) (void *opaque, void *stream, ZPOS64_T offset, int origin);
|
||||
|
||||
typedef struct zlib_filefunc_def_s
|
||||
{
|
||||
open_file_func zopen_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
tell_file_func ztell_file;
|
||||
seek_file_func zseek_file;
|
||||
close_file_func zclose_file;
|
||||
testerror_file_func zerror_file;
|
||||
void* opaque;
|
||||
} zlib_filefunc_def;
|
||||
|
||||
typedef struct zlib_filefunc64_def_s
|
||||
{
|
||||
open64_file_func zopen64_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
tell64_file_func ztell64_file;
|
||||
seek64_file_func zseek64_file;
|
||||
close_file_func zclose_file;
|
||||
testerror_file_func zerror_file;
|
||||
void* opaque;
|
||||
} zlib_filefunc64_def;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define ZLIB_FILEFUNC_SEEK_SET (0)
|
||||
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||
#define ZLIB_FILEFUNC_SEEK_END (2)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_READ (1)
|
||||
#define ZLIB_FILEFUNC_MODE_WRITE (2)
|
||||
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
|
||||
#define ZLIB_FILEFUNC_MODE_CREATE (8)
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
ZEXPORT void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def);
|
||||
ZEXPORT void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def);
|
||||
ZEXPORT void fill_win32_filefunc(zlib_filefunc_def *pzlib_filefunc_def);
|
||||
ZEXPORT void fill_win32_filefunc64(zlib_filefunc64_def *pzlib_filefunc_def);
|
||||
ZEXPORT void fill_win32_filefunc64A(zlib_filefunc64_def *pzlib_filefunc_def);
|
||||
ZEXPORT void fill_memory_filefunc(zlib_filefunc_def *pzlib_filefunc_def);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#if MZ_COMPAT_VERSION <= 110
|
||||
#define mz_dos_date dosDate
|
||||
#else
|
||||
#define mz_dos_date dos_date
|
||||
#endif
|
||||
|
||||
typedef struct tm tm_unz;
|
||||
typedef struct tm tm_zip;
|
||||
|
||||
typedef struct {
|
||||
uint32_t mz_dos_date;
|
||||
struct tm tmz_date;
|
||||
uint16_t internal_fa; /* internal file attributes 2 bytes */
|
||||
uint32_t external_fa; /* external file attributes 4 bytes */
|
||||
} zip_fileinfo;
|
||||
|
||||
typedef const char *zipcharpc;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define ZIP_OK (0)
|
||||
#define ZIP_EOF (0)
|
||||
#define ZIP_ERRNO (-1)
|
||||
#define ZIP_PARAMERROR (-102)
|
||||
#define ZIP_BADZIPFILE (-103)
|
||||
#define ZIP_INTERNALERROR (-104)
|
||||
|
||||
#ifndef Z_DEFLATED
|
||||
#define Z_DEFLATED (8)
|
||||
#endif
|
||||
#define Z_BZIP2ED (12)
|
||||
|
||||
#define APPEND_STATUS_CREATE (0)
|
||||
#define APPEND_STATUS_CREATEAFTER (1)
|
||||
#define APPEND_STATUS_ADDINZIP (2)
|
||||
|
||||
/***************************************************************************/
|
||||
/* Writing a zip file */
|
||||
|
||||
ZEXPORT zipFile zipOpen(const char *path, int append);
|
||||
ZEXPORT zipFile zipOpen64(const void *path, int append);
|
||||
ZEXPORT zipFile zipOpen2(const char *path, int append, const char **globalcomment,
|
||||
zlib_filefunc_def *pzlib_filefunc_def);
|
||||
|
||||
ZEXPORT zipFile zipOpen2_64(const void *path, int append, const char **globalcomment,
|
||||
zlib_filefunc64_def *pzlib_filefunc_def);
|
||||
ZEXPORT zipFile zipOpen_MZ(void *stream, int append, const char **globalcomment);
|
||||
|
||||
ZEXPORT void* zipGetHandle_MZ(zipFile);
|
||||
ZEXPORT void* zipGetStream_MZ(zipFile file);
|
||||
|
||||
ZEXPORT int zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, int compression_method, int level);
|
||||
ZEXPORT int zipOpenNewFileInZip_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, int compression_method, int level,
|
||||
int zip64);
|
||||
ZEXPORT int zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, int compression_method, int level,
|
||||
int raw);
|
||||
ZEXPORT int zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, int compression_method, int level,
|
||||
int raw, int zip64);
|
||||
ZEXPORT int zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, int compression_method, int level,
|
||||
int raw, int windowBits, int memLevel, int strategy, const char *password,
|
||||
unsigned long crc_for_crypting);
|
||||
ZEXPORT int zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, int compression_method, int level,
|
||||
int raw, int windowBits, int memLevel, int strategy, const char *password,
|
||||
uint32_t crc_for_crypting, int zip64);
|
||||
ZEXPORT int zipOpenNewFileInZip4(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, int compression_method, int level,
|
||||
int raw, int windowBits, int memLevel, int strategy, const char *password,
|
||||
unsigned long crc_for_crypting, unsigned long version_madeby, unsigned long flag_base);
|
||||
ZEXPORT int zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, int compression_method, int level,
|
||||
int raw, int windowBits, int memLevel, int strategy, const char *password,
|
||||
unsigned long crc_for_crypting, unsigned long version_madeby, unsigned long flag_base, int zip64);
|
||||
ZEXPORT int zipOpenNewFileInZip5(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, int compression_method, int level,
|
||||
int raw, int windowBits, int memLevel, int strategy, const char *password,
|
||||
unsigned long crc_for_crypting, unsigned long version_madeby, unsigned long flag_base, int zip64);
|
||||
|
||||
ZEXPORT int zipWriteInFileInZip(zipFile file, const void *buf, uint32_t len);
|
||||
|
||||
ZEXPORT int zipCloseFileInZipRaw(zipFile file, unsigned long uncompressed_size, unsigned long crc32);
|
||||
ZEXPORT int zipCloseFileInZipRaw64(zipFile file, uint64_t uncompressed_size, unsigned long crc32);
|
||||
ZEXPORT int zipCloseFileInZip(zipFile file);
|
||||
ZEXPORT int zipCloseFileInZip64(zipFile file);
|
||||
|
||||
ZEXPORT int zipClose(zipFile file, const char *global_comment);
|
||||
ZEXPORT int zipClose_64(zipFile file, const char *global_comment);
|
||||
ZEXPORT int zipClose2_64(zipFile file, const char *global_comment, uint16_t version_madeby);
|
||||
int zipClose_MZ(zipFile file, const char *global_comment);
|
||||
int zipClose2_MZ(zipFile file, const char *global_comment, uint16_t version_madeby);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unz_file__;
|
||||
typedef unz_file__ *unzFile;
|
||||
#else
|
||||
typedef void *unzFile;
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (-1)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
#define UNZ_BADPASSWORD (-106)
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct unz_global_info64_s {
|
||||
uint64_t number_entry; /* total number of entries in the central dir on this disk */
|
||||
uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP */
|
||||
uint16_t size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info64;
|
||||
|
||||
typedef struct unz_global_info_s {
|
||||
uint32_t number_entry; /* total number of entries in the central dir on this disk */
|
||||
uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP */
|
||||
uint16_t size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
typedef struct unz_file_info64_s {
|
||||
uint16_t version; /* version made by 2 bytes */
|
||||
uint16_t version_needed; /* version needed to extract 2 bytes */
|
||||
uint16_t flag; /* general purpose bit flag 2 bytes */
|
||||
uint16_t compression_method; /* compression method 2 bytes */
|
||||
uint32_t mz_dos_date; /* last mod file date in Dos fmt 4 bytes */
|
||||
struct tm tmu_date;
|
||||
uint32_t crc; /* crc-32 4 bytes */
|
||||
uint64_t compressed_size; /* compressed size 8 bytes */
|
||||
uint64_t uncompressed_size; /* uncompressed size 8 bytes */
|
||||
uint16_t size_filename; /* filename length 2 bytes */
|
||||
uint16_t size_file_extra; /* extra field length 2 bytes */
|
||||
uint16_t size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uint32_t disk_num_start; /* disk number start 4 bytes */
|
||||
uint16_t internal_fa; /* internal file attributes 2 bytes */
|
||||
uint32_t external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
uint64_t disk_offset;
|
||||
|
||||
uint16_t size_file_extra_internal;
|
||||
} unz_file_info64;
|
||||
|
||||
typedef struct unz_file_info_s {
|
||||
uint16_t version; /* version made by 2 bytes */
|
||||
uint16_t version_needed; /* version needed to extract 2 bytes */
|
||||
uint16_t flag; /* general purpose bit flag 2 bytes */
|
||||
uint16_t compression_method; /* compression method 2 bytes */
|
||||
uint32_t mz_dos_date; /* last mod file date in Dos fmt 4 bytes */
|
||||
struct tm tmu_date;
|
||||
uint32_t crc; /* crc-32 4 bytes */
|
||||
uint32_t compressed_size; /* compressed size 4 bytes */
|
||||
uint32_t uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uint16_t size_filename; /* filename length 2 bytes */
|
||||
uint16_t size_file_extra; /* extra field length 2 bytes */
|
||||
uint16_t size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uint16_t disk_num_start; /* disk number start 2 bytes */
|
||||
uint16_t internal_fa; /* internal file attributes 2 bytes */
|
||||
uint32_t external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
uint64_t disk_offset;
|
||||
} unz_file_info;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef int (*unzFileNameComparer)(unzFile file, const char *filename1, const char *filename2);
|
||||
typedef int (*unzIteratorFunction)(unzFile file);
|
||||
typedef int (*unzIteratorFunction2)(unzFile file, unz_file_info64 *pfile_info, char *filename,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment,
|
||||
uint16_t comment_size);
|
||||
|
||||
/***************************************************************************/
|
||||
/* Reading a zip file */
|
||||
|
||||
ZEXPORT unzFile unzOpen(const char *path);
|
||||
ZEXPORT unzFile unzOpen64(const void *path);
|
||||
ZEXPORT unzFile unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc_def);
|
||||
ZEXPORT unzFile unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def);
|
||||
unzFile unzOpen_MZ(void *stream);
|
||||
|
||||
ZEXPORT int unzClose(unzFile file);
|
||||
ZEXPORT int unzClose_MZ(unzFile file);
|
||||
|
||||
ZEXPORT void* unzGetHandle_MZ(unzFile file);
|
||||
ZEXPORT void* unzGetStream_MZ(zipFile file);
|
||||
|
||||
ZEXPORT int unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info32);
|
||||
ZEXPORT int unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info);
|
||||
ZEXPORT int unzGetGlobalComment(unzFile file, char *comment, unsigned long comment_size);
|
||||
|
||||
ZEXPORT int unzOpenCurrentFile(unzFile file);
|
||||
ZEXPORT int unzOpenCurrentFilePassword(unzFile file, const char *password);
|
||||
ZEXPORT int unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw);
|
||||
ZEXPORT int unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password);
|
||||
ZEXPORT int unzReadCurrentFile(unzFile file, void *buf, uint32_t len);
|
||||
ZEXPORT int unzCloseCurrentFile(unzFile file);
|
||||
|
||||
ZEXPORT int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *filename,
|
||||
unsigned long filename_size, void *extrafield, unsigned long extrafield_size, char *comment,
|
||||
unsigned long comment_size);
|
||||
ZEXPORT int unzGetCurrentFileInfo64(unzFile file, unz_file_info64 * pfile_info, char *filename,
|
||||
unsigned long filename_size, void *extrafield, unsigned long extrafield_size, char *comment,
|
||||
unsigned long comment_size);
|
||||
|
||||
ZEXPORT int unzGoToFirstFile(unzFile file);
|
||||
ZEXPORT int unzGoToNextFile(unzFile file);
|
||||
ZEXPORT int unzLocateFile(unzFile file, const char *filename, unzFileNameComparer filename_compare_func);
|
||||
|
||||
ZEXPORT int unzGetLocalExtrafield(unzFile file, void *buf, unsigned int len);
|
||||
|
||||
/***************************************************************************/
|
||||
/* Raw access to zip file */
|
||||
|
||||
typedef struct unz_file_pos_s {
|
||||
uint32_t pos_in_zip_directory; /* offset in zip file directory */
|
||||
uint32_t num_of_file; /* # of file */
|
||||
} unz_file_pos;
|
||||
|
||||
ZEXPORT int unzGetFilePos(unzFile file, unz_file_pos *file_pos);
|
||||
ZEXPORT int unzGoToFilePos(unzFile file, unz_file_pos *file_pos);
|
||||
|
||||
typedef struct unz64_file_pos_s {
|
||||
int64_t pos_in_zip_directory; /* offset in zip file directory */
|
||||
uint64_t num_of_file; /* # of file */
|
||||
} unz64_file_pos;
|
||||
|
||||
ZEXPORT int unzGetFilePos64(unzFile file, unz64_file_pos *file_pos);
|
||||
ZEXPORT int unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos);
|
||||
|
||||
ZEXPORT int64_t unzGetOffset64(unzFile file);
|
||||
ZEXPORT unsigned long
|
||||
unzGetOffset(unzFile file);
|
||||
ZEXPORT int unzSetOffset64(unzFile file, int64_t pos);
|
||||
ZEXPORT int unzSetOffset(unzFile file, unsigned long pos);
|
||||
ZEXPORT int32_t unztell(unzFile file);
|
||||
ZEXPORT int32_t unzTell(unzFile file);
|
||||
ZEXPORT uint64_t unztell64(unzFile file);
|
||||
ZEXPORT uint64_t unzTell64(unzFile file);
|
||||
ZEXPORT int unzSeek(unzFile file, int32_t offset, int origin);
|
||||
ZEXPORT int unzSeek64(unzFile file, int64_t offset, int origin);
|
||||
ZEXPORT int unzEndOfFile(unzFile file);
|
||||
ZEXPORT int unzeof(unzFile file);
|
||||
ZEXPORT void* unzGetStream(unzFile file);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Vendored
-196
@@ -1,196 +0,0 @@
|
||||
/* mz_crypt.c -- Crypto/hash functions
|
||||
part of the minizip-ng project
|
||||
|
||||
Copyright (C) 2010-2021 Nathan Moinvaziri
|
||||
https://github.com/zlib-ng/minizip-ng
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
See the accompanying LICENSE file for the full text of the license.
|
||||
*/
|
||||
|
||||
|
||||
#include "mz.h"
|
||||
#include "mz_os.h"
|
||||
#include "mz_crypt.h"
|
||||
|
||||
#if defined(HAVE_ZLIB)
|
||||
# include "zlib.h"
|
||||
# if defined(ZLIBNG_VERNUM) && !defined(ZLIB_COMPAT)
|
||||
# include "zlib-ng.h"
|
||||
# endif
|
||||
#elif defined(HAVE_LZMA)
|
||||
# include "lzma.h"
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
/* Define z_crc_t in zlib 1.2.5 and less or if using zlib-ng */
|
||||
|
||||
#if defined(HAVE_ZLIB) && defined(ZLIBNG_VERNUM)
|
||||
# if defined(ZLIB_COMPAT)
|
||||
# define ZLIB_PREFIX(x) x
|
||||
# else
|
||||
# define ZLIB_PREFIX(x) zng_ ## x
|
||||
# endif
|
||||
typedef uint32_t z_crc_t;
|
||||
#elif defined(HAVE_ZLIB)
|
||||
# define ZLIB_PREFIX(x) x
|
||||
# if (ZLIB_VERNUM < 0x1270)
|
||||
typedef unsigned long z_crc_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#if defined(MZ_ZIP_NO_CRYPTO)
|
||||
int32_t mz_crypt_rand(uint8_t *buf, int32_t size) {
|
||||
return mz_os_rand(buf, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size) {
|
||||
#if defined(HAVE_ZLIB)
|
||||
return (uint32_t)ZLIB_PREFIX(crc32)((z_crc_t)value, buf, (uInt)size);
|
||||
#elif defined(HAVE_LZMA)
|
||||
return (uint32_t)lzma_crc32(buf, (size_t)size, (uint32_t)value);
|
||||
#else
|
||||
static uint32_t crc32_table[256] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
||||
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
|
||||
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
||||
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
||||
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
||||
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
|
||||
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
|
||||
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
||||
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
|
||||
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
||||
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
|
||||
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
||||
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
||||
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
||||
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
|
||||
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
||||
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
|
||||
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
|
||||
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
||||
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
|
||||
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
||||
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
||||
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
||||
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
|
||||
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
|
||||
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
||||
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
|
||||
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
||||
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
|
||||
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
||||
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
||||
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
|
||||
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
||||
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
|
||||
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
|
||||
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
||||
};
|
||||
value = ~value;
|
||||
|
||||
while (size > 0) {
|
||||
value = (value >> 8) ^ crc32_table[(value ^ *buf) & 0xFF];
|
||||
|
||||
buf += 1;
|
||||
size -= 1;
|
||||
}
|
||||
|
||||
return ~value;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(HAVE_WZAES)
|
||||
int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt,
|
||||
int32_t salt_length, int32_t iteration_count, uint8_t *key, int32_t key_length) {
|
||||
void *hmac1 = NULL;
|
||||
void *hmac2 = NULL;
|
||||
void *hmac3 = NULL;
|
||||
int32_t err = MZ_OK;
|
||||
uint16_t i = 0;
|
||||
uint16_t j = 0;
|
||||
uint16_t k = 0;
|
||||
uint16_t block_count = 0;
|
||||
uint8_t uu[MZ_HASH_SHA1_SIZE];
|
||||
uint8_t ux[MZ_HASH_SHA1_SIZE];
|
||||
|
||||
if (password == NULL || salt == NULL || key == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
memset(key, 0, key_length);
|
||||
|
||||
mz_crypt_hmac_create(&hmac1);
|
||||
mz_crypt_hmac_create(&hmac2);
|
||||
mz_crypt_hmac_create(&hmac3);
|
||||
|
||||
mz_crypt_hmac_set_algorithm(hmac1, MZ_HASH_SHA1);
|
||||
mz_crypt_hmac_set_algorithm(hmac2, MZ_HASH_SHA1);
|
||||
mz_crypt_hmac_set_algorithm(hmac3, MZ_HASH_SHA1);
|
||||
|
||||
err = mz_crypt_hmac_init(hmac1, password, password_length);
|
||||
if (err == MZ_OK)
|
||||
err = mz_crypt_hmac_init(hmac2, password, password_length);
|
||||
if (err == MZ_OK)
|
||||
err = mz_crypt_hmac_update(hmac2, salt, salt_length);
|
||||
|
||||
block_count = 1 + ((uint16_t)key_length - 1) / MZ_HASH_SHA1_SIZE;
|
||||
|
||||
for (i = 0; (err == MZ_OK) && (i < block_count); i += 1) {
|
||||
memset(ux, 0, sizeof(ux));
|
||||
|
||||
err = mz_crypt_hmac_copy(hmac2, hmac3);
|
||||
if (err != MZ_OK)
|
||||
break;
|
||||
|
||||
uu[0] = (uint8_t)((i + 1) >> 24);
|
||||
uu[1] = (uint8_t)((i + 1) >> 16);
|
||||
uu[2] = (uint8_t)((i + 1) >> 8);
|
||||
uu[3] = (uint8_t)(i + 1);
|
||||
|
||||
for (j = 0, k = 4; j < iteration_count; j += 1) {
|
||||
err = mz_crypt_hmac_update(hmac3, uu, k);
|
||||
if (err == MZ_OK)
|
||||
err = mz_crypt_hmac_end(hmac3, uu, sizeof(uu));
|
||||
if (err != MZ_OK)
|
||||
break;
|
||||
|
||||
for(k = 0; k < MZ_HASH_SHA1_SIZE; k += 1)
|
||||
ux[k] ^= uu[k];
|
||||
|
||||
err = mz_crypt_hmac_copy(hmac1, hmac3);
|
||||
if (err != MZ_OK)
|
||||
break;
|
||||
}
|
||||
|
||||
if (err != MZ_OK)
|
||||
break;
|
||||
|
||||
j = 0;
|
||||
k = i * MZ_HASH_SHA1_SIZE;
|
||||
|
||||
while (j < MZ_HASH_SHA1_SIZE && k < key_length)
|
||||
key[k++] = ux[j++];
|
||||
}
|
||||
|
||||
/* hmac3 uses the same provider as hmac2, so it must be deleted
|
||||
before the context is destroyed. */
|
||||
mz_crypt_hmac_delete(&hmac3);
|
||||
mz_crypt_hmac_delete(&hmac1);
|
||||
mz_crypt_hmac_delete(&hmac2);
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
Vendored
-65
@@ -1,65 +0,0 @@
|
||||
/* mz_crypt.h -- Crypto/hash functions
|
||||
part of the minizip-ng project
|
||||
|
||||
Copyright (C) 2010-2021 Nathan Moinvaziri
|
||||
https://github.com/zlib-ng/minizip-ng
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
See the accompanying LICENSE file for the full text of the license.
|
||||
*/
|
||||
|
||||
#ifndef MZ_CRYPT_H
|
||||
#define MZ_CRYPT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size);
|
||||
|
||||
int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt,
|
||||
int32_t salt_length, int32_t iteration_count, uint8_t *key, int32_t key_length);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
int32_t mz_crypt_rand(uint8_t *buf, int32_t size);
|
||||
|
||||
void mz_crypt_sha_reset(void *handle);
|
||||
int32_t mz_crypt_sha_begin(void *handle);
|
||||
int32_t mz_crypt_sha_update(void *handle, const void *buf, int32_t size);
|
||||
int32_t mz_crypt_sha_end(void *handle, uint8_t *digest, int32_t digest_size);
|
||||
void mz_crypt_sha_set_algorithm(void *handle, uint16_t algorithm);
|
||||
void* mz_crypt_sha_create(void **handle);
|
||||
void mz_crypt_sha_delete(void **handle);
|
||||
|
||||
void mz_crypt_aes_reset(void *handle);
|
||||
int32_t mz_crypt_aes_encrypt(void *handle, uint8_t *buf, int32_t size);
|
||||
int32_t mz_crypt_aes_decrypt(void *handle, uint8_t *buf, int32_t size);
|
||||
int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_length);
|
||||
int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_length);
|
||||
void mz_crypt_aes_set_mode(void *handle, int32_t mode);
|
||||
void* mz_crypt_aes_create(void **handle);
|
||||
void mz_crypt_aes_delete(void **handle);
|
||||
|
||||
void mz_crypt_hmac_reset(void *handle);
|
||||
int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length);
|
||||
int32_t mz_crypt_hmac_update(void *handle, const void *buf, int32_t size);
|
||||
int32_t mz_crypt_hmac_end(void *handle, uint8_t *digest, int32_t digest_size);
|
||||
int32_t mz_crypt_hmac_copy(void *src_handle, void *target_handle);
|
||||
void mz_crypt_hmac_set_algorithm(void *handle, uint16_t algorithm);
|
||||
void* mz_crypt_hmac_create(void **handle);
|
||||
void mz_crypt_hmac_delete(void **handle);
|
||||
|
||||
int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size,
|
||||
const char *cert_pwd, uint8_t **signature, int32_t *signature_size);
|
||||
int32_t mz_crypt_sign_verify(uint8_t *message, int32_t message_size, uint8_t *signature, int32_t signature_size);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Vendored
-487
@@ -1,487 +0,0 @@
|
||||
/* mz_crypt_apple.c -- Crypto/hash functions for Apple
|
||||
part of the minizip-ng project
|
||||
|
||||
Copyright (C) 2010-2021 Nathan Moinvaziri
|
||||
https://github.com/zlib-ng/minizip-ng
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
See the accompanying LICENSE file for the full text of the license.
|
||||
*/
|
||||
|
||||
|
||||
#include "mz.h"
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CommonCrypto/CommonCryptor.h>
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#include <CommonCrypto/CommonHMAC.h>
|
||||
#include <Security/Security.h>
|
||||
#include <Security/SecPolicy.h>
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
int32_t mz_crypt_rand(uint8_t *buf, int32_t size) {
|
||||
if (SecRandomCopyBytes(kSecRandomDefault, size, buf) != errSecSuccess)
|
||||
return 0;
|
||||
return size;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct mz_crypt_sha_s {
|
||||
CC_SHA1_CTX ctx1;
|
||||
CC_SHA256_CTX ctx256;
|
||||
int32_t error;
|
||||
int32_t initialized;
|
||||
uint16_t algorithm;
|
||||
} mz_crypt_sha;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
void mz_crypt_sha_reset(void *handle) {
|
||||
mz_crypt_sha *sha = (mz_crypt_sha *)handle;
|
||||
|
||||
sha->error = 0;
|
||||
sha->initialized = 0;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_sha_begin(void *handle) {
|
||||
mz_crypt_sha *sha = (mz_crypt_sha *)handle;
|
||||
|
||||
if (sha == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
mz_crypt_sha_reset(handle);
|
||||
|
||||
if (sha->algorithm == MZ_HASH_SHA1)
|
||||
sha->error = CC_SHA1_Init(&sha->ctx1);
|
||||
else if (sha->algorithm == MZ_HASH_SHA256)
|
||||
sha->error = CC_SHA256_Init(&sha->ctx256);
|
||||
else
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
if (!sha->error)
|
||||
return MZ_HASH_ERROR;
|
||||
|
||||
sha->initialized = 1;
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_sha_update(void *handle, const void *buf, int32_t size) {
|
||||
mz_crypt_sha *sha = (mz_crypt_sha *)handle;
|
||||
|
||||
if (sha == NULL || buf == NULL || !sha->initialized)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
if (sha->algorithm == MZ_HASH_SHA1)
|
||||
sha->error = CC_SHA1_Update(&sha->ctx1, buf, size);
|
||||
else
|
||||
sha->error = CC_SHA256_Update(&sha->ctx256, buf, size);
|
||||
|
||||
if (!sha->error)
|
||||
return MZ_HASH_ERROR;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_sha_end(void *handle, uint8_t *digest, int32_t digest_size) {
|
||||
mz_crypt_sha *sha = (mz_crypt_sha *)handle;
|
||||
|
||||
if (sha == NULL || digest == NULL || !sha->initialized)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
if (sha->algorithm == MZ_HASH_SHA1) {
|
||||
if (digest_size < MZ_HASH_SHA1_SIZE)
|
||||
return MZ_BUF_ERROR;
|
||||
sha->error = CC_SHA1_Final(digest, &sha->ctx1);
|
||||
} else {
|
||||
if (digest_size < MZ_HASH_SHA256_SIZE)
|
||||
return MZ_BUF_ERROR;
|
||||
sha->error = CC_SHA256_Final(digest, &sha->ctx256);
|
||||
}
|
||||
|
||||
if (!sha->error)
|
||||
return MZ_HASH_ERROR;
|
||||
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
void mz_crypt_sha_set_algorithm(void *handle, uint16_t algorithm) {
|
||||
mz_crypt_sha *sha = (mz_crypt_sha *)handle;
|
||||
sha->algorithm = algorithm;
|
||||
}
|
||||
|
||||
void *mz_crypt_sha_create(void **handle) {
|
||||
mz_crypt_sha *sha = NULL;
|
||||
|
||||
sha = (mz_crypt_sha *)MZ_ALLOC(sizeof(mz_crypt_sha));
|
||||
if (sha != NULL) {
|
||||
memset(sha, 0, sizeof(mz_crypt_sha));
|
||||
sha->algorithm = MZ_HASH_SHA256;
|
||||
}
|
||||
if (handle != NULL)
|
||||
*handle = sha;
|
||||
|
||||
return sha;
|
||||
}
|
||||
|
||||
void mz_crypt_sha_delete(void **handle) {
|
||||
mz_crypt_sha *sha = NULL;
|
||||
if (handle == NULL)
|
||||
return;
|
||||
sha = (mz_crypt_sha *)*handle;
|
||||
if (sha != NULL) {
|
||||
mz_crypt_sha_reset(*handle);
|
||||
MZ_FREE(sha);
|
||||
}
|
||||
*handle = NULL;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct mz_crypt_aes_s {
|
||||
CCCryptorRef crypt;
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
} mz_crypt_aes;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
void mz_crypt_aes_reset(void *handle) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
|
||||
if (aes->crypt != NULL)
|
||||
CCCryptorRelease(aes->crypt);
|
||||
aes->crypt = NULL;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_aes_encrypt(void *handle, uint8_t *buf, int32_t size) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
size_t data_moved = 0;
|
||||
|
||||
if (aes == NULL || buf == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
if (size != MZ_AES_BLOCK_SIZE)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
aes->error = CCCryptorUpdate(aes->crypt, buf, size, buf, size, &data_moved);
|
||||
|
||||
if (aes->error != kCCSuccess)
|
||||
return MZ_HASH_ERROR;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_aes_decrypt(void *handle, uint8_t *buf, int32_t size) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
size_t data_moved = 0;
|
||||
|
||||
if (aes == NULL || buf == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
if (size != MZ_AES_BLOCK_SIZE)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
aes->error = CCCryptorUpdate(aes->crypt, buf, size, buf, size, &data_moved);
|
||||
|
||||
if (aes->error != kCCSuccess)
|
||||
return MZ_HASH_ERROR;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_length) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
|
||||
|
||||
if (aes == NULL || key == NULL || key_length == 0)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
mz_crypt_aes_reset(handle);
|
||||
|
||||
aes->error = CCCryptorCreate(kCCEncrypt, kCCAlgorithmAES, kCCOptionECBMode,
|
||||
key, key_length, NULL, &aes->crypt);
|
||||
|
||||
if (aes->error != kCCSuccess)
|
||||
return MZ_HASH_ERROR;
|
||||
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_length) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
|
||||
|
||||
if (aes == NULL || key == NULL || key_length == 0)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
mz_crypt_aes_reset(handle);
|
||||
|
||||
aes->error = CCCryptorCreate(kCCDecrypt, kCCAlgorithmAES, kCCOptionECBMode,
|
||||
key, key_length, NULL, &aes->crypt);
|
||||
|
||||
if (aes->error != kCCSuccess)
|
||||
return MZ_HASH_ERROR;
|
||||
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
void mz_crypt_aes_set_mode(void *handle, int32_t mode) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
aes->mode = mode;
|
||||
}
|
||||
|
||||
void *mz_crypt_aes_create(void **handle) {
|
||||
mz_crypt_aes *aes = NULL;
|
||||
|
||||
aes = (mz_crypt_aes *)MZ_ALLOC(sizeof(mz_crypt_aes));
|
||||
if (aes != NULL)
|
||||
memset(aes, 0, sizeof(mz_crypt_aes));
|
||||
if (handle != NULL)
|
||||
*handle = aes;
|
||||
|
||||
return aes;
|
||||
}
|
||||
|
||||
void mz_crypt_aes_delete(void **handle) {
|
||||
mz_crypt_aes *aes = NULL;
|
||||
if (handle == NULL)
|
||||
return;
|
||||
aes = (mz_crypt_aes *)*handle;
|
||||
if (aes != NULL) {
|
||||
mz_crypt_aes_reset(*handle);
|
||||
MZ_FREE(aes);
|
||||
}
|
||||
*handle = NULL;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct mz_crypt_hmac_s {
|
||||
CCHmacContext ctx;
|
||||
int32_t initialized;
|
||||
int32_t error;
|
||||
uint16_t algorithm;
|
||||
} mz_crypt_hmac;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static void mz_crypt_hmac_free(void *handle) {
|
||||
mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle;
|
||||
memset(&hmac->ctx, 0, sizeof(hmac->ctx));
|
||||
}
|
||||
|
||||
void mz_crypt_hmac_reset(void *handle) {
|
||||
mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle;
|
||||
mz_crypt_hmac_free(handle);
|
||||
hmac->error = 0;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length) {
|
||||
mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle;
|
||||
CCHmacAlgorithm algorithm = 0;
|
||||
|
||||
if (hmac == NULL || key == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
mz_crypt_hmac_reset(handle);
|
||||
|
||||
if (hmac->algorithm == MZ_HASH_SHA1)
|
||||
algorithm = kCCHmacAlgSHA1;
|
||||
else if (hmac->algorithm == MZ_HASH_SHA256)
|
||||
algorithm = kCCHmacAlgSHA256;
|
||||
else
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
CCHmacInit(&hmac->ctx, algorithm, key, key_length);
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_hmac_update(void *handle, const void *buf, int32_t size) {
|
||||
mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle;
|
||||
|
||||
if (hmac == NULL || buf == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
CCHmacUpdate(&hmac->ctx, buf, size);
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_hmac_end(void *handle, uint8_t *digest, int32_t digest_size) {
|
||||
mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle;
|
||||
|
||||
if (hmac == NULL || digest == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
if (hmac->algorithm == MZ_HASH_SHA1) {
|
||||
if (digest_size < MZ_HASH_SHA1_SIZE)
|
||||
return MZ_BUF_ERROR;
|
||||
CCHmacFinal(&hmac->ctx, digest);
|
||||
} else {
|
||||
if (digest_size < MZ_HASH_SHA256_SIZE)
|
||||
return MZ_BUF_ERROR;
|
||||
CCHmacFinal(&hmac->ctx, digest);
|
||||
}
|
||||
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
void mz_crypt_hmac_set_algorithm(void *handle, uint16_t algorithm) {
|
||||
mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle;
|
||||
hmac->algorithm = algorithm;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_hmac_copy(void *src_handle, void *target_handle) {
|
||||
mz_crypt_hmac *source = (mz_crypt_hmac *)src_handle;
|
||||
mz_crypt_hmac *target = (mz_crypt_hmac *)target_handle;
|
||||
|
||||
if (source == NULL || target == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
memcpy(&target->ctx, &source->ctx, sizeof(CCHmacContext));
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
void *mz_crypt_hmac_create(void **handle) {
|
||||
mz_crypt_hmac *hmac = NULL;
|
||||
|
||||
hmac = (mz_crypt_hmac *)MZ_ALLOC(sizeof(mz_crypt_hmac));
|
||||
if (hmac != NULL) {
|
||||
memset(hmac, 0, sizeof(mz_crypt_hmac));
|
||||
hmac->algorithm = MZ_HASH_SHA256;
|
||||
}
|
||||
if (handle != NULL)
|
||||
*handle = hmac;
|
||||
|
||||
return hmac;
|
||||
}
|
||||
|
||||
void mz_crypt_hmac_delete(void **handle) {
|
||||
mz_crypt_hmac *hmac = NULL;
|
||||
if (handle == NULL)
|
||||
return;
|
||||
hmac = (mz_crypt_hmac *)*handle;
|
||||
if (hmac != NULL) {
|
||||
mz_crypt_hmac_free(*handle);
|
||||
MZ_FREE(hmac);
|
||||
}
|
||||
*handle = NULL;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#if defined(MZ_ZIP_SIGNING)
|
||||
int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size,
|
||||
const char *cert_pwd, uint8_t **signature, int32_t *signature_size) {
|
||||
CFStringRef password_ref = NULL;
|
||||
CFDictionaryRef options_dict = NULL;
|
||||
CFDictionaryRef identity_trust = NULL;
|
||||
CFDataRef signature_out = NULL;
|
||||
CFDataRef pkcs12_data = NULL;
|
||||
CFArrayRef items = 0;
|
||||
SecIdentityRef identity = NULL;
|
||||
SecTrustRef trust = NULL;
|
||||
OSStatus status = noErr;
|
||||
const void *options_key[2] = { kSecImportExportPassphrase, kSecReturnRef };
|
||||
const void *options_values[2] = { 0, kCFBooleanTrue };
|
||||
int32_t err = MZ_SIGN_ERROR;
|
||||
|
||||
|
||||
if (message == NULL || cert_data == NULL || signature == NULL || signature_size == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
*signature = NULL;
|
||||
*signature_size = 0;
|
||||
|
||||
password_ref = CFStringCreateWithCString(0, cert_pwd, kCFStringEncodingUTF8);
|
||||
options_values[0] = password_ref;
|
||||
|
||||
options_dict = CFDictionaryCreate(0, options_key, options_values, 2, 0, 0);
|
||||
if (options_dict)
|
||||
pkcs12_data = CFDataCreate(0, cert_data, cert_data_size);
|
||||
if (pkcs12_data)
|
||||
status = SecPKCS12Import(pkcs12_data, options_dict, &items);
|
||||
if (status == noErr)
|
||||
identity_trust = CFArrayGetValueAtIndex(items, 0);
|
||||
if (identity_trust)
|
||||
identity = (SecIdentityRef)CFDictionaryGetValue(identity_trust, kSecImportItemIdentity);
|
||||
if (identity)
|
||||
trust = (SecTrustRef)CFDictionaryGetValue(identity_trust, kSecImportItemTrust);
|
||||
if (trust) {
|
||||
status = CMSEncodeContent(identity, NULL, NULL, FALSE, 0, message, message_size, &signature_out);
|
||||
|
||||
if (status == errSecSuccess) {
|
||||
*signature_size = CFDataGetLength(signature_out);
|
||||
*signature = (uint8_t *)MZ_ALLOC(*signature_size);
|
||||
|
||||
memcpy(*signature, CFDataGetBytePtr(signature_out), *signature_size);
|
||||
|
||||
err = MZ_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (signature_out)
|
||||
CFRelease(signature_out);
|
||||
if (items)
|
||||
CFRelease(items);
|
||||
if (pkcs12_data)
|
||||
CFRelease(pkcs12_data);
|
||||
if (options_dict)
|
||||
CFRelease(options_dict);
|
||||
if (password_ref)
|
||||
CFRelease(password_ref);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int32_t mz_crypt_sign_verify(uint8_t *message, int32_t message_size, uint8_t *signature, int32_t signature_size) {
|
||||
CMSDecoderRef decoder = NULL;
|
||||
CMSSignerStatus signer_status = 0;
|
||||
CFDataRef message_out = NULL;
|
||||
SecPolicyRef trust_policy = NULL;
|
||||
OSStatus status = noErr;
|
||||
OSStatus verify_status = noErr;
|
||||
size_t signer_count = 0;
|
||||
size_t i = 0;
|
||||
int32_t err = MZ_SIGN_ERROR;
|
||||
|
||||
if (message == NULL || signature == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
status = CMSDecoderCreate(&decoder);
|
||||
if (status == errSecSuccess)
|
||||
status = CMSDecoderUpdateMessage(decoder, signature, signature_size);
|
||||
if (status == errSecSuccess)
|
||||
status = CMSDecoderFinalizeMessage(decoder);
|
||||
if (status == errSecSuccess)
|
||||
trust_policy = SecPolicyCreateBasicX509();
|
||||
|
||||
if (status == errSecSuccess && trust_policy) {
|
||||
CMSDecoderGetNumSigners(decoder, &signer_count);
|
||||
if (signer_count > 0)
|
||||
err = MZ_OK;
|
||||
for (i = 0; i < signer_count; i += 1) {
|
||||
status = CMSDecoderCopySignerStatus(decoder, i, trust_policy, TRUE, &signer_status, NULL, &verify_status);
|
||||
if (status != errSecSuccess || verify_status != 0 || signer_status != kCMSSignerValid) {
|
||||
err = MZ_SIGN_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (err == MZ_OK) {
|
||||
status = CMSDecoderCopyContent(decoder, &message_out);
|
||||
if ((status != errSecSuccess) ||
|
||||
(CFDataGetLength(message_out) != message_size) ||
|
||||
(memcmp(message, CFDataGetBytePtr(message_out), message_size) != 0))
|
||||
err = MZ_SIGN_ERROR;
|
||||
}
|
||||
|
||||
if (trust_policy)
|
||||
CFRelease(trust_policy);
|
||||
if (decoder)
|
||||
CFRelease(decoder);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user