diff --git a/README.md b/README.md index 44d3fe27..9e20b025 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 9a4e2ce6..93e05eb4 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)) @@ -119,7 +120,15 @@ void NTR_ApplyKey (u32* pCardHash, int nCardHash, u32* pKeyCode) void NTR_InitKey (u32 aGameCode, u32* pCardHash, int nCardHash, u32* pKeyCode, int level, int iCardDevice) { - if(iCardDevice) + if(iCardDevice == 2) + { + size_t len = LoadSupportFile(BLOWFISHKEYDEV_NAME, pCardHash, 0x1048); + pKeyCode[0] = 0; + pKeyCode[1] = 0; + pKeyCode[2] = 0; + return; + } + else if(iCardDevice == 1) { const u8* BlowfishTwl = (const u8*)0x01FFD3E0; memcpy (pCardHash, BlowfishTwl, 0x1048); @@ -252,7 +261,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)) return false; + if (fsize != 0x1048) return false; + NTR_InitKey (iGameCode, iCardHash, nCardHash, iKeyCode, 1, 2); + } + 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 7ef5779a..638e5068 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;