This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for P5S PC asset decryption.
The decryption algorithms were reversed from the executable and later simplified to readable code (I hope 😳).
Encryption is also implemented, but not used at the moment.
LINKDATA Decryption
P5S PC
LINKDATA.BIN
entries can either be compressed or encrypted, but never both at the same time.The encryption algorithm is a form of Mersenne twister, and the key is the index of the entry in
LINKDATA.IDX
, plus a constant.LINKDATA.IDX
itself is located in the executable.To decrypt:
Cethleann.DataExporter.exe --linkdata --game "P5SPC" <out_dir> <in_dir>
Example - first entry in
LINKDATA.IDX
:RDB Decryption
P5S PC RDB ZLib compressed entries are always encrypted.
Conversely, non-compressed RDB entries are never encrypted.
The encryption algorithm uses XORShift32, and the key is the entry's KTID.
To decrypt:
Cethleann.DataExporter.exe --rdb --filelist filelist-Scramble-rdb.csv <out_dir> <in_dir>
Example - an encrypted shader from
system.rdb
:SRST Decryption
P5S PC external
.file
s with anSRST
header can be encrypted.To determine whether a file is encrypted, the game checks offset 0x20 in the
KTSR
header which immediately follows the 0x10 byteSRST
header.The byte value stored in that offset is the encryption key length, with the key itself following from the next byte - if the value is 0, no decryption is performed.
Only the audio files themselves (
KOVS
header) are encrypted. TheSRST
,KTSR
andKOVS
wrapper headers remain unencrypted, and are used by the game to determine what needs to be decrypted.The encryption algorithm is Blowfish in ECB mode.
The game decrypts
SRST
file contents on-the-fly, during stream playback.To decrypt:
Cethleann.DataExporter.exe --rdb --filelist filelist-Scramble-rdb.csv <out_dir> <in_dir>
All encrypted
SRST
external files in P5S PC are referenced inRRPreview.rdb
.Example - from the BGM
.srst
: