-
Notifications
You must be signed in to change notification settings - Fork 222
Add dev DSi blowfish key support to dump dev software #969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| 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; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 (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); | ||
|
|
||
There was a problem hiding this comment.
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.