mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Sighax compatibility improvements
... this also removes the last remaining NAND offset hardcoding
This commit is contained in:
parent
c93746e957
commit
5694df0dad
@ -140,7 +140,7 @@ bool InitNandCrypto(void)
|
||||
|
||||
// part #2: TWL KEY
|
||||
// see: https://www.3dbrew.org/wiki/Memory_layout#ARM9_ITCM
|
||||
if (IS_A9LH) { // only for a9lh
|
||||
if (IS_A9LH) { // only for a9lh (and sighax, for now)
|
||||
u32* TwlCustId = (u32*) (0x01FFB808);
|
||||
u8 TwlKeyX[16] __attribute__((aligned(32)));
|
||||
u8 TwlKeyY[16] __attribute__((aligned(32)));
|
||||
@ -167,18 +167,19 @@ bool InitNandCrypto(void)
|
||||
// part #3: CTRNAND N3DS KEY / AGBSAVE CMAC KEY
|
||||
// thanks AuroraWright and Gelex for advice on this
|
||||
// see: https://github.com/AuroraWright/Luma3DS/blob/master/source/crypto.c#L347
|
||||
if (IS_A9LH && !IS_SIGHAX) { // only on A9LH, not required on sighax
|
||||
// keyY 0x05 is encrypted @0x0EB014 in the FIRM90
|
||||
// keyY 0x05 is encrypted @0x0EB24C in the FIRM81
|
||||
if ((LoadKeyYFromP9(slot0x05KeyY, slot0x05KeyY_sha256, 0x0EB014, 0x05) != 0) &&
|
||||
(LoadKeyYFromP9(slot0x05KeyY, slot0x05KeyY_sha256, 0x0EB24C, 0x05) != 0))
|
||||
LoadKeyFromFile(slot0x05KeyY, 0x05, 'Y', NULL);
|
||||
|
||||
// keyY 0x05 is encrypted @0x0EB014 in the FIRM90
|
||||
// keyY 0x05 is encrypted @0x0EB24C in the FIRM81
|
||||
if ((LoadKeyYFromP9(slot0x05KeyY, slot0x05KeyY_sha256, 0x0EB014, 0x05) != 0) &&
|
||||
(LoadKeyYFromP9(slot0x05KeyY, slot0x05KeyY_sha256, 0x0EB24C, 0x05) != 0))
|
||||
LoadKeyFromFile(slot0x05KeyY, 0x05, 'Y', NULL);
|
||||
|
||||
// keyY 0x24 is encrypted @0x0E62DC in the FIRM90
|
||||
// keyY 0x24 is encrypted @0x0E6514 in the FIRM81
|
||||
if ((LoadKeyYFromP9(NULL, slot0x24KeyY_sha256, 0x0E62DC, 0x24) != 0) &&
|
||||
(LoadKeyYFromP9(NULL, slot0x24KeyY_sha256, 0x0E6514, 0x24) != 0))
|
||||
LoadKeyFromFile(NULL, 0x24, 'Y', NULL);
|
||||
// keyY 0x24 is encrypted @0x0E62DC in the FIRM90
|
||||
// keyY 0x24 is encrypted @0x0E6514 in the FIRM81
|
||||
if ((LoadKeyYFromP9(NULL, slot0x24KeyY_sha256, 0x0E62DC, 0x24) != 0) &&
|
||||
(LoadKeyYFromP9(NULL, slot0x24KeyY_sha256, 0x0E6514, 0x24) != 0))
|
||||
LoadKeyFromFile(NULL, 0x24, 'Y', NULL);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -189,12 +190,8 @@ bool CheckSlot0x05Crypto(void)
|
||||
if (sha_cmp(slot0x05KeyY_sha256, slot0x05KeyY, 16, SHA256_MODE) == 0)
|
||||
return true;
|
||||
|
||||
// step #2 - check actual CTRNAND magic
|
||||
const u8 magic[8] = {0xE9, 0x00, 0x00, 0x43, 0x54, 0x52, 0x20, 0x20};
|
||||
const u32 sector = 0x05CAD7;
|
||||
u8 buffer[0x200];
|
||||
ReadNandSectors(buffer, sector, 1, 0x05, NAND_SYSNAND);
|
||||
if (memcmp(buffer, magic, 8) == 0)
|
||||
// step #2 - check actual presence of CTRNAND FAT
|
||||
if (GetNandPartitionInfo(NULL, NP_TYPE_STD, NP_SUBTYPE_CTR_N, 0, NAND_SYSNAND) == 0)
|
||||
return true;
|
||||
|
||||
// failed if we arrive here
|
||||
|
Loading…
x
Reference in New Issue
Block a user