mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-22 18:06:40 +00:00
pkg1: move warmboot rsa patching into pkg1
And create a function for hekatf to be used
This commit is contained in:
parent
ee465b98af
commit
cfd6567f5d
3 changed files with 34 additions and 27 deletions
|
@ -423,3 +423,35 @@ int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base)
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pkg1_warmboot_rsa_mod(u32 warmboot_base)
|
||||||
|
{
|
||||||
|
// Set warmboot binary rsa modulus.
|
||||||
|
u8 *rsa_mod = (u8 *)malloc(512);
|
||||||
|
|
||||||
|
sdmmc_storage_set_mmc_partition(&emmc_storage, EMMC_BOOT0);
|
||||||
|
|
||||||
|
u32 sector;
|
||||||
|
u8 mod0, mod1;
|
||||||
|
|
||||||
|
// Get the correct RSA modulus byte masks.
|
||||||
|
nx_emmc_get_autorcm_masks(&mod0, &mod1);
|
||||||
|
|
||||||
|
// Iterate BCTs.
|
||||||
|
for (u32 i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
sector = 1 + (32 * i); // 0x4000 bct + 0x200 offset.
|
||||||
|
sdmmc_storage_read(&emmc_storage, sector, 1, rsa_mod);
|
||||||
|
|
||||||
|
// Check if 2nd byte of modulus is correct.
|
||||||
|
if (rsa_mod[0x11] != mod1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Patch AutoRCM out.
|
||||||
|
rsa_mod[0x10] = mod0;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy((void *)(warmboot_base + 0x10), rsa_mod + 0x10, 0x100);
|
||||||
|
}
|
||||||
|
|
|
@ -100,5 +100,6 @@ const u8 *pkg1_unpack(void *wm_dst, u32 *wb_sz, void *sm_dst, void *ldr_dst, con
|
||||||
void pkg1_secmon_patch(void *hos_ctxt, u32 secmon_base, bool t210b01);
|
void pkg1_secmon_patch(void *hos_ctxt, u32 secmon_base, bool t210b01);
|
||||||
void pkg1_warmboot_patch(void *hos_ctxt);
|
void pkg1_warmboot_patch(void *hos_ctxt);
|
||||||
int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base);
|
int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base);
|
||||||
|
void pkg1_warmboot_rsa_mod(u32 warmboot_base);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -311,33 +311,7 @@ void config_exosphere(launch_ctxt_t *ctxt, u32 warmboot_base)
|
||||||
wb_cfg->fwno = exo_fw_no;
|
wb_cfg->fwno = exo_fw_no;
|
||||||
|
|
||||||
// Set warmboot binary rsa modulus.
|
// Set warmboot binary rsa modulus.
|
||||||
u8 *rsa_mod = (u8 *)malloc(512);
|
pkg1_warmboot_rsa_mod(warmboot_base);
|
||||||
|
|
||||||
sdmmc_storage_set_mmc_partition(&emmc_storage, EMMC_BOOT0);
|
|
||||||
|
|
||||||
u32 sector;
|
|
||||||
u8 mod0, mod1;
|
|
||||||
|
|
||||||
// Get the correct RSA modulus byte masks.
|
|
||||||
nx_emmc_get_autorcm_masks(&mod0, &mod1);
|
|
||||||
|
|
||||||
// Iterate BCTs.
|
|
||||||
for (u32 i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
sector = 1 + (32 * i); // 0x4000 bct + 0x200 offset.
|
|
||||||
sdmmc_storage_read(&emmc_storage, sector, 1, rsa_mod);
|
|
||||||
|
|
||||||
// Check if 2nd byte of modulus is correct.
|
|
||||||
if (rsa_mod[0x11] != mod1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Patch AutoRCM out.
|
|
||||||
rsa_mod[0x10] = mod0;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy((void *)(warmboot_base + 0x10), rsa_mod + 0x10, 0x100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emu_cfg.enabled && !h_cfg.emummc_force_disable)
|
if (emu_cfg.enabled && !h_cfg.emummc_force_disable)
|
||||||
|
|
Loading…
Reference in a new issue