Fix several bugs related to Modcrypt (d)encryption and ROM header hash generation, especially after changes on the arm9 and/or its code parameters (such as compression length):
Potential unhandled exception, calculating the key for Modcrypt (d)encryption for retail software. This may happen during ROM reading or writing.
The reason is that by default BigInteger are signed values and after the bitwise OR operation, the sign may be affected changing a 22-bytes length number to a 6-bytes length number.
Fix generation of arm9 secure area when its code parameters changes. The hash was calculated with arm9 content before patching the code parameter values such as file compressed length.
Fix program HMAC generation: it was calculated with an old value of arm9 secure are hash
Fix corruption of modcrypt content: the content was encrypted with an old arm9 secure hash which is part of the key.
Also fix the build by installing .NET 6 SDK and bumping .NET 8 SDK.
Quality check list
[x] Related code has been tested automatically or manually: tested with the problematic software and updated tests
Fix several bugs related to Modcrypt (d)encryption and ROM header hash generation, especially after changes on the arm9 and/or its code parameters (such as compression length):
BigInteger
are signed values and after the bitwise OR operation, the sign may be affected changing a 22-bytes length number to a 6-bytes length number.Also fix the build by installing .NET 6 SDK and bumping .NET 8 SDK.
Quality check list
Acceptance criteria
The Modcrypt key generation does not fail. Every hash of the encrypted content is valid after changing the arm9 content.
Follow-up work
None
Example
N/A