forked from Mirror/SafeB9SInstaller
Fix remaing bugs + cosmetics
This commit is contained in:
parent
64b1275c39
commit
9ca9c135cc
@ -54,13 +54,13 @@ u32 ShowInstallerStatus(void) {
|
|||||||
DrawStringF(BOT_SCREEN, pos_x0, pos_y0 + 50, COLOR_STD_FONT, COLOR_STD_BG, "Backup Status :");
|
DrawStringF(BOT_SCREEN, pos_x0, pos_y0 + 50, COLOR_STD_FONT, COLOR_STD_BG, "Backup Status :");
|
||||||
DrawStringF(BOT_SCREEN, pos_x0, pos_y0 + 60, COLOR_STD_FONT, COLOR_STD_BG, "Install Status:");
|
DrawStringF(BOT_SCREEN, pos_x0, pos_y0 + 60, COLOR_STD_FONT, COLOR_STD_BG, "Install Status:");
|
||||||
|
|
||||||
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 0, COLOR_STATUS(statusA9lh) , COLOR_STD_BG, msgA9lh );
|
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 0, COLOR_STATUS(statusA9lh) , COLOR_STD_BG, "%-22.22s", msgA9lh );
|
||||||
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 10, COLOR_STATUS(statusSdCard) , COLOR_STD_BG, msgSdCard );
|
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 10, COLOR_STATUS(statusSdCard) , COLOR_STD_BG, "%-22.22s", msgSdCard );
|
||||||
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 20, COLOR_STATUS(statusFirm) , COLOR_STD_BG, msgFirm );
|
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 20, COLOR_STATUS(statusFirm) , COLOR_STD_BG, "%-22.22s", msgFirm );
|
||||||
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 30, COLOR_STATUS(statusSector) , COLOR_STD_BG, msgSector );
|
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 30, COLOR_STATUS(statusSector) , COLOR_STD_BG, "%-22.22s", msgSector );
|
||||||
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 40, COLOR_STATUS(statusCrypto) , COLOR_STD_BG, msgCrypto );
|
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 40, COLOR_STATUS(statusCrypto) , COLOR_STD_BG, "%-22.22s", msgCrypto );
|
||||||
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 50, COLOR_STATUS(statusBackup) , COLOR_STD_BG, msgBackup );
|
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 50, COLOR_STATUS(statusBackup) , COLOR_STD_BG, "%-22.22s", msgBackup );
|
||||||
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 60, COLOR_STATUS(statusInstall), COLOR_STD_BG, msgInstall);
|
DrawStringF(BOT_SCREEN, pos_x1, pos_y0 + 60, COLOR_STATUS(statusInstall), COLOR_STD_BG, "%-22.22s", msgInstall);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -73,7 +73,6 @@ u32 SafeSigHaxInstaller(void) {
|
|||||||
|
|
||||||
|
|
||||||
// step #0 - a9lh check
|
// step #0 - a9lh check
|
||||||
InitNandCrypto(); // for sector0x96 crypto and NAND drives
|
|
||||||
snprintf(msgA9lh, 64, CheckA9lh() ? "installed" : "not installed");
|
snprintf(msgA9lh, 64, CheckA9lh() ? "installed" : "not installed");
|
||||||
statusA9lh = STATUS_GREEN;
|
statusA9lh = STATUS_GREEN;
|
||||||
ShowInstallerStatus();
|
ShowInstallerStatus();
|
||||||
@ -91,6 +90,7 @@ u32 SafeSigHaxInstaller(void) {
|
|||||||
statusSdCard = STATUS_RED;
|
statusSdCard = STATUS_RED;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
InitNandCrypto(); // for sector0x96 crypto and NAND drives
|
||||||
snprintf(msgSdCard, 64, "%lluMB/%lluMB free", sdFree / (1024 * 1024), sdTotal / (1024 * 1024));
|
snprintf(msgSdCard, 64, "%lluMB/%lluMB free", sdFree / (1024 * 1024), sdTotal / (1024 * 1024));
|
||||||
statusSdCard = (sdFree < MIN_SD_FREE) ? STATUS_RED : STATUS_GREEN;
|
statusSdCard = (sdFree < MIN_SD_FREE) ? STATUS_RED : STATUS_GREEN;
|
||||||
ShowInstallerStatus();
|
ShowInstallerStatus();
|
||||||
@ -177,6 +177,8 @@ u32 SafeSigHaxInstaller(void) {
|
|||||||
if (!ShowUnlockSequence(1, "All input files verified.\nTo install FIRM, enter the sequence\nbelow or press B to cancel.")) {
|
if (!ShowUnlockSequence(1, "All input files verified.\nTo install FIRM, enter the sequence\nbelow or press B to cancel.")) {
|
||||||
snprintf(msgBackup, 64, "cancelled by user");
|
snprintf(msgBackup, 64, "cancelled by user");
|
||||||
snprintf(msgInstall, 64, "cancelled by user");
|
snprintf(msgInstall, 64, "cancelled by user");
|
||||||
|
statusBackup = STATUS_YELLOW;
|
||||||
|
statusInstall = STATUS_YELLOW;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +217,7 @@ u32 SafeSigHaxInstaller(void) {
|
|||||||
u8 sector_backup0[0x200];
|
u8 sector_backup0[0x200];
|
||||||
u8 sector_backup1[0x200];
|
u8 sector_backup1[0x200];
|
||||||
f_unlink(NAME_SECTORBACKUP);
|
f_unlink(NAME_SECTORBACKUP);
|
||||||
if ((ReadNandSectors(sector_backup0, 96, 1, 0xFF) != 0) ||
|
if ((ReadNandSectors(sector_backup0, 0x96, 1, 0xFF) != 0) ||
|
||||||
(f_qwrite(NAME_SECTORBACKUP, sector_backup0, 0, 0x200, &bt) != FR_OK) || (bt != 0x200) ||
|
(f_qwrite(NAME_SECTORBACKUP, sector_backup0, 0, 0x200, &bt) != FR_OK) || (bt != 0x200) ||
|
||||||
(f_qread(NAME_SECTORBACKUP, sector_backup1, 0, 0x200, &bt) != FR_OK) || (bt != 0x200) ||
|
(f_qread(NAME_SECTORBACKUP, sector_backup1, 0, 0x200, &bt) != FR_OK) || (bt != 0x200) ||
|
||||||
(memcmp(sector_backup0, sector_backup1, 0x200) != 0)) {
|
(memcmp(sector_backup0, sector_backup1, 0x200) != 0)) {
|
||||||
@ -230,6 +232,7 @@ u32 SafeSigHaxInstaller(void) {
|
|||||||
// backups done
|
// backups done
|
||||||
|
|
||||||
// step #6 - install sighaxed FIRM
|
// step #6 - install sighaxed FIRM
|
||||||
|
ShowPrompt(false, "Install not finished - this is only a preview");
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -11,8 +11,8 @@ static const u8 slot0x05KeyY_sha256[0x20] = { // hash for slot0x05KeyY (16 byte)
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const u8 slot0x11Key95_sha256[0x20] = { // slot0x11Key95 hash (first 16 byte of sector0x96)
|
static const u8 slot0x11Key95_sha256[0x20] = { // slot0x11Key95 hash (first 16 byte of sector0x96)
|
||||||
0xBF, 0x01, 0x4C, 0x85, 0x9B, 0xA1, 0x07, 0xFA, 0x3B, 0xAC, 0x25, 0x20, 0x1A, 0x3F, 0x3A, 0xF4,
|
0xBA, 0xC1, 0x40, 0x9C, 0x6E, 0xE4, 0x1F, 0x04, 0xAA, 0xC4, 0xE2, 0x09, 0x5C, 0xE9, 0x4F, 0x78,
|
||||||
0x4E, 0x97, 0xE9, 0x5C, 0x06, 0x46, 0xF8, 0xE7, 0xC1, 0xC2, 0xC3, 0x29, 0x88, 0xBF, 0xF6, 0x50
|
0x6C, 0x78, 0x5F, 0xAC, 0xEC, 0x7E, 0xC0, 0x11, 0x26, 0x9D, 0x4E, 0x47, 0xB3, 0x64, 0xC4, 0xA5
|
||||||
};
|
};
|
||||||
|
|
||||||
static const u8 nand_magic_n3ds[0x60] = { // NCSD NAND header N3DS magic
|
static const u8 nand_magic_n3ds[0x60] = { // NCSD NAND header N3DS magic
|
||||||
@ -95,6 +95,7 @@ bool InitNandCrypto(void)
|
|||||||
u32 NandCid[4];
|
u32 NandCid[4];
|
||||||
u8 shasum[32];
|
u8 shasum[32];
|
||||||
|
|
||||||
|
sdmmc_sdcard_init();
|
||||||
sdmmc_get_cid(1, NandCid);
|
sdmmc_get_cid(1, NandCid);
|
||||||
sha_quick(shasum, (u8*) NandCid, 16, SHA256_MODE);
|
sha_quick(shasum, (u8*) NandCid, 16, SHA256_MODE);
|
||||||
memcpy(CtrNandCtr, shasum, 16);
|
memcpy(CtrNandCtr, shasum, 16);
|
||||||
@ -131,11 +132,12 @@ bool InitNandCrypto(void)
|
|||||||
// part #3: CTRNAND N3DS KEY
|
// part #3: CTRNAND N3DS KEY
|
||||||
// thanks AuroraWright and Gelex for advice on this
|
// thanks AuroraWright and Gelex for advice on this
|
||||||
// see: https://github.com/AuroraWright/Luma3DS/blob/master/source/crypto.c#L347
|
// see: https://github.com/AuroraWright/Luma3DS/blob/master/source/crypto.c#L347
|
||||||
|
if (CheckA9lh()) { // only for a9lh
|
||||||
// keyY 0x05 is encrypted @0x0EB014 in the FIRM90
|
// keyY 0x05 is encrypted @0x0EB014 in the FIRM90
|
||||||
// keyY 0x05 is encrypted @0x0EB24C in the FIRM81
|
// keyY 0x05 is encrypted @0x0EB24C in the FIRM81
|
||||||
if ((LoadKeyYFromP9(slot0x05KeyY, slot0x05KeyY_sha256, 0x0EB014, 0x05) != 0) &&
|
if ((LoadKeyYFromP9(slot0x05KeyY, slot0x05KeyY_sha256, 0x0EB014, 0x05) != 0) &&
|
||||||
(LoadKeyYFromP9(slot0x05KeyY, slot0x05KeyY_sha256, 0x0EB24C, 0x05) != 0)) {};
|
(LoadKeyYFromP9(slot0x05KeyY, slot0x05KeyY_sha256, 0x0EB24C, 0x05) != 0)) {};
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -175,12 +177,11 @@ bool CheckFirmCrypto(void)
|
|||||||
u8 buffer[0x200];
|
u8 buffer[0x200];
|
||||||
for (u32 i = 0; i < sizeof(sectors) / sizeof(u32); i++) {
|
for (u32 i = 0; i < sizeof(sectors) / sizeof(u32); i++) {
|
||||||
ReadNandSectors(buffer, sectors[i], 1, 0x06);
|
ReadNandSectors(buffer, sectors[i], 1, 0x06);
|
||||||
ShowPrompt(false, "%016llX\n%016llX", getbe64(magic), getbe64(buffer));
|
|
||||||
if (memcmp(buffer, magic, 8) != 0) return false;
|
if (memcmp(buffer, magic, 8) != 0) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// success if we arrive here
|
// success if we arrive here
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckA9lh(void)
|
bool CheckA9lh(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user