Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Persona 5 Strikers PC Assets Decryption #36

Merged
merged 3 commits into from
Feb 17, 2021

Conversation

zarroboogs
Copy link
Contributor

@zarroboogs zarroboogs commented Feb 17, 2021

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:

    linkdata

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:

    rdb

SRST Decryption

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 KOVS 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 in RRPreview.rdb.

  • Example - from the BGM .srst:

    srst

@yretenai yretenai merged commit 94b1cde into yretenai:main Feb 17, 2021
@yretenai
Copy link
Owner

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants