pkg1: move warmboot rsa patching into pkg1
And create a function for hekatf to be used
This commit is contained in:
@@ -423,3 +423,35 @@ int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user