├── npm ├── .npmrc ├── package.json ├── KgmWasm.d.ts ├── KgmLegacy.d.ts └── KgmWasmBundle.d.ts ├── KgmWasm.cpp ├── .github └── workflows │ ├── publish.yml │ └── codeql.yml ├── KgmWasm.h ├── README.md ├── CMakeLists.txt ├── kgm_wasm.ts ├── .gitattributes ├── kgm.hpp ├── .gitignore └── LICENSE.txt /npm/.npmrc: -------------------------------------------------------------------------------- 1 | //registry.npmjs.org/:_authToken=${NPM_TOKEN} 2 | -------------------------------------------------------------------------------- /KgmWasm.cpp: -------------------------------------------------------------------------------- 1 | // KgmWasm.cpp : Defines the entry point for the application. 2 | // 3 | 4 | #include "KgmWasm.h" 5 | 6 | #include "kgm.hpp" 7 | 8 | #include 9 | #include 10 | 11 | size_t preDec(uintptr_t blob, size_t blobSize, std::string ext) 12 | { 13 | return PreDec((uint8_t*)blob, blobSize, ext == "vpr"); 14 | } 15 | 16 | void decBlob(uintptr_t blob, size_t blobSize, size_t offset) 17 | { 18 | Decrypt((uint8_t*)blob, blobSize, offset); 19 | return; 20 | } 21 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: "Publish" 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | publish: 8 | name: Publish 9 | runs-on: ubuntu-latest 10 | permissions: 11 | actions: read 12 | contents: read 13 | 14 | steps: 15 | - name: Checkout repository 16 | uses: actions/checkout@v3 17 | 18 | - name: Autobuild 19 | run: bash build-wasm 20 | 21 | - name: Publish Package 22 | run: cd npm; npm publish --access public 23 | env: 24 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 25 | -------------------------------------------------------------------------------- /KgmWasm.h: -------------------------------------------------------------------------------- 1 | // KgmWasm.h : Include file for standard system include files, 2 | // or project specific include files. 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace em = emscripten; 10 | 11 | size_t preDec(uintptr_t blob, size_t blobSize, std::string ext); 12 | void decBlob(uintptr_t blob, size_t blobSize, size_t offset); 13 | 14 | EMSCRIPTEN_BINDINGS(QmcCrypto) 15 | { 16 | em::function("preDec", &preDec, em::allow_raw_pointers()); 17 | em::function("decBlob", &decBlob, em::allow_raw_pointers()); 18 | } 19 | -------------------------------------------------------------------------------- /npm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@xhacker/kgmwasm", 3 | "version": "1.0.0", 4 | "description": "WASM for Kgm Encryption & Decryption", 5 | "main": "KgmWasmBundle.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/nullptr-0/KgmWasm.git" 12 | }, 13 | "keywords": [ 14 | "unlock-music", 15 | "kgm", 16 | "WASM" 17 | ], 18 | "author": "xhacker-zzz", 19 | "license": "Apache-2.0", 20 | "bugs": { 21 | "url": "https://github.com/nullptr-0/KgmWasm/issues" 22 | }, 23 | "homepage": "https://github.com/nullptr-0/KgmWasm#readme" 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KgmWasm 2 | WASM for Kgm Encryption & Decryption 3 | - KgmWasm是从属于[音乐解锁Web]项目的Kgm类加密文件的WASM解密组件,属于[音乐解锁]系列项目之一。 4 | - KgmWasm只提供对读入内存的加密内容进行解密的功能,并不能直接使用。如需直接使用,请转到[Web预构建版本]或[CLI预构建版本]。 5 | - KgmWasm项目以学习和研究为初衷,并基于您同意并遵守[授权协议]各项条款在此项目上之应用的条件向您开放源代码。 6 | 7 | ## 支持的格式 8 | 9 | - [x] 酷狗音乐 Normal (.kgm*) 10 | - [x] 酷狗音乐 Viper (.vpr) 11 | 12 | ## 构建与使用 13 | 14 | KgmWasm使用[GitHub Actions]构建和发布npm包,您可以在项目的配置中使用包名`@xhacker/kgmwasm`进行引用 15 | 16 | ### 使用方法 17 | 18 | - 您可以参照[kgm_wasm.ts]中的使用方法 19 | - 您也可以在您的项目中直接引用[kgm_wasm.ts]文件,例如: 20 | ``` 21 | import { DecryptKgmWasm } from '@/kgm_wasm'; 22 | // 其他代码 ... 23 | const decrypted= (await DecryptKgmWasm(cipherText, extension)).data; 24 | ``` 25 | 26 | ### 自行构建 27 | 28 | #### 依赖 29 | 要自行构建此项目,请确保已经安装[Git]与[CMake]且其路径已经添加到 `PATH` 30 | #### Linux 31 | 在此项目根目录中执行 `./build-wasm` 即可构建。构建结果将位于此项目根目录的npm子目录中。 32 | #### Windows 33 | 在此项目根目录中执行 `build-wasm.cmd` 即可构建。构建结果将位于此项目根目录的npm子目录中。 34 | 35 | [音乐解锁Web]: https://git.unlock-music.dev/um/web 36 | [音乐解锁]: https://unlock-music.dev/ 37 | [Web预构建版本]: https://git.unlock-music.dev/um/-/packages/generic/web-build/ 38 | [CLI预构建版本]: https://git.unlock-music.dev/um/-/packages/generic/cli-build/ 39 | [授权协议]: https://github.com/nullptr-0/KgmWasm/blob/master/LICENSE.txt 40 | [kgm_wasm.ts]: https://github.com/nullptr-0/KgmWasm/blob/master/kgm_wasm.ts 41 | [GitHub Actions]: https://github.com/nullptr-0/KgmWasm/actions 42 | [Git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git 43 | [CMake]: https://cmake.org/download/ 44 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMakeList.txt : CMake project for KgmWasm, include source and define 2 | # project specific logic here. 3 | # 4 | cmake_minimum_required (VERSION 3.8) 5 | 6 | project ("KgmWasm") 7 | 8 | set(CMAKE_CXX_STANDARD 14) 9 | 10 | include_directories( 11 | $ 12 | ) 13 | 14 | # Add source to this project's executable. 15 | set(RUNTIME_METHODS_LIST 16 | getValue 17 | writeArrayToMemory 18 | UTF8ToString 19 | ) 20 | list(JOIN RUNTIME_METHODS_LIST "," RUNTIME_METHODS) 21 | 22 | set(EMSCRIPTEN_FLAGS 23 | "--bind" 24 | "-s NO_DYNAMIC_EXECUTION=1" 25 | "-s MODULARIZE=1" 26 | "-s EXPORT_NAME=KgmCryptoModule" 27 | "-s EXPORTED_RUNTIME_METHODS=${RUNTIME_METHODS}" 28 | ) 29 | set(EMSCRIPTEN_LEGACY_FLAGS 30 | ${EMSCRIPTEN_FLAGS} 31 | "-s WASM=0" 32 | "--memory-init-file 0" 33 | ) 34 | set(EMSCRIPTEN_WASM_BUNDLE_FLAGS 35 | ${EMSCRIPTEN_FLAGS} 36 | "-s SINGLE_FILE=1" 37 | ) 38 | 39 | list(JOIN EMSCRIPTEN_FLAGS " " EMSCRIPTEN_FLAGS_STR) 40 | list(JOIN EMSCRIPTEN_LEGACY_FLAGS " " EMSCRIPTEN_LEGACY_FLAGS_STR) 41 | list(JOIN EMSCRIPTEN_WASM_BUNDLE_FLAGS " " EMSCRIPTEN_WASM_BUNDLE_FLAGS_STR) 42 | 43 | # Define projects config 44 | set(WASM_SOURCES 45 | "KgmWasm.cpp" 46 | ) 47 | 48 | add_executable(KgmWasm ${WASM_SOURCES}) 49 | set_target_properties( 50 | KgmWasm 51 | PROPERTIES LINK_FLAGS ${EMSCRIPTEN_FLAGS_STR} 52 | ) 53 | 54 | add_executable(KgmWasmBundle ${WASM_SOURCES}) 55 | set_target_properties( 56 | KgmWasmBundle 57 | PROPERTIES LINK_FLAGS ${EMSCRIPTEN_WASM_BUNDLE_FLAGS_STR} 58 | ) 59 | 60 | add_executable(KgmLegacy ${WASM_SOURCES}) 61 | set_target_properties( 62 | KgmLegacy 63 | PROPERTIES LINK_FLAGS ${EMSCRIPTEN_LEGACY_FLAGS_STR} 64 | ) 65 | 66 | -------------------------------------------------------------------------------- /npm/KgmWasm.d.ts: -------------------------------------------------------------------------------- 1 | export type WASM_ptr = number; 2 | export type WASM_NUMBER = "i8" | "i16" | "i32" | "i64" | "float" | "double"; 3 | 4 | export declare interface WASMExportedRuntime { 5 | /** 6 | * Emscripten HEAP, use this for raw memory access. 7 | * @type {Uint8Array} 8 | */ 9 | HEAPU8: Uint8Array; 10 | 11 | /** 12 | * Allocate a block of {@link size} bytes of memory in Emscripten HEAP 13 | * @param size Size of the memory block, in bytes. 14 | * @returns {WASM_ptr} Returns a pointer to the beginning of the block. 15 | */ 16 | _malloc(size: number): WASM_ptr; 17 | 18 | /** 19 | * Free an allocated block of memory. 20 | * @param ptr Pointer to a memory block previously allocated with `malloc`. 21 | */ 22 | _free(ptr: WASM_ptr): void; 23 | 24 | /** 25 | * Write an uint8 array to the Emscripten HEAP. 26 | * @param data Data to be written inside the Emscripten HEAP. 27 | * @param bufferPointer Address pointer 28 | */ 29 | writeArrayToMemory(data: Uint8Array, bufferPointer: WASM_ptr): void; 30 | } 31 | 32 | export declare interface KgmCrypto extends WASMExportedRuntime { 33 | /** 34 | * Decryption preparations using the beginning-of-file buffer. 35 | * @param blob WASM ptr points to the beginning of the beginning-of-file buffer. 36 | * @param blobSize size of {@link blob}. 37 | * @param ext extension of the _original file_. 38 | */ 39 | preDec( 40 | blob: WASM_ptr, 41 | blobSize: number, 42 | ext: string 43 | ): number; 44 | 45 | /** 46 | * Decrypt a block. 47 | * @param blob Pointer to buffer allocated using {@link _malloc}. 48 | * Data can be written here using {@link writeArrayToMemory}. 49 | * @param size Size of the provided buffer. 50 | * @param offset Offset of the buffer from _original file_. 51 | * This parameter is _required_ to derive correct key. 52 | */ 53 | decBlob( 54 | blob: WASM_ptr, 55 | blobSize: number, 56 | offset: number 57 | ): void; 58 | } 59 | 60 | /** 61 | * Factory to initialise KgmCryptoModule. 62 | */ 63 | export default function KgmCryptoModule(): Promise; -------------------------------------------------------------------------------- /npm/KgmLegacy.d.ts: -------------------------------------------------------------------------------- 1 | export type WASM_ptr = number; 2 | export type WASM_NUMBER = "i8" | "i16" | "i32" | "i64" | "float" | "double"; 3 | 4 | export declare interface WASMExportedRuntime { 5 | /** 6 | * Emscripten HEAP, use this for raw memory access. 7 | * @type {Uint8Array} 8 | */ 9 | HEAPU8: Uint8Array; 10 | 11 | /** 12 | * Allocate a block of {@link size} bytes of memory in Emscripten HEAP 13 | * @param size Size of the memory block, in bytes. 14 | * @returns {WASM_ptr} Returns a pointer to the beginning of the block. 15 | */ 16 | _malloc(size: number): WASM_ptr; 17 | 18 | /** 19 | * Free an allocated block of memory. 20 | * @param ptr Pointer to a memory block previously allocated with `malloc`. 21 | */ 22 | _free(ptr: WASM_ptr): void; 23 | 24 | /** 25 | * Write an uint8 array to the Emscripten HEAP. 26 | * @param data Data to be written inside the Emscripten HEAP. 27 | * @param bufferPointer Address pointer 28 | */ 29 | writeArrayToMemory(data: Uint8Array, bufferPointer: WASM_ptr): void; 30 | } 31 | 32 | export declare interface KgmCrypto extends WASMExportedRuntime { 33 | /** 34 | * Decryption preparations using the beginning-of-file buffer. 35 | * @param blob WASM ptr points to the beginning of the beginning-of-file buffer. 36 | * @param blobSize size of {@link blob}. 37 | * @param ext extension of the _original file_. 38 | */ 39 | preDec( 40 | blob: WASM_ptr, 41 | blobSize: number, 42 | ext: string 43 | ): number; 44 | 45 | /** 46 | * Decrypt a block. 47 | * @param blob Pointer to buffer allocated using {@link _malloc}. 48 | * Data can be written here using {@link writeArrayToMemory}. 49 | * @param size Size of the provided buffer. 50 | * @param offset Offset of the buffer from _original file_. 51 | * This parameter is _required_ to derive correct key. 52 | */ 53 | decBlob( 54 | blob: WASM_ptr, 55 | blobSize: number, 56 | offset: number 57 | ): void; 58 | } 59 | 60 | /** 61 | * Factory to initialise KgmCryptoModule. 62 | */ 63 | export default function KgmCryptoModule(): Promise; -------------------------------------------------------------------------------- /npm/KgmWasmBundle.d.ts: -------------------------------------------------------------------------------- 1 | export type WASM_ptr = number; 2 | export type WASM_NUMBER = "i8" | "i16" | "i32" | "i64" | "float" | "double"; 3 | 4 | export declare interface WASMExportedRuntime { 5 | /** 6 | * Emscripten HEAP, use this for raw memory access. 7 | * @type {Uint8Array} 8 | */ 9 | HEAPU8: Uint8Array; 10 | 11 | /** 12 | * Allocate a block of {@link size} bytes of memory in Emscripten HEAP 13 | * @param size Size of the memory block, in bytes. 14 | * @returns {WASM_ptr} Returns a pointer to the beginning of the block. 15 | */ 16 | _malloc(size: number): WASM_ptr; 17 | 18 | /** 19 | * Free an allocated block of memory. 20 | * @param ptr Pointer to a memory block previously allocated with `malloc`. 21 | */ 22 | _free(ptr: WASM_ptr): void; 23 | 24 | /** 25 | * Write an uint8 array to the Emscripten HEAP. 26 | * @param data Data to be written inside the Emscripten HEAP. 27 | * @param bufferPointer Address pointer 28 | */ 29 | writeArrayToMemory(data: Uint8Array, bufferPointer: WASM_ptr): void; 30 | } 31 | 32 | export declare interface KgmCrypto extends WASMExportedRuntime { 33 | /** 34 | * Decryption preparations using the beginning-of-file buffer. 35 | * @param blob WASM ptr points to the beginning of the beginning-of-file buffer. 36 | * @param blobSize size of {@link blob}. 37 | * @param ext extension of the _original file_. 38 | */ 39 | preDec( 40 | blob: WASM_ptr, 41 | blobSize: number, 42 | ext: string 43 | ): number; 44 | 45 | /** 46 | * Decrypt a block. 47 | * @param blob Pointer to buffer allocated using {@link _malloc}. 48 | * Data can be written here using {@link writeArrayToMemory}. 49 | * @param size Size of the provided buffer. 50 | * @param offset Offset of the buffer from _original file_. 51 | * This parameter is _required_ to derive correct key. 52 | */ 53 | decBlob( 54 | blob: WASM_ptr, 55 | blobSize: number, 56 | offset: number 57 | ): void; 58 | } 59 | 60 | /** 61 | * Factory to initialise KgmCryptoModule. 62 | */ 63 | export default function KgmCryptoModule(): Promise; -------------------------------------------------------------------------------- /kgm_wasm.ts: -------------------------------------------------------------------------------- 1 | import { KgmCrypto } from '@xhacker/kgmwasm/KgmWasmBundle'; 2 | import KgmCryptoModule from '@xhacker/kgmwasm/KgmWasmBundle'; 3 | import { MergeUint8Array } from '@/utils/MergeUint8Array'; 4 | 5 | // 每次可以处理 2M 的数据 6 | const DECRYPTION_BUF_SIZE = 2 *1024 * 1024; 7 | 8 | export interface KGMDecryptionResult { 9 | success: boolean; 10 | data: Uint8Array; 11 | error: string; 12 | } 13 | 14 | /** 15 | * 解密一个 KGM 加密的文件。 16 | * 17 | * 如果检测并解密成功,返回解密后的 Uint8Array 数据。 18 | * @param {ArrayBuffer} kgmBlob 读入的文件 Blob 19 | */ 20 | export async function DecryptKgmWasm(kgmBlob: ArrayBuffer, ext: string): Promise { 21 | const result: KGMDecryptionResult = { success: false, data: new Uint8Array(), error: '' }; 22 | 23 | // 初始化模组 24 | let KgmCryptoObj: KgmCrypto; 25 | 26 | try { 27 | KgmCryptoObj = await KgmCryptoModule(); 28 | } catch (err: any) { 29 | result.error = err?.message || 'wasm 加载失败'; 30 | return result; 31 | } 32 | if (!KgmCryptoObj) { 33 | result.error = 'wasm 加载失败'; 34 | return result; 35 | } 36 | 37 | // 申请内存块,并文件末端数据到 WASM 的内存堆 38 | let kgmBuf = new Uint8Array(kgmBlob); 39 | const pKgmBuf = KgmCryptoObj._malloc(DECRYPTION_BUF_SIZE); 40 | const preDecDataSize = Math.min(DECRYPTION_BUF_SIZE, kgmBlob.byteLength); // 初始化缓冲区大小 41 | KgmCryptoObj.writeArrayToMemory(kgmBuf.slice(0, preDecDataSize), pKgmBuf); 42 | 43 | // 进行解密初始化 44 | const headerSize = KgmCryptoObj.preDec(pKgmBuf, preDecDataSize, ext); 45 | kgmBuf = kgmBuf.slice(headerSize); 46 | 47 | const decryptedParts = []; 48 | let offset = 0; 49 | let bytesToDecrypt = kgmBuf.length; 50 | while (bytesToDecrypt > 0) { 51 | const blockSize = Math.min(bytesToDecrypt, DECRYPTION_BUF_SIZE); 52 | 53 | // 解密一些片段 54 | const blockData = new Uint8Array(kgmBuf.slice(offset, offset + blockSize)); 55 | KgmCryptoObj.writeArrayToMemory(blockData, pKgmBuf); 56 | KgmCryptoObj.decBlob(pKgmBuf, blockSize, offset); 57 | decryptedParts.push(KgmCryptoObj.HEAPU8.slice(pKgmBuf, pKgmBuf + blockSize)); 58 | 59 | offset += blockSize; 60 | bytesToDecrypt -= blockSize; 61 | } 62 | KgmCryptoObj._free(pKgmBuf); 63 | 64 | result.data = MergeUint8Array(decryptedParts); 65 | result.success = true; 66 | 67 | return result; 68 | } 69 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "master" ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ "master" ] 20 | workflow_dispatch: 21 | 22 | jobs: 23 | analyze: 24 | name: Analyze 25 | runs-on: ubuntu-latest 26 | permissions: 27 | actions: read 28 | contents: read 29 | security-events: write 30 | 31 | strategy: 32 | fail-fast: false 33 | matrix: 34 | language: [ 'cpp', 'javascript' ] 35 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 36 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 37 | 38 | steps: 39 | - name: Checkout repository 40 | uses: actions/checkout@v3 41 | 42 | # Initializes the CodeQL tools for scanning. 43 | - name: Initialize CodeQL 44 | uses: github/codeql-action/init@v2 45 | with: 46 | languages: ${{ matrix.language }} 47 | # If you wish to specify custom queries, you can do so here or in a config file. 48 | # By default, queries listed here will override any specified in a config file. 49 | # Prefix the list here with "+" to use these queries and those in the config file. 50 | 51 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 52 | # queries: security-extended,security-and-quality 53 | 54 | 55 | # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). 56 | # If this step fails, then you should remove it and run the build manually (see below) 57 | - name: Autobuild 58 | run: bash build-wasm 59 | #uses: github/codeql-action/autobuild@v2 60 | 61 | # ℹ️ Command-line programs to run using the OS shell. 62 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 63 | 64 | # If the Autobuild fails above, remove it and uncomment the following three lines. 65 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 66 | 67 | # - run: | 68 | # echo "Run, Build Application using script" 69 | # ./location_of_script_within_repo/buildscript.sh 70 | 71 | - name: Perform CodeQL Analysis 72 | uses: github/codeql-action/analyze@v2 73 | with: 74 | category: "/language:${{matrix.language}}" 75 | -------------------------------------------------------------------------------- /kgm.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::vector VprHeader = { 4 | 0x05, 0x28, 0xBC, 0x96, 0xE9, 0xE4, 0x5A, 0x43, 5 | 0x91, 0xAA, 0xBD, 0xD0, 0x7A, 0xF5, 0x36, 0x31 }; 6 | std::vector KgmHeader = { 7 | 0x7C, 0xD5, 0x32, 0xEB, 0x86, 0x02, 0x7F, 0x4B, 8 | 0xA8, 0xAF, 0xA6, 0x8E, 0x0F, 0xFF, 0x99, 0x14 }; 9 | std::vector VprMaskDiff = { 10 | 0x25, 0xDF, 0xE8, 0xA6, 0x75, 0x1E, 0x75, 0x0E, 11 | 0x2F, 0x80, 0xF3, 0x2D, 0xB8, 0xB6, 0xE3, 0x11, 0x00 }; 12 | 13 | std::vector MaskV2; 14 | 15 | std::vector table1 = { 16 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x01, 0x21, 0x01, 0x61, 0x01, 0x21, 0x01, 0xe1, 0x01, 0x21, 0x01, 0x61, 0x01, 0x21, 0x01, 18 | 0xd2, 0x23, 0x02, 0x02, 0x42, 0x42, 0x02, 0x02, 0xc2, 0xc2, 0x02, 0x02, 0x42, 0x42, 0x02, 0x02, 19 | 0xd3, 0xd3, 0x02, 0x03, 0x63, 0x43, 0x63, 0x03, 0xe3, 0xc3, 0xe3, 0x03, 0x63, 0x43, 0x63, 0x03, 20 | 0x94, 0xb4, 0x94, 0x65, 0x04, 0x04, 0x04, 0x04, 0x84, 0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df, 0xdf, 0x9f, 0x9f, 0xdf, 0xdf, 0x0e, 0x0f, 32 | 0x00, 0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0xe0, 0x00, 0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0xf1 33 | }; 34 | 35 | std::vector table2 = { 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 37 | 0x00, 0x01, 0x23, 0x01, 0x67, 0x01, 0x23, 0x01, 0xef, 0x01, 0x23, 0x01, 0x67, 0x01, 0x23, 0x01, 38 | 0xdf, 0x21, 0x02, 0x02, 0x46, 0x46, 0x02, 0x02, 0xce, 0xce, 0x02, 0x02, 0x46, 0x46, 0x02, 0x02, 39 | 0xde, 0xde, 0x02, 0x03, 0x65, 0x47, 0x65, 0x03, 0xed, 0xcf, 0xed, 0x03, 0x65, 0x47, 0x65, 0x03, 40 | 0x9d, 0xbf, 0x9d, 0x63, 0x04, 0x04, 0x04, 0x04, 0x8c, 0x8c, 0x8c, 0x8c, 0x04, 0x04, 0x04, 0x04, 41 | 0x9c, 0x9c, 0x9c, 0x9c, 0x04, 0x05, 0x27, 0x05, 0xeb, 0x8d, 0xaf, 0x8d, 0xeb, 0x05, 0x27, 0x05, 42 | 0xdb, 0xbd, 0x9f, 0xbd, 0xdb, 0x25, 0x06, 0x06, 0xca, 0xca, 0x8e, 0x8e, 0xca, 0xca, 0x06, 0x06, 43 | 0xda, 0xda, 0x9e, 0x9e, 0xda, 0xda, 0x06, 0x07, 0xe9, 0xcb, 0xe9, 0x8f, 0xe9, 0xcb, 0xe9, 0x07, 44 | 0x19, 0x3b, 0x19, 0x7f, 0x19, 0x3b, 0x19, 0xe7, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 45 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x08, 0x09, 0x2b, 0x09, 0x6f, 0x09, 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0, 0x68, 0xF4, 0x00, 0x23, 0xF3, 0x5E, 0x0A, 0x7B, 0x93, 0xDD, 71 | 0xAB, 0x12, 0xB2, 0x13, 0xE8, 0x84, 0xD7, 0xA7, 0x9F, 0x0F, 0x32, 0x4C, 0x55, 0x1D, 0x04, 0x36, 72 | 0x52, 0xDC, 0x03, 0xF3, 0xF9, 0x4E, 0x42, 0xE9, 0x3D, 0x61, 0xEF, 0x7C, 0xB6, 0xB3, 0x93, 0x50, 73 | }; 74 | 75 | uint8_t getMask(size_t pos) { 76 | size_t offset = pos >> 4; 77 | uint8_t value = 0; 78 | while (offset >= 0x11) { 79 | value ^= table1[offset % 272]; 80 | offset >>= 4; 81 | value ^= table2[offset % 272]; 82 | offset >>= 4; 83 | } 84 | 85 | return MaskV2PreDef[pos % 272] ^ value; 86 | } 87 | 88 | std::vector key(17); 89 | bool isVpr = false; 90 | 91 | size_t PreDec(uint8_t* fileData, size_t size, bool iV) { 92 | uint32_t headerLen = *(uint32_t*)(fileData + 0x10); 93 | memcpy(key.data(), (fileData + 0x1C), 0x10); 94 | key[16] = 0; 95 | isVpr = iV; 96 | return headerLen; 97 | } 98 | 99 | void Decrypt(uint8_t* fileData, size_t size, size_t offset) { 100 | for (size_t i = 0; i < size; ++i) { 101 | uint8_t med8 = key[(i + offset) % 17] ^ fileData[i]; 102 | med8 ^= (med8 & 0xf) << 4; 103 | 104 | uint8_t msk8 = getMask(i + offset); 105 | msk8 ^= (msk8 & 0xf) << 4; 106 | fileData[i] = med8 ^ msk8; 107 | 108 | if (isVpr) { 109 | fileData[i] ^= VprMaskDiff[(i + offset) % 17]; 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd 364 | 365 | # content from build 366 | npm/LICENSE.txt 367 | npm/QmcWasm.wasm 368 | npm/QmcLegacy.js 369 | npm/QmcWasm.js 370 | npm/QmcWasmBundle.js 371 | build/ -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2022 - 2023 Zhengze Zhu 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------