Fix XP3 creation with RiddleCxCrypt#186
Merged
Merged
Conversation
Owner
|
Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue
The current XP3
RiddleCxCryptencryption is broken.To reproduce, just create any XP3 pack that uses
RiddleCxCrypt("Riddle Joker" or "Café Stella to Shinigami no Chou"). Then you decrypt it and see that the file extracted is not the same as the original file.For example, I created a pack with one file test.txt containing the following bytes:
Creating a XP3 with "Café Stella to Shinigami no Chou" crypt and then extracting it, the extracted test.txt has the following bytes:
Cause
Look at
GameRes.Formats.KiriKiri.RiddleCxCrypt.Encrypt:GARbro/ArcFormats/KiriKiri/YuzCrypt.cs
Lines 137 to 141 in 71a9382
base.Encryptwould callGameRes.Formats.KiriKiri.CxEncryption.Encrypt:GARbro/ArcFormats/KiriKiri/KiriKiriCx.cs
Lines 205 to 208 in 71a9382
which would call
Decryptagain as the algorithm is symmetric, butDecryptis virtual and this would callGameRes.Formats.KiriKiri.RiddleCxCrypt.Decrypt:GARbro/ArcFormats/KiriKiri/YuzCrypt.cs
Lines 131 to 135 in 71a9382
As you can tell from the process,
ProcessFirstBytesgets invoked twice (once before the Cx crypt and once after) when it should have only been invoked once after the Cx crypt.Fix
Let
CxEncryption.EncryptcallCxEncryption's own implementation ofDecryptonly. This fix should not break other crypts derived fromCxEncryptionas they don't callbase.Encryptor rely on the fact thatbase.Encryptcalls theirDecrypt.