feat(rengoku): validate and log Hunting Road config on startup

Port ECD encryption/decryption from ReFrontier (C#) and FrontierTextHandler
(Python) into common/decryption. The cipher uses a 32-bit LCG key stream with
an 8-round Feistel-like nibble transformation and CFB chaining; all six key
sets are supported, key 4 being the default for all MHF files.

On startup, loadRengokuBinary now decrypts (ECD) and decompresses (JKR) the
binary to validate pointer bounds and entry counts, then logs a structured
summary (floor counts, spawn table counts, unique monster IDs). Failures are
non-fatal — the encrypted blob is still cached and served to clients unchanged,
preserving existing behaviour. Closes #173.
This commit is contained in:
Houmgaor
2026-03-19 23:59:34 +01:00
parent 08e7de2c5e
commit 5c2fde5cfd
6 changed files with 698 additions and 9 deletions

View File

@@ -11,6 +11,7 @@ import (
"time"
cfg "erupe-ce/config"
"erupe-ce/common/decryption"
"erupe-ce/network/clientctx"
"erupe-ce/network/mhfpacket"
@@ -737,7 +738,7 @@ func TestLoadRengokuBinary_ValidECD(t *testing.T) {
dir := t.TempDir()
// Build a minimal valid ECD file: magic + some payload
data := make([]byte, 16)
binary.LittleEndian.PutUint32(data[:4], ecdMagic)
binary.LittleEndian.PutUint32(data[:4], decryption.ECDMagic)
if err := os.WriteFile(filepath.Join(dir, "rengoku_data.bin"), data, 0644); err != nil {
t.Fatal(err)
}