libwz 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/binding.gyp +149 -0
- package/deps/tiny-aes/.github/workflows/c-cpp.yml +27 -0
- package/deps/tiny-aes/CMakeLists.txt +17 -0
- package/deps/tiny-aes/Makefile +61 -0
- package/deps/tiny-aes/README.md +83 -0
- package/deps/tiny-aes/aes.c +572 -0
- package/deps/tiny-aes/aes.h +91 -0
- package/deps/tiny-aes/aes.hpp +12 -0
- package/deps/tiny-aes/conanfile.py +73 -0
- package/deps/tiny-aes/library.json +19 -0
- package/deps/tiny-aes/library.properties +11 -0
- package/deps/tiny-aes/test.c +316 -0
- package/deps/tiny-aes/test.cpp +2 -0
- package/deps/tiny-aes/test_package/CMakeLists.txt +11 -0
- package/deps/tiny-aes/test_package/conanfile.py +17 -0
- package/deps/tiny-aes/unlicense.txt +24 -0
- package/deps/zlib/.cmake-format.yaml +245 -0
- package/deps/zlib/.github/workflows/c-std.yml +268 -0
- package/deps/zlib/.github/workflows/cmake.yml +147 -0
- package/deps/zlib/.github/workflows/configure.yml +146 -0
- package/deps/zlib/.github/workflows/contribs.yml +64 -0
- package/deps/zlib/.github/workflows/fuzz.yml +25 -0
- package/deps/zlib/.github/workflows/msys-cygwin.yml +92 -0
- package/deps/zlib/.github/workflows/others.yml +153 -0
- package/deps/zlib/BUILD.bazel +134 -0
- package/deps/zlib/CMakeLists.txt +310 -0
- package/deps/zlib/ChangeLog +1669 -0
- package/deps/zlib/FAQ +371 -0
- package/deps/zlib/INDEX +67 -0
- package/deps/zlib/LICENSE +22 -0
- package/deps/zlib/MODULE.bazel +9 -0
- package/deps/zlib/Makefile.in +426 -0
- package/deps/zlib/README +115 -0
- package/deps/zlib/README-cmake.md +79 -0
- package/deps/zlib/adler32.c +164 -0
- package/deps/zlib/amiga/Makefile.pup +69 -0
- package/deps/zlib/amiga/Makefile.sas +68 -0
- package/deps/zlib/compress.c +99 -0
- package/deps/zlib/configure +1078 -0
- package/deps/zlib/contrib/CMakeLists.txt +61 -0
- package/deps/zlib/contrib/README.contrib +57 -0
- package/deps/zlib/contrib/ada/CMakeLists.txt +217 -0
- package/deps/zlib/contrib/ada/buffer_demo.adb +106 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADACompiler.cmake.in +23 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADAInformation.cmake +133 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeDetermineADACompiler.cmake +33 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeTestADACompiler.cmake +46 -0
- package/deps/zlib/contrib/ada/cmake/binder_helper.cmake +47 -0
- package/deps/zlib/contrib/ada/cmake/compile_helper.cmake +32 -0
- package/deps/zlib/contrib/ada/cmake/exe_link_helper.cmake +53 -0
- package/deps/zlib/contrib/ada/cmake/shared_link_helper.cmake +52 -0
- package/deps/zlib/contrib/ada/cmake/static_link_helper.cmake +25 -0
- package/deps/zlib/contrib/ada/mtest.adb +156 -0
- package/deps/zlib/contrib/ada/read.adb +156 -0
- package/deps/zlib/contrib/ada/readme.txt +65 -0
- package/deps/zlib/contrib/ada/test.adb +463 -0
- package/deps/zlib/contrib/ada/zlib-streams.adb +225 -0
- package/deps/zlib/contrib/ada/zlib-streams.ads +114 -0
- package/deps/zlib/contrib/ada/zlib-thin.adb +142 -0
- package/deps/zlib/contrib/ada/zlib-thin.ads +450 -0
- package/deps/zlib/contrib/ada/zlib.adb +701 -0
- package/deps/zlib/contrib/ada/zlib.ads +328 -0
- package/deps/zlib/contrib/ada/zlib.gpr +20 -0
- package/deps/zlib/contrib/blast/CMakeLists.txt +166 -0
- package/deps/zlib/contrib/blast/Makefile +14 -0
- package/deps/zlib/contrib/blast/README +4 -0
- package/deps/zlib/contrib/blast/blast-test.c +42 -0
- package/deps/zlib/contrib/blast/blast.c +422 -0
- package/deps/zlib/contrib/blast/blast.h +84 -0
- package/deps/zlib/contrib/blast/blastConfig.cmake.in +18 -0
- package/deps/zlib/contrib/blast/test/CMakeLists.txt +193 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/blast/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test.pk +0 -0
- package/deps/zlib/contrib/blast/test.txt +1 -0
- package/deps/zlib/contrib/blast/tester.cmake +28 -0
- package/deps/zlib/contrib/crc32vx/CMakeLists.txt +67 -0
- package/deps/zlib/contrib/crc32vx/README +9 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx.c +254 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx_hooks.h +9 -0
- package/deps/zlib/contrib/delphi/ZLib.pas +557 -0
- package/deps/zlib/contrib/delphi/ZLibConst.pas +11 -0
- package/deps/zlib/contrib/delphi/readme.txt +76 -0
- package/deps/zlib/contrib/delphi/zlibd32.mak +99 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs +202 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs +83 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CodecBase.cs +198 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Deflater.cs +106 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.cs +288 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj +141 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/GZipStream.cs +301 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Inflater.cs +105 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/UnitTests.cs +274 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.build +33 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.chm +0 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.sln +21 -0
- package/deps/zlib/contrib/dotzlib/LICENSE_1_0.txt +23 -0
- package/deps/zlib/contrib/dotzlib/readme.txt +58 -0
- package/deps/zlib/contrib/gcc_gvmat64/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/gcc_gvmat64/gvmat64.S +570 -0
- package/deps/zlib/contrib/infback9/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/infback9/README +1 -0
- package/deps/zlib/contrib/infback9/infback9.c +603 -0
- package/deps/zlib/contrib/infback9/infback9.h +37 -0
- package/deps/zlib/contrib/infback9/inffix9.h +107 -0
- package/deps/zlib/contrib/infback9/inflate9.h +47 -0
- package/deps/zlib/contrib/infback9/inftree9.c +319 -0
- package/deps/zlib/contrib/infback9/inftree9.h +61 -0
- package/deps/zlib/contrib/iostream/test.cpp +24 -0
- package/deps/zlib/contrib/iostream/zfstream.cpp +329 -0
- package/deps/zlib/contrib/iostream/zfstream.h +128 -0
- package/deps/zlib/contrib/iostream2/zstream.h +306 -0
- package/deps/zlib/contrib/iostream2/zstream_test.cpp +25 -0
- package/deps/zlib/contrib/iostream3/CMakeLists.txt +200 -0
- package/deps/zlib/contrib/iostream3/README +35 -0
- package/deps/zlib/contrib/iostream3/TODO +17 -0
- package/deps/zlib/contrib/iostream3/iostream3Config.cmake.in +23 -0
- package/deps/zlib/contrib/iostream3/test/CMakeLists.txt +191 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/iostream3/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test.cc +50 -0
- package/deps/zlib/contrib/iostream3/zfstream.cc +479 -0
- package/deps/zlib/contrib/iostream3/zfstream.h +466 -0
- package/deps/zlib/contrib/minizip/CMakeLists.txt +387 -0
- package/deps/zlib/contrib/minizip/LICENSE.Info-Zip +58 -0
- package/deps/zlib/contrib/minizip/Makefile +33 -0
- package/deps/zlib/contrib/minizip/Makefile.am +45 -0
- package/deps/zlib/contrib/minizip/MiniZip64_Changes.txt +6 -0
- package/deps/zlib/contrib/minizip/MiniZip64_info.txt +69 -0
- package/deps/zlib/contrib/minizip/configure.ac +32 -0
- package/deps/zlib/contrib/minizip/crypt.h +125 -0
- package/deps/zlib/contrib/minizip/ints.h +57 -0
- package/deps/zlib/contrib/minizip/ioapi.c +231 -0
- package/deps/zlib/contrib/minizip/ioapi.h +183 -0
- package/deps/zlib/contrib/minizip/iowin32.c +447 -0
- package/deps/zlib/contrib/minizip/iowin32.h +27 -0
- package/deps/zlib/contrib/minizip/make_vms.com +25 -0
- package/deps/zlib/contrib/minizip/miniunz.c +647 -0
- package/deps/zlib/contrib/minizip/miniunzip.1 +63 -0
- package/deps/zlib/contrib/minizip/minizip.1 +46 -0
- package/deps/zlib/contrib/minizip/minizip.c +511 -0
- package/deps/zlib/contrib/minizip/minizip.pc.in +13 -0
- package/deps/zlib/contrib/minizip/minizip.pc.txt +13 -0
- package/deps/zlib/contrib/minizip/minizipConfig.cmake.in +27 -0
- package/deps/zlib/contrib/minizip/mztools.c +294 -0
- package/deps/zlib/contrib/minizip/mztools.h +37 -0
- package/deps/zlib/contrib/minizip/skipset.h +366 -0
- package/deps/zlib/contrib/minizip/test/CMakeLists.txt +176 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/contrib/minizip/test/find_package_no_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_wrong_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/test_helper.cm +32 -0
- package/deps/zlib/contrib/minizip/unzip.c +1984 -0
- package/deps/zlib/contrib/minizip/unzip.h +442 -0
- package/deps/zlib/contrib/minizip/zip.c +2246 -0
- package/deps/zlib/contrib/minizip/zip.h +371 -0
- package/deps/zlib/contrib/nuget/nuget.csproj +45 -0
- package/deps/zlib/contrib/nuget/nuget.sln +22 -0
- package/deps/zlib/contrib/pascal/example.pas +599 -0
- package/deps/zlib/contrib/pascal/readme.txt +76 -0
- package/deps/zlib/contrib/pascal/zlibd32.mak +99 -0
- package/deps/zlib/contrib/pascal/zlibpas.pas +276 -0
- package/deps/zlib/contrib/puff/CMakeLists.txt +154 -0
- package/deps/zlib/contrib/puff/Makefile +42 -0
- package/deps/zlib/contrib/puff/README +63 -0
- package/deps/zlib/contrib/puff/bin-writer.c +26 -0
- package/deps/zlib/contrib/puff/puff.c +840 -0
- package/deps/zlib/contrib/puff/puff.h +35 -0
- package/deps/zlib/contrib/puff/puffConfig.cmake.in +18 -0
- package/deps/zlib/contrib/puff/pufftest.c +168 -0
- package/deps/zlib/contrib/puff/test/CMakeLists.txt +262 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_exclude_test.cmake.in +26 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/puff/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/tester-cov.cmake +58 -0
- package/deps/zlib/contrib/puff/test/tester.cmake +16 -0
- package/deps/zlib/contrib/puff/zeros.raw +0 -0
- package/deps/zlib/contrib/testzlib/CMakeLists.txt +44 -0
- package/deps/zlib/contrib/testzlib/testzlib.c +275 -0
- package/deps/zlib/contrib/testzlib/testzlib.txt +10 -0
- package/deps/zlib/contrib/vstudio/readme.txt +22 -0
- package/deps/zlib/contrib/zlib1-dll/CMakeLists.txt +196 -0
- package/deps/zlib/contrib/zlib1-dll/readme.txt +21 -0
- package/deps/zlib/crc32.c +983 -0
- package/deps/zlib/crc32.h +9446 -0
- package/deps/zlib/deflate.c +2185 -0
- package/deps/zlib/deflate.h +383 -0
- package/deps/zlib/doc/algorithm.txt +209 -0
- package/deps/zlib/doc/crc-doc.1.0.pdf +0 -0
- package/deps/zlib/doc/rfc1950.txt +619 -0
- package/deps/zlib/doc/rfc1951.txt +955 -0
- package/deps/zlib/doc/rfc1952.txt +675 -0
- package/deps/zlib/doc/txtvsbin.txt +107 -0
- package/deps/zlib/examples/README.examples +54 -0
- package/deps/zlib/examples/enough.c +597 -0
- package/deps/zlib/examples/fitblk.c +233 -0
- package/deps/zlib/examples/gun.c +702 -0
- package/deps/zlib/examples/gzappend.c +504 -0
- package/deps/zlib/examples/gzjoin.c +449 -0
- package/deps/zlib/examples/gzlog.c +1061 -0
- package/deps/zlib/examples/gzlog.h +91 -0
- package/deps/zlib/examples/gznorm.c +474 -0
- package/deps/zlib/examples/zlib_how.html +550 -0
- package/deps/zlib/examples/zpipe.c +206 -0
- package/deps/zlib/examples/zran.c +546 -0
- package/deps/zlib/examples/zran.h +53 -0
- package/deps/zlib/gzclose.c +23 -0
- package/deps/zlib/gzguts.h +216 -0
- package/deps/zlib/gzlib.c +609 -0
- package/deps/zlib/gzread.c +668 -0
- package/deps/zlib/gzwrite.c +700 -0
- package/deps/zlib/infback.c +581 -0
- package/deps/zlib/inffast.c +321 -0
- package/deps/zlib/inffast.h +11 -0
- package/deps/zlib/inffixed.h +94 -0
- package/deps/zlib/inflate.c +1413 -0
- package/deps/zlib/inflate.h +126 -0
- package/deps/zlib/inftrees.c +424 -0
- package/deps/zlib/inftrees.h +64 -0
- package/deps/zlib/make_vms.com +867 -0
- package/deps/zlib/msdos/Makefile.bor +115 -0
- package/deps/zlib/msdos/Makefile.dj2 +104 -0
- package/deps/zlib/msdos/Makefile.emx +69 -0
- package/deps/zlib/msdos/Makefile.msc +112 -0
- package/deps/zlib/msdos/Makefile.tc +100 -0
- package/deps/zlib/os400/README400 +48 -0
- package/deps/zlib/os400/bndsrc +144 -0
- package/deps/zlib/os400/make.sh +383 -0
- package/deps/zlib/os400/zlibfixed.rpgle +578 -0
- package/deps/zlib/os400/zlibfree.rpgle +634 -0
- package/deps/zlib/qnx/package.qpg +141 -0
- package/deps/zlib/test/CMakeLists.txt +318 -0
- package/deps/zlib/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/test/example.c +552 -0
- package/deps/zlib/test/find_package_no_components_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_wrong_components_test.cmake.in +27 -0
- package/deps/zlib/test/infcover.c +672 -0
- package/deps/zlib/test/minigzip.c +592 -0
- package/deps/zlib/treebuild.xml +116 -0
- package/deps/zlib/trees.c +1119 -0
- package/deps/zlib/trees.h +128 -0
- package/deps/zlib/uncompr.c +101 -0
- package/deps/zlib/watcom/watcom_f.mak +43 -0
- package/deps/zlib/watcom/watcom_l.mak +43 -0
- package/deps/zlib/win32/DLL_FAQ.txt +381 -0
- package/deps/zlib/win32/Makefile.bor +109 -0
- package/deps/zlib/win32/Makefile.gcc +177 -0
- package/deps/zlib/win32/Makefile.msc +159 -0
- package/deps/zlib/win32/README-WIN32.txt +103 -0
- package/deps/zlib/win32/VisualC.txt +3 -0
- package/deps/zlib/win32/zlib.def +104 -0
- package/deps/zlib/win32/zlib1.rc +37 -0
- package/deps/zlib/zconf.h.in +551 -0
- package/deps/zlib/zlib.3 +149 -0
- package/deps/zlib/zlib.3.pdf +0 -0
- package/deps/zlib/zlib.h +2057 -0
- package/deps/zlib/zlib.map +116 -0
- package/deps/zlib/zlib.pc.cmakein +14 -0
- package/deps/zlib/zlib.pc.in +14 -0
- package/deps/zlib/zlibConfig.cmake.in +18 -0
- package/deps/zlib/zutil.c +313 -0
- package/deps/zlib/zutil.h +331 -0
- package/dist/index.d.ts +266 -0
- package/dist/index.js +1146 -0
- package/dist/libwz.js +5632 -0
- package/dist/libwz.wasm +0 -0
- package/include/wz/CRC32.h +182 -0
- package/include/wz/PngUtility.h +72 -0
- package/include/wz/PortalType.h +124 -0
- package/include/wz/Properties/WzBinaryProperty.h +70 -0
- package/include/wz/Properties/WzCanvasProperty.h +55 -0
- package/include/wz/Properties/WzConvexProperty.h +34 -0
- package/include/wz/Properties/WzDoubleProperty.h +32 -0
- package/include/wz/Properties/WzFloatProperty.h +30 -0
- package/include/wz/Properties/WzIntProperty.h +30 -0
- package/include/wz/Properties/WzLongProperty.h +30 -0
- package/include/wz/Properties/WzLuaProperty.h +31 -0
- package/include/wz/Properties/WzNullProperty.h +15 -0
- package/include/wz/Properties/WzPngProperty.h +53 -0
- package/include/wz/Properties/WzRawDataProperty.h +46 -0
- package/include/wz/Properties/WzShortProperty.h +31 -0
- package/include/wz/Properties/WzStringProperty.h +32 -0
- package/include/wz/Properties/WzSubProperty.h +35 -0
- package/include/wz/Properties/WzUOLProperty.h +44 -0
- package/include/wz/Properties/WzVectorProperty.h +40 -0
- package/include/wz/Properties/WzVideoProperty.h +43 -0
- package/include/wz/Result.h +58 -0
- package/include/wz/Util/Defines.h +16 -0
- package/include/wz/Util/ListFileParser.h +20 -0
- package/include/wz/Util/WzBinaryReader.h +95 -0
- package/include/wz/Util/WzBinaryWriter.h +72 -0
- package/include/wz/Util/WzBlobDataSource.h +30 -0
- package/include/wz/Util/WzDataSource.h +49 -0
- package/include/wz/Util/WzKeyGenerator.h +28 -0
- package/include/wz/Util/WzMutableKey.h +39 -0
- package/include/wz/Util/WzPath.h +37 -0
- package/include/wz/Util/WzStream.h +86 -0
- package/include/wz/Util/WzTool.h +42 -0
- package/include/wz/WzAESConstant.h +17 -0
- package/include/wz/WzDirectory.h +97 -0
- package/include/wz/WzEnums.h +76 -0
- package/include/wz/WzFile.h +99 -0
- package/include/wz/WzHeader.h +47 -0
- package/include/wz/WzImage.h +97 -0
- package/include/wz/WzImageProperty.h +92 -0
- package/include/wz/WzObject.h +55 -0
- package/include/wz/WzPropertyCollection.h +115 -0
- package/include/wz/wz.h +41 -0
- package/include/wz/wz_api.h +432 -0
- package/package.json +93 -0
- package/src/PngUtility.cpp +328 -0
- package/src/Properties/WzBinaryProperty.cpp +183 -0
- package/src/Properties/WzCanvasProperty.cpp +262 -0
- package/src/Properties/WzConvexProperty.cpp +159 -0
- package/src/Properties/WzDoubleProperty.cpp +12 -0
- package/src/Properties/WzFloatProperty.cpp +17 -0
- package/src/Properties/WzIntProperty.cpp +12 -0
- package/src/Properties/WzLongProperty.cpp +12 -0
- package/src/Properties/WzLuaProperty.cpp +37 -0
- package/src/Properties/WzNullProperty.cpp +11 -0
- package/src/Properties/WzPngProperty.cpp +637 -0
- package/src/Properties/WzRawDataProperty.cpp +116 -0
- package/src/Properties/WzShortProperty.cpp +12 -0
- package/src/Properties/WzStringProperty.cpp +44 -0
- package/src/Properties/WzSubProperty.cpp +129 -0
- package/src/Properties/WzUOLProperty.cpp +136 -0
- package/src/Properties/WzVectorProperty.cpp +22 -0
- package/src/Properties/WzVideoProperty.cpp +115 -0
- package/src/Util/ListFileParser.cpp +48 -0
- package/src/Util/WzBinaryReader.cpp +368 -0
- package/src/Util/WzBinaryWriter.cpp +305 -0
- package/src/Util/WzBlobDataSource.cpp +47 -0
- package/src/Util/WzDataSource.cpp +61 -0
- package/src/Util/WzKeyGenerator.cpp +43 -0
- package/src/Util/WzMutableKey.cpp +59 -0
- package/src/Util/WzStream.cpp +196 -0
- package/src/Util/WzTool.cpp +266 -0
- package/src/WzAESConstant.cpp +12 -0
- package/src/WzDirectory.cpp +669 -0
- package/src/WzEnums.cpp +20 -0
- package/src/WzFile.cpp +450 -0
- package/src/WzImage.cpp +350 -0
- package/src/WzImageProperty.cpp +469 -0
- package/src/WzObject.cpp +174 -0
- package/src/WzPropertyCollection.cpp +84 -0
- package/src/capi/wz_api.cpp +1996 -0
- package/src/node/binding.cpp +1776 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Toyobayashi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# libwz
|
|
2
|
+
|
|
3
|
+
> ⚠️ **Vibe Coding / Clean-room Reimplementation / Under Development**
|
|
4
|
+
> This project was developed with significant AI assistance (GitHub Copilot).
|
|
5
|
+
> It is an independent C++ reimplementation — no code was copied from the
|
|
6
|
+
> C# reference (included as a submodule for test data only).
|
|
7
|
+
|
|
8
|
+
A native C++ library for reading and parsing **MapleStory `.wz` game data files**.
|
|
9
|
+
Provides C API for FFI consumers and JNI bindings for Java/Kotlin.
|
|
10
|
+
|
|
11
|
+
<!-- [](https://github.com/toyobayashi/libwz/actions/workflows/build.yml) -->
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- Decrypt and parse PKG1-format `.wz` archives across all major MapleStory
|
|
16
|
+
regions (GMS, EMS, BMS, Classic, Custom)
|
|
17
|
+
- Support for 32-bit and 64-bit WZ file versions
|
|
18
|
+
- Hierarchical directory/image traversal with all 16 property types
|
|
19
|
+
- Image decompression: DXT3, DXT5, BGRA4444, ARGB1555, RGB565, Form517
|
|
20
|
+
- UOL (link) property resolution with cross-file traversal
|
|
21
|
+
- Audio extraction (MP3/WAV) from Sound properties
|
|
22
|
+
- Lua script decoding
|
|
23
|
+
- PNG export from Canvas properties
|
|
24
|
+
- C API (`wz_api.h`) for FFI consumers (Python, Node.js, etc.)
|
|
25
|
+
- JNI bindings for Java/Kotlin consumers
|
|
26
|
+
- Java wrapper classes with `AutoCloseable` resource management
|
|
27
|
+
- Node.js native addon and WebAssembly package entries for JavaScript users
|
|
28
|
+
|
|
29
|
+
## Requirements
|
|
30
|
+
|
|
31
|
+
- **C++23** compiler with `<expected>` support
|
|
32
|
+
- **CMake 3.16+**
|
|
33
|
+
- **Git** (for submodules)
|
|
34
|
+
|
|
35
|
+
## Quick Start — C++
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
git clone --recurse-submodules https://github.com/toyobayashi/libwz.git
|
|
39
|
+
cd libwz
|
|
40
|
+
|
|
41
|
+
cmake -B build -DCMAKE_BUILD_TYPE=Release
|
|
42
|
+
cmake --build build
|
|
43
|
+
|
|
44
|
+
# Run tests
|
|
45
|
+
cmake -B build -DBUILD_TESTS=ON
|
|
46
|
+
cmake --build build
|
|
47
|
+
ctest --test-dir build
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Quick Start — Java (Maven)
|
|
51
|
+
|
|
52
|
+
Add the dependency (available on Maven Central):
|
|
53
|
+
|
|
54
|
+
```xml
|
|
55
|
+
<dependency>
|
|
56
|
+
<groupId>io.github.toyobayashi</groupId>
|
|
57
|
+
<artifactId>libwz</artifactId>
|
|
58
|
+
<version>0.1.0</version>
|
|
59
|
+
</dependency>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Alternatively, from GitHub Packages (requires authentication):
|
|
63
|
+
|
|
64
|
+
```xml
|
|
65
|
+
<repository>
|
|
66
|
+
<id>github</id>
|
|
67
|
+
<url>https://maven.pkg.github.com/toyobayashi/libwz</url>
|
|
68
|
+
</repository>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Authenticate with a [GitHub personal access token](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#authenticating-to-github-packages):
|
|
72
|
+
|
|
73
|
+
```xml
|
|
74
|
+
<!-- ~/.m2/settings.xml -->
|
|
75
|
+
<server>
|
|
76
|
+
<id>github</id>
|
|
77
|
+
<username>YOUR_GITHUB_USERNAME</username>
|
|
78
|
+
<password>YOUR_GITHUB_TOKEN</password>
|
|
79
|
+
</server>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The JAR bundles native libraries for **Windows x86_64**, **Linux x86_64**,
|
|
83
|
+
and **macOS ARM64 (Apple Silicon)**. `NativeLibraryLoader` automatically
|
|
84
|
+
extracts the correct one at runtime.
|
|
85
|
+
|
|
86
|
+
## Quick Start — JavaScript / Wasm
|
|
87
|
+
|
|
88
|
+
The root `libwz` package entry uses the native Node addon in Node.js and the
|
|
89
|
+
Wasm build through the package `browser` export in browser bundlers. Both
|
|
90
|
+
entries export the same classes and constants, plus one async `init()` function
|
|
91
|
+
for the Wasm runtime.
|
|
92
|
+
|
|
93
|
+
Node.js requires `^20.19.0 || >=22.12.0`. `process.getBuiltinModule()` exists
|
|
94
|
+
in Node.js 20.16.0 and 22.3.0, but the package also relies on the modern
|
|
95
|
+
`require(esm)` interoperability that is available by default from Node.js
|
|
96
|
+
20.19.0 and 22.12.0; Node.js 24.x is covered by the `>=22.12.0` range.
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
import { init, MapleVersion, WzFile } from "libwz";
|
|
100
|
+
|
|
101
|
+
await init();
|
|
102
|
+
using file = new WzFile("Character.wz", MapleVersion.GMS);
|
|
103
|
+
file.parseWzFile();
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Pass a custom Wasm URL or path when your bundler or CDN serves the binary from
|
|
107
|
+
a different location.
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
import { init } from "libwz";
|
|
111
|
+
|
|
112
|
+
await init(new URL("./assets/libwz.wasm", import.meta.url));
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Use `getWzBindingType()` to inspect whether the active backend is `"native"` or
|
|
116
|
+
`"wasm"`. If the native addon cannot be loaded, `init()` falls back to Wasm.
|
|
117
|
+
In Node.js, pass a Wasm URL or `{ forceWasm: true }` to force the Wasm backend
|
|
118
|
+
even when the native addon is available. Path-based APIs still accept normal
|
|
119
|
+
host filesystem paths; the Wasm runtime maps them internally.
|
|
120
|
+
|
|
121
|
+
The package publishes one Wasm binary, `dist/libwz.wasm`, and no synchronous or
|
|
122
|
+
main-thread Worker wrapper entry.
|
|
123
|
+
|
|
124
|
+
## Build Options
|
|
125
|
+
|
|
126
|
+
| Option | Default | Description |
|
|
127
|
+
|--------|---------|-------------|
|
|
128
|
+
| `BUILD_TESTS` | `ON` | Build Google Test unit tests |
|
|
129
|
+
| `BUILD_CAPI` | `ON` | Build C ABI wrapper (`libwz_capi`) |
|
|
130
|
+
| `BUILD_JNI` | `OFF` | Build JNI shared library (`libwz_jni`) |
|
|
131
|
+
|
|
132
|
+
## Targets
|
|
133
|
+
|
|
134
|
+
| Target | Type | Description |
|
|
135
|
+
|--------|------|-------------|
|
|
136
|
+
| `wz` | Static | Core WZ parsing engine |
|
|
137
|
+
| `wz_capi` | Static | C ABI layer for FFI consumers |
|
|
138
|
+
| `wz_jni` | Shared | JNI native library for Java |
|
|
139
|
+
|
|
140
|
+
## Code Map
|
|
141
|
+
|
|
142
|
+
| Directory | Purpose |
|
|
143
|
+
|-----------|---------|
|
|
144
|
+
| `include/wz/` | Public C++ headers |
|
|
145
|
+
| `include/wz/Properties/` | 16 property type headers |
|
|
146
|
+
| `include/wz/Util/` | Binary reader, key gen, path utils |
|
|
147
|
+
| `include/wz/wz_api.h` | C ABI (opaque handles, no STL) |
|
|
148
|
+
| `src/` | C++ implementation files |
|
|
149
|
+
| `src/capi/` | C API implementation |
|
|
150
|
+
| `src/jni/` | JNI bindings (`wz_jni.cpp`) |
|
|
151
|
+
| `java/` | Java wrapper classes + Maven project |
|
|
152
|
+
| `tests/` | Google Test unit tests |
|
|
153
|
+
| `Harepacker-resurrected/` | C# reference (submodule, test data only) |
|
|
154
|
+
|
|
155
|
+
## Dependencies
|
|
156
|
+
|
|
157
|
+
- [tiny-AES-c](https://github.com/kokke/tiny-AES-c) — AES-256-ECB decryption
|
|
158
|
+
- [zlib](https://github.com/madler/zlib) — Image data decompression
|
|
159
|
+
- [Google Test](https://github.com/google/googletest) — Unit tests
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
MIT. The `Harepacker-resurrected/` submodule (test data reference, not part of
|
|
164
|
+
libwz source) contains code under MPL-2.0 and GPL-3.0 — see respective
|
|
165
|
+
LICENSE files in that submodule.
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "tiny_aes",
|
|
5
|
+
"type": "static_library",
|
|
6
|
+
"sources": [
|
|
7
|
+
"deps/tiny-aes/aes.c"
|
|
8
|
+
],
|
|
9
|
+
"include_dirs": [
|
|
10
|
+
"deps/tiny-aes"
|
|
11
|
+
],
|
|
12
|
+
"defines": [
|
|
13
|
+
"AES256=1"
|
|
14
|
+
],
|
|
15
|
+
"msvs_settings": {
|
|
16
|
+
"VCCLCompilerTool": {
|
|
17
|
+
"AdditionalOptions": [
|
|
18
|
+
"/utf-8"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"target_name": "zlibstatic",
|
|
25
|
+
"type": "static_library",
|
|
26
|
+
"sources": [
|
|
27
|
+
"deps/zlib/adler32.c",
|
|
28
|
+
"deps/zlib/compress.c",
|
|
29
|
+
"deps/zlib/crc32.c",
|
|
30
|
+
"deps/zlib/deflate.c",
|
|
31
|
+
"deps/zlib/gzclose.c",
|
|
32
|
+
"deps/zlib/gzlib.c",
|
|
33
|
+
"deps/zlib/gzread.c",
|
|
34
|
+
"deps/zlib/gzwrite.c",
|
|
35
|
+
"deps/zlib/infback.c",
|
|
36
|
+
"deps/zlib/inffast.c",
|
|
37
|
+
"deps/zlib/inflate.c",
|
|
38
|
+
"deps/zlib/inftrees.c",
|
|
39
|
+
"deps/zlib/trees.c",
|
|
40
|
+
"deps/zlib/uncompr.c",
|
|
41
|
+
"deps/zlib/zutil.c"
|
|
42
|
+
],
|
|
43
|
+
"include_dirs": [
|
|
44
|
+
"deps/zlib"
|
|
45
|
+
],
|
|
46
|
+
"conditions": [
|
|
47
|
+
[
|
|
48
|
+
"OS=='win'",
|
|
49
|
+
{
|
|
50
|
+
"defines": [
|
|
51
|
+
"_CRT_SECURE_NO_DEPRECATE",
|
|
52
|
+
"_CRT_NONSTDC_NO_DEPRECATE"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
"OS!='win'",
|
|
58
|
+
{
|
|
59
|
+
"defines": [
|
|
60
|
+
"HAVE_UNISTD_H"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"target_name": "wz",
|
|
68
|
+
"sources": [
|
|
69
|
+
"src/node/binding.cpp",
|
|
70
|
+
"src/WzEnums.cpp",
|
|
71
|
+
"src/WzAESConstant.cpp",
|
|
72
|
+
"src/Util/WzMutableKey.cpp",
|
|
73
|
+
"src/Util/WzKeyGenerator.cpp",
|
|
74
|
+
"src/Util/WzBinaryReader.cpp",
|
|
75
|
+
"src/Util/WzDataSource.cpp",
|
|
76
|
+
"src/Util/WzStream.cpp",
|
|
77
|
+
"src/Util/WzBinaryWriter.cpp",
|
|
78
|
+
"src/Util/WzBlobDataSource.cpp",
|
|
79
|
+
"src/Util/WzTool.cpp",
|
|
80
|
+
"src/Util/ListFileParser.cpp",
|
|
81
|
+
"src/PngUtility.cpp",
|
|
82
|
+
"src/Properties/WzNullProperty.cpp",
|
|
83
|
+
"src/Properties/WzShortProperty.cpp",
|
|
84
|
+
"src/Properties/WzIntProperty.cpp",
|
|
85
|
+
"src/Properties/WzLongProperty.cpp",
|
|
86
|
+
"src/Properties/WzFloatProperty.cpp",
|
|
87
|
+
"src/Properties/WzDoubleProperty.cpp",
|
|
88
|
+
"src/Properties/WzStringProperty.cpp",
|
|
89
|
+
"src/Properties/WzSubProperty.cpp",
|
|
90
|
+
"src/Properties/WzCanvasProperty.cpp",
|
|
91
|
+
"src/Properties/WzPngProperty.cpp",
|
|
92
|
+
"src/Properties/WzVectorProperty.cpp",
|
|
93
|
+
"src/Properties/WzConvexProperty.cpp",
|
|
94
|
+
"src/Properties/WzBinaryProperty.cpp",
|
|
95
|
+
"src/Properties/WzUOLProperty.cpp",
|
|
96
|
+
"src/Properties/WzLuaProperty.cpp",
|
|
97
|
+
"src/Properties/WzRawDataProperty.cpp",
|
|
98
|
+
"src/Properties/WzVideoProperty.cpp",
|
|
99
|
+
"src/WzFile.cpp",
|
|
100
|
+
"src/WzDirectory.cpp",
|
|
101
|
+
"src/WzImage.cpp",
|
|
102
|
+
"src/WzImageProperty.cpp",
|
|
103
|
+
"src/WzObject.cpp",
|
|
104
|
+
"src/WzPropertyCollection.cpp",
|
|
105
|
+
],
|
|
106
|
+
"include_dirs": [
|
|
107
|
+
"include",
|
|
108
|
+
"deps/tiny-aes",
|
|
109
|
+
"deps/zlib"
|
|
110
|
+
],
|
|
111
|
+
"dependencies": [
|
|
112
|
+
"tiny_aes",
|
|
113
|
+
"zlibstatic"
|
|
114
|
+
],
|
|
115
|
+
"defines": [
|
|
116
|
+
"NAPI_DISABLE_CPP_EXCEPTIONS",
|
|
117
|
+
"AES256=1",
|
|
118
|
+
"_HAS_EXCEPTIONS=0"
|
|
119
|
+
],
|
|
120
|
+
"cflags_cc!": [
|
|
121
|
+
"-std=c++20"
|
|
122
|
+
],
|
|
123
|
+
"cflags_cc": [
|
|
124
|
+
"-std=c++23",
|
|
125
|
+
"-fno-exceptions",
|
|
126
|
+
"-fno-rtti"
|
|
127
|
+
],
|
|
128
|
+
"xcode_settings": {
|
|
129
|
+
"CLANG_CXX_LANGUAGE_STANDARD": "c++23"
|
|
130
|
+
},
|
|
131
|
+
"msvs_settings": {
|
|
132
|
+
"VCCLCompilerTool": {
|
|
133
|
+
"ExceptionHandling": 0,
|
|
134
|
+
"RuntimeTypeInfo": "false",
|
|
135
|
+
"AdditionalOptions!": [
|
|
136
|
+
"-std:c++20",
|
|
137
|
+
"/std:c++20"
|
|
138
|
+
],
|
|
139
|
+
"AdditionalOptions": [
|
|
140
|
+
"/std:c++latest",
|
|
141
|
+
"/utf-8",
|
|
142
|
+
"/EHs-c-",
|
|
143
|
+
"/GR-"
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master ]
|
|
8
|
+
schedule:
|
|
9
|
+
# Run CI nightly (midnight)
|
|
10
|
+
- cron: "0 0 * * *"
|
|
11
|
+
|
|
12
|
+
# Allows you to run this workflow manually from the Actions tab
|
|
13
|
+
workflow_dispatch:
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v2
|
|
22
|
+
- name: make clean
|
|
23
|
+
run: make clean
|
|
24
|
+
- name: make
|
|
25
|
+
run: make
|
|
26
|
+
- name: make test
|
|
27
|
+
run: make test
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.12)
|
|
2
|
+
|
|
3
|
+
project(tiny-aes C)
|
|
4
|
+
|
|
5
|
+
add_library(${PROJECT_NAME} "")
|
|
6
|
+
target_sources(${PROJECT_NAME}
|
|
7
|
+
PRIVATE
|
|
8
|
+
${CMAKE_CURRENT_LIST_DIR}/aes.c
|
|
9
|
+
INTERFACE
|
|
10
|
+
${CMAKE_CURRENT_LIST_DIR}/aes.h
|
|
11
|
+
${CMAKE_CURRENT_LIST_DIR}/aes.hpp
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
target_include_directories(${PROJECT_NAME}
|
|
15
|
+
INTERFACE
|
|
16
|
+
${CMAKE_CURRENT_LIST_DIR}
|
|
17
|
+
)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#CC = avr-gcc
|
|
2
|
+
#CFLAGS = -Wall -mmcu=atmega16 -Os -Wl,-Map,test.map
|
|
3
|
+
#OBJCOPY = avr-objcopy
|
|
4
|
+
CC = gcc
|
|
5
|
+
LD = gcc
|
|
6
|
+
AR = ar
|
|
7
|
+
ARFLAGS = rcs
|
|
8
|
+
CFLAGS = -Wall -Os -c
|
|
9
|
+
LDFLAGS = -Wall -Os -Wl,-Map,test.map
|
|
10
|
+
ifdef AES192
|
|
11
|
+
CFLAGS += -DAES192=1
|
|
12
|
+
endif
|
|
13
|
+
ifdef AES256
|
|
14
|
+
CFLAGS += -DAES256=1
|
|
15
|
+
endif
|
|
16
|
+
|
|
17
|
+
OBJCOPYFLAGS = -j .text -O ihex
|
|
18
|
+
OBJCOPY = objcopy
|
|
19
|
+
|
|
20
|
+
# include path to AVR library
|
|
21
|
+
INCLUDE_PATH = /usr/lib/avr/include
|
|
22
|
+
# splint static check
|
|
23
|
+
SPLINT = splint test.c aes.c -I$(INCLUDE_PATH) +charindex -unrecog
|
|
24
|
+
|
|
25
|
+
default: test.elf
|
|
26
|
+
|
|
27
|
+
.SILENT:
|
|
28
|
+
.PHONY: lint clean
|
|
29
|
+
|
|
30
|
+
test.hex : test.elf
|
|
31
|
+
echo copy object-code to new image and format in hex
|
|
32
|
+
$(OBJCOPY) ${OBJCOPYFLAGS} $< $@
|
|
33
|
+
|
|
34
|
+
test.o : test.c aes.h aes.o
|
|
35
|
+
echo [CC] $@ $(CFLAGS)
|
|
36
|
+
$(CC) $(CFLAGS) -o $@ $<
|
|
37
|
+
|
|
38
|
+
aes.o : aes.c aes.h
|
|
39
|
+
echo [CC] $@ $(CFLAGS)
|
|
40
|
+
$(CC) $(CFLAGS) -o $@ $<
|
|
41
|
+
|
|
42
|
+
test.elf : aes.o test.o
|
|
43
|
+
echo [LD] $@
|
|
44
|
+
$(LD) $(LDFLAGS) -o $@ $^
|
|
45
|
+
|
|
46
|
+
aes.a : aes.o
|
|
47
|
+
echo [AR] $@
|
|
48
|
+
$(AR) $(ARFLAGS) $@ $^
|
|
49
|
+
|
|
50
|
+
lib : aes.a
|
|
51
|
+
|
|
52
|
+
clean:
|
|
53
|
+
rm -f *.OBJ *.LST *.o *.gch *.out *.hex *.map *.elf *.a
|
|
54
|
+
|
|
55
|
+
test:
|
|
56
|
+
make clean && make && ./test.elf
|
|
57
|
+
make clean && make AES192=1 && ./test.elf
|
|
58
|
+
make clean && make AES256=1 && ./test.elf
|
|
59
|
+
|
|
60
|
+
lint:
|
|
61
|
+
$(call SPLINT)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+

|
|
2
|
+
### Tiny AES in C
|
|
3
|
+
|
|
4
|
+
This is a small and portable implementation of the AES [ECB](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Electronic_Codebook_.28ECB.29), [CTR](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Counter_.28CTR.29) and [CBC](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_Block_Chaining_.28CBC.29) encryption algorithms written in C.
|
|
5
|
+
|
|
6
|
+
You can override the default key-size of 128 bit with 192 or 256 bit by defining the symbols AES192 or AES256 in [`aes.h`](https://github.com/kokke/tiny-AES-c/blob/master/aes.h).
|
|
7
|
+
|
|
8
|
+
The API is very simple and looks like this (I am using C99 `<stdint.h>`-style annotated types):
|
|
9
|
+
|
|
10
|
+
```C
|
|
11
|
+
/* Initialize context calling one of: */
|
|
12
|
+
void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key);
|
|
13
|
+
void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv);
|
|
14
|
+
|
|
15
|
+
/* ... or reset IV at random point: */
|
|
16
|
+
void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv);
|
|
17
|
+
|
|
18
|
+
/* Then start encrypting and decrypting with the functions below: */
|
|
19
|
+
void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf);
|
|
20
|
+
void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf);
|
|
21
|
+
|
|
22
|
+
void AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
|
23
|
+
void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
|
24
|
+
|
|
25
|
+
/* Same function for encrypting as for decrypting in CTR mode */
|
|
26
|
+
void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Important notes:
|
|
30
|
+
* No padding is provided so for CBC and ECB all buffers should be multiples of 16 bytes. For padding [PKCS7](https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7) is recommendable.
|
|
31
|
+
* ECB mode is considered unsafe for most uses and is not implemented in streaming mode. If you need this mode, call the function for every block of 16 bytes you need encrypted. See [wikipedia's article on ECB](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Electronic_Codebook_(ECB)) for more details.
|
|
32
|
+
* This library is designed for small code size and simplicity, intended for cases where small binary size, low memory footprint and portability is more important than high performance. If speed is a concern, you can try more complex libraries, e.g. [Mbed TLS](https://tls.mbed.org/), [OpenSSL](https://www.openssl.org/) etc.
|
|
33
|
+
|
|
34
|
+
You can choose to use any or all of the modes-of-operations, by defining the symbols CBC, CTR or ECB in [`aes.h`](https://github.com/kokke/tiny-AES-c/blob/master/aes.h) (read the comments for clarification).
|
|
35
|
+
|
|
36
|
+
C++ users should `#include` [aes.hpp](https://github.com/kokke/tiny-AES-c/blob/master/aes.hpp) instead of [aes.h](https://github.com/kokke/tiny-AES-c/blob/master/aes.h)
|
|
37
|
+
|
|
38
|
+
There is no built-in error checking or protection from out-of-bounds memory access errors as a result of malicious input.
|
|
39
|
+
|
|
40
|
+
The module uses less than 200 bytes of RAM and 1-2K ROM when compiled for ARM, but YMMV depending on which modes are enabled.
|
|
41
|
+
|
|
42
|
+
It is one of the smallest implementations in C I've seen yet, but do contact me if you know of something smaller (or have improvements to the code here).
|
|
43
|
+
|
|
44
|
+
I've successfully used the code on 64bit x86, 32bit ARM and 8 bit AVR platforms.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
GCC size output when only CTR mode is compiled for ARM:
|
|
48
|
+
|
|
49
|
+
$ arm-none-eabi-gcc -Os -DCBC=0 -DECB=0 -DCTR=1 -c aes.c
|
|
50
|
+
$ size aes.o
|
|
51
|
+
text data bss dec hex filename
|
|
52
|
+
1171 0 0 1171 493 aes.o
|
|
53
|
+
|
|
54
|
+
.. and when compiling for the THUMB instruction set, we end up well below 1K in code size.
|
|
55
|
+
|
|
56
|
+
$ arm-none-eabi-gcc -Os -mthumb -DCBC=0 -DECB=0 -DCTR=1 -c aes.c
|
|
57
|
+
$ size aes.o
|
|
58
|
+
text data bss dec hex filename
|
|
59
|
+
903 0 0 903 387 aes.o
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
I am using the Free Software Foundation, ARM GCC compiler:
|
|
63
|
+
|
|
64
|
+
$ arm-none-eabi-gcc --version
|
|
65
|
+
arm-none-eabi-gcc (4.8.4-1+11-1) 4.8.4 20141219 (release)
|
|
66
|
+
Copyright (C) 2013 Free Software Foundation, Inc.
|
|
67
|
+
This is free software; see the source for copying conditions. There is NO
|
|
68
|
+
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
This implementation is verified against the data in:
|
|
74
|
+
|
|
75
|
+
[National Institute of Standards and Technology Special Publication 800-38A 2001 ED](http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf) Appendix F: Example Vectors for Modes of Operation of the AES.
|
|
76
|
+
|
|
77
|
+
The other appendices in the document are valuable for implementation details on e.g. padding, generation of IVs and nonces in CTR-mode etc.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
A heartfelt thank-you to [all the nice people](https://github.com/kokke/tiny-AES-c/graphs/contributors) out there who have contributed to this project.
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
All material in this repository is in the public domain.
|