2021-12-16 22:07:43 +00:00
|
|
|
import {QmcDecryptKey, simpleMakeKey,} from "@/decrypt/qmc_key";
|
2021-12-16 17:28:48 +00:00
|
|
|
import fs from "fs";
|
|
|
|
|
|
|
|
test("key dec: make simple key", () => {
|
|
|
|
expect(
|
|
|
|
simpleMakeKey(106, 8)
|
|
|
|
).toStrictEqual(
|
|
|
|
[0x69, 0x56, 0x46, 0x38, 0x2b, 0x20, 0x15, 0x0b]
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
function loadTestDataKeyDecrypt(name: string): {
|
|
|
|
cipherText: Uint8Array,
|
|
|
|
clearText: Uint8Array
|
|
|
|
} {
|
|
|
|
return {
|
|
|
|
cipherText: fs.readFileSync(`testdata/${name}_key_raw.bin`),
|
|
|
|
clearText: fs.readFileSync(`testdata/${name}_key.bin`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test("key dec: real file", async () => {
|
|
|
|
const cases = ["mflac_map", "mgg_map", "mflac0_rc4"]
|
|
|
|
for (const name of cases) {
|
|
|
|
const {clearText, cipherText} = loadTestDataKeyDecrypt(name)
|
2021-12-16 22:07:43 +00:00
|
|
|
const buf = QmcDecryptKey(cipherText)
|
2021-12-16 17:28:48 +00:00
|
|
|
|
|
|
|
expect(buf).toStrictEqual(clearText)
|
|
|
|
}
|
|
|
|
})
|