From 0036f39fc6c9413196fd1d425b2981be905dcc69 Mon Sep 17 00:00:00 2001 From: xp0x00 <208293783+xp0x00@users.noreply.github.com> Date: Sun, 19 Jul 2026 17:55:00 +0800 Subject: [PATCH] Add dev DSi blowfish key support to dump dev software (#969) * Add dev DSi blowfish key support to dump dev roms * Mention dev DSi blowfish support file in readme * Adjust dsi dev app check * Load support file immediately --- README.md | 1 + arm9/source/gamecart/secure_ntr.c | 14 +++++++++++++- arm9/source/gamecart/secure_ntr.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 44d3fe2..9e20b02 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ For certain functionality, GodMode9 may need 'support files'. Support files shou * __`aeskeydb.bin`__: This should contain 0x25keyX, 0x18keyX and 0x1BkeyX to enable decryption of 7x / Secure3 / Secure4 encrypted NCCH files, 0x11key95 / 0x11key96 for FIRM decrypt support and 0x11keyOTP / 0x11keyIVOTP for 'secret' sector 0x96 crypto support. Entrypoints other than [boot9strap](https://github.com/SciresM/boot9strap) or [fastboot3ds](https://github.com/derrekr/fastboot3DS) may require a aeskeydb.bin file. This is now included in standard releases of GM9. No need to hunt down the file! * __`seeddb.bin`__: This file is optional and required to decrypt and mount seed-encrypted NCCHs and CIAs (if the seed in question is not installed to your NAND). Note that your seeddb.bin must also contain the seed for the specific game you need to decrypt. * __`encTitleKeys.bin`__ / __`decTitleKeys.bin`__: These files are optional and provide titlekeys, which are required to decrypt and install contents downloaded from CDN (for DSi and 3DS content). +* __`TwlBlowfishKeyDev.bin`__: This should contain the dev DSi blowfish key. It is optional and required to dump DSi developer or factory cartridges with dev software flashed on them. ### Fonts and translations GodMode9 also supports custom fonts and translations as support files. These both use custom formats, fonts use FRF (Font RIFF) files which can be created using the `fontriff.py` Python script in the 'utils' folder. Translations use TRF (Translation RIFF) files from the `transriff.py` script. Examples of the inputs to these scripts can be found in the 'fonts' and 'languages' folders of the 'resources' folder respectively. diff --git a/arm9/source/gamecart/secure_ntr.c b/arm9/source/gamecart/secure_ntr.c index 9a4e2ce..96fd8de 100644 --- a/arm9/source/gamecart/secure_ntr.c +++ b/arm9/source/gamecart/secure_ntr.c @@ -23,6 +23,7 @@ #include "card_ntr.h" // #include "draw.h" #include "timer.h" +#include "support.h" #define BSWAP32(val) ((((val >> 24) & 0xFF)) | (((val >> 16) & 0xFF) << 8) | (((val >> 8) & 0xFF) << 16) | ((val & 0xFF) << 24)) @@ -252,7 +253,18 @@ bool NTR_Secure_Init (u8* header, u8* sa_copy, u32 CartID, int iCardDevice) iGameCode = *((vu32*)(void*)&header[0x0C]); ReadDataFlags = cardControl13 & ~ NTRCARD_BLK_SIZE(7); - NTR_InitKey (iGameCode, iCardHash, nCardHash, iKeyCode, iCardDevice?1:2, iCardDevice); + + 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); + } if(!iCheapCard) flagsKey1 |= NTRCARD_SEC_LARGE; //Debug("iCheapCard=%d, readTimeout=%d", iCheapCard, readTimeout); diff --git a/arm9/source/gamecart/secure_ntr.h b/arm9/source/gamecart/secure_ntr.h index 7ef5779..638e506 100644 --- a/arm9/source/gamecart/secure_ntr.h +++ b/arm9/source/gamecart/secure_ntr.h @@ -2,6 +2,7 @@ #include "common.h" +#define BLOWFISHKEYDEV_NAME "TwlBlowfishKeyDev.bin" typedef struct _IKEY1{ u32 iii;