Skip to content

Add dev DSi blowfish key support to dump dev software#969

Open
xp0x00 wants to merge 3 commits into
d0k3:masterfrom
xp0x00:add-dev-dsi-key
Open

Add dev DSi blowfish key support to dump dev software#969
xp0x00 wants to merge 3 commits into
d0k3:masterfrom
xp0x00:add-dev-dsi-key

Conversation

@xp0x00

@xp0x00 xp0x00 commented Jun 22, 2026

Copy link
Copy Markdown

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] = 01 and [0x1C] = 07 during 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):

  • Dev app (game proto) flashed on DSi dev cart (TWL Flash Card 4G)
  • Dev app (factory software) flashed on DSi factory cart
  • Dev app (game proto) flashed on DSi factory cart

Retail (checked one sample of each type to ensure no regression):

  • Retail DS cart
  • Retail DSi-exclusive cart
  • Retail DS, DSi-enhanced and DSi-exclusive game flashed on DSi factory cart
  • Retail factory software flashed on DSi factory cart

Should fix #457.

@d0k3 d0k3 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review done, thanks for your contribution!

if(iCardDevice)
if(iCardDevice == 2)
{
size_t len = LoadSupportFile(BLOWFISHKEYDEV_NAME, pCardHash, 0x1048);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot dump DSi dev carts

2 participants