Add dev DSi blowfish key support to dump dev software#969
Conversation
d0k3
left a comment
There was a problem hiding this comment.
Review done, thanks for your contribution!
| if(iCardDevice) | ||
| if(iCardDevice == 2) | ||
| { | ||
| size_t len = LoadSupportFile(BLOWFISHKEYDEV_NAME, pCardHash, 0x1048); |
There was a problem hiding this comment.
len is set, but unused after. Did you mean to check for 0x1048? I think you should. Even if you checked the availaibility of the support file before this, something may happen in between.
| { | ||
| size_t len = LoadSupportFile(BLOWFISHKEYDEV_NAME, pCardHash, 0x1048); | ||
| pKeyCode[0] = 0; | ||
| pKeyCode[1] = 0; |
There was a problem hiding this comment.
This and below: don't mix tabs and spaces. Everything else here uses spaces.
| if(iCardDevice && ((header[0x1BF] & 0x80) || (header[0x1C] & 0x04))) // dsi dev app | ||
| { | ||
| size_t fsize; | ||
| if (!CheckSupportFile(BLOWFISHKEYDEV_NAME, &fsize)) return false; |
There was a problem hiding this comment.
Instead of just checking for the availability of the key file, you could load it right away, and react to any failures here. Example (be careful, though, I may be missing something here):
if (iCardDevice && ((header[0x1BF] & 0x80) || (header[0x1C] & 0x04))) // dsi dev app
{
size_t fsize;
if (!CheckSupportFile(BLOWFISHKEYDEV_NAME, &fsize) || (fsize != 0x1048)) return false;
if (LoadSupportFile(BLOWFISHKEYDEV_NAME, iCardHash, 0x1048) != 0x1048) return false;
memset(iKeyCode, 0, sizeof(iKeyCode));
}
else // retail
{
NTR_InitKey (iGameCode, iCardHash, nCardHash, iKeyCode, iCardDevice?1:2, iCardDevice);
}
This adds support for using the dev DSi blowfish key, allowing DSi dev apps to be dumped from DSi dev and factory cartridges.
The blowfish key is provided by the user as a support file (
TwlBlowfishKeyDev.bin) and will be used whenever dev software is detected. The logic is the same as DS-Homebrew/TWiLightMenu@f181b22, however the dev check is adjusted to add|| (header[0x1C] & 0x04)as one dev app was observed to have[0x1BF] = 01and[0x1C] = 07during testing. (Bit 2 of[0x1C]specifies using dev encryption)Existing functionality for dumping retail cartridges should be unaffected.
What has been tested?
Dev software (now dumping correctly):
Retail (checked one sample of each type to ensure no regression):
Should fix #457.