P5S PC external .files with an SRST 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 byte SRST 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. The SRST, KTSR and KOVSwrapper 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.
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
: