Closed jonjonarnearne closed 7 years ago
The lut is so simple that I just generate it when I do the lookup. I'm not sure if lut is the correct name for this :)
The generation/lookup is done in the badly named function "get_xor_delta".
Lut generation for PT10 - PT12 encryption would look like this: lut[i] = (i * 0xb) & 0xff Where lut is an array with 256 values.
I've simplified your xor decryption code. I realized that the two bytes at offset 0x12 and 0x13 are encryption identification.
The first byte is the type of encryption. I've only seen the values 0x01 and 0x05. 0x01 is the encryption scheme used for PT8-9, and 0x05 is the scheme used from PT10 and later.
The next value is part of a lookup table, and the position of this value in the lut is the delta that is used to create the xor key. For PT10 - PT12, this lut looks like this:
So if the value at offset 0x13 is 0x21, we can see that it has index 0x03 in the lut. Since this is for PT10-12, we have to take the negative of this number. Then we generate the xor_key by doing:
I've tested that this works with a selection of files from PT8 to PT12. Hope you find some use for this code :)