mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-26 11:42:09 +00:00
hos: rename KB defines
From KB_FIRMWARE_VERSION to HOS_KB_VERSION
This commit is contained in:
parent
5b13e81141
commit
613fdf621d
13 changed files with 131 additions and 125 deletions
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Atmosphère Fusée Secondary Storage (Package3) parser.
|
* Atmosphère Fusée Secondary Storage (Package3) parser.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019-2021 CTCaer
|
* Copyright (c) 2019-2023 CTCaer
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
@ -120,7 +120,7 @@ int parse_fss(launch_ctxt_t *ctxt, const char *path)
|
||||||
bool experimental = false;
|
bool experimental = false;
|
||||||
|
|
||||||
// Skip if stock and Exosphere and warmboot are not needed.
|
// Skip if stock and Exosphere and warmboot are not needed.
|
||||||
bool pkg1_old = ctxt->pkg1_id->kb <= KB_FIRMWARE_VERSION_620; // Should check if t210b01?
|
bool pkg1_old = ctxt->pkg1_id->kb <= HOS_KB_VERSION_620; // Should check if t210b01?
|
||||||
bool emummc_disabled = !emu_cfg.enabled || h_cfg.emummc_force_disable;
|
bool emummc_disabled = !emu_cfg.enabled || h_cfg.emummc_force_disable;
|
||||||
|
|
||||||
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ctxt->cfg->kvs, link)
|
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ctxt->cfg->kvs, link)
|
||||||
|
|
|
@ -89,7 +89,7 @@ typedef struct _kb_t
|
||||||
u8 padding[0x150];
|
u8 padding[0x150];
|
||||||
} kb_t;
|
} kb_t;
|
||||||
|
|
||||||
static const u8 keyblob_keyseeds[][SE_KEY_128_SIZE] = {
|
static const u8 keyblob_keyseeds[HOS_KB_VERSION_600 - HOS_KB_VERSION_100 + 1][SE_KEY_128_SIZE] = {
|
||||||
{ 0xDF, 0x20, 0x6F, 0x59, 0x44, 0x54, 0xEF, 0xDC, 0x70, 0x74, 0x48, 0x3B, 0x0D, 0xED, 0x9F, 0xD3 }, // 1.0.0.
|
{ 0xDF, 0x20, 0x6F, 0x59, 0x44, 0x54, 0xEF, 0xDC, 0x70, 0x74, 0x48, 0x3B, 0x0D, 0xED, 0x9F, 0xD3 }, // 1.0.0.
|
||||||
{ 0x0C, 0x25, 0x61, 0x5D, 0x68, 0x4C, 0xEB, 0x42, 0x1C, 0x23, 0x79, 0xEA, 0x82, 0x25, 0x12, 0xAC }, // 3.0.0.
|
{ 0x0C, 0x25, 0x61, 0x5D, 0x68, 0x4C, 0xEB, 0x42, 0x1C, 0x23, 0x79, 0xEA, 0x82, 0x25, 0x12, 0xAC }, // 3.0.0.
|
||||||
{ 0x33, 0x76, 0x85, 0xEE, 0x88, 0x4A, 0xAE, 0x0A, 0xC2, 0x8A, 0xFD, 0x7D, 0x63, 0xC0, 0x43, 0x3B }, // 3.0.1.
|
{ 0x33, 0x76, 0x85, 0xEE, 0x88, 0x4A, 0xAE, 0x0A, 0xC2, 0x8A, 0xFD, 0x7D, 0x63, 0xC0, 0x43, 0x3B }, // 3.0.1.
|
||||||
|
@ -111,7 +111,7 @@ static const u8 master_kekseed_620[SE_KEY_128_SIZE] =
|
||||||
{ 0x37, 0x4B, 0x77, 0x29, 0x59, 0xB4, 0x04, 0x30, 0x81, 0xF6, 0xE5, 0x8C, 0x6D, 0x36, 0x17, 0x9A };
|
{ 0x37, 0x4B, 0x77, 0x29, 0x59, 0xB4, 0x04, 0x30, 0x81, 0xF6, 0xE5, 0x8C, 0x6D, 0x36, 0x17, 0x9A };
|
||||||
|
|
||||||
//!TODO: Update on tsec/mkey changes.
|
//!TODO: Update on tsec/mkey changes.
|
||||||
static const u8 master_kekseed_t210_tsec_v4[][SE_KEY_128_SIZE] = {
|
static const u8 master_kekseed_t210_tsec_v4[HOS_KB_VERSION_MAX - HOS_KB_VERSION_810 + 1][SE_KEY_128_SIZE] = {
|
||||||
{ 0xDE, 0xDC, 0xE3, 0x39, 0x30, 0x88, 0x16, 0xF8, 0xAE, 0x97, 0xAD, 0xEC, 0x64, 0x2D, 0x41, 0x41 }, // 8.1.0.
|
{ 0xDE, 0xDC, 0xE3, 0x39, 0x30, 0x88, 0x16, 0xF8, 0xAE, 0x97, 0xAD, 0xEC, 0x64, 0x2D, 0x41, 0x41 }, // 8.1.0.
|
||||||
{ 0x1A, 0xEC, 0x11, 0x82, 0x2B, 0x32, 0x38, 0x7A, 0x2B, 0xED, 0xBA, 0x01, 0x47, 0x7E, 0x3B, 0x67 }, // 9.0.0.
|
{ 0x1A, 0xEC, 0x11, 0x82, 0x2B, 0x32, 0x38, 0x7A, 0x2B, 0xED, 0xBA, 0x01, 0x47, 0x7E, 0x3B, 0x67 }, // 9.0.0.
|
||||||
{ 0x30, 0x3F, 0x02, 0x7E, 0xD8, 0x38, 0xEC, 0xD7, 0x93, 0x25, 0x34, 0xB5, 0x30, 0xEB, 0xCA, 0x7A }, // 9.1.0.
|
{ 0x30, 0x3F, 0x02, 0x7E, 0xD8, 0x38, 0xEC, 0xD7, 0x93, 0x25, 0x34, 0xB5, 0x30, 0xEB, 0xCA, 0x7A }, // 9.1.0.
|
||||||
|
@ -123,7 +123,7 @@ static const u8 master_kekseed_t210_tsec_v4[][SE_KEY_128_SIZE] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
//!TODO: Update on mkey changes.
|
//!TODO: Update on mkey changes.
|
||||||
static const u8 master_kekseed_t210b01[][SE_KEY_128_SIZE] = {
|
static const u8 master_kekseed_t210b01[HOS_KB_VERSION_MAX - HOS_KB_VERSION_600 + 1][SE_KEY_128_SIZE] = {
|
||||||
{ 0x77, 0x60, 0x5A, 0xD2, 0xEE, 0x6E, 0xF8, 0x3C, 0x3F, 0x72, 0xE2, 0x59, 0x9D, 0xAC, 0x5E, 0x56 }, // 6.0.0.
|
{ 0x77, 0x60, 0x5A, 0xD2, 0xEE, 0x6E, 0xF8, 0x3C, 0x3F, 0x72, 0xE2, 0x59, 0x9D, 0xAC, 0x5E, 0x56 }, // 6.0.0.
|
||||||
{ 0x1E, 0x80, 0xB8, 0x17, 0x3E, 0xC0, 0x60, 0xAA, 0x11, 0xBE, 0x1A, 0x4A, 0xA6, 0x6F, 0xE4, 0xAE }, // 6.2.0.
|
{ 0x1E, 0x80, 0xB8, 0x17, 0x3E, 0xC0, 0x60, 0xAA, 0x11, 0xBE, 0x1A, 0x4A, 0xA6, 0x6F, 0xE4, 0xAE }, // 6.2.0.
|
||||||
{ 0x94, 0x08, 0x67, 0xBD, 0x0A, 0x00, 0x38, 0x84, 0x11, 0xD3, 0x1A, 0xDB, 0xDD, 0x8D, 0xF1, 0x8A }, // 7.0.0.
|
{ 0x94, 0x08, 0x67, 0xBD, 0x0A, 0x00, 0x38, 0x84, 0x11, 0xD3, 0x1A, 0xDB, 0xDD, 0x8D, 0xF1, 0x8A }, // 7.0.0.
|
||||||
|
@ -302,7 +302,7 @@ void hos_eks_clear(u32 kb)
|
||||||
if (h_cfg.t210b01)
|
if (h_cfg.t210b01)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (h_cfg.eks && kb >= KB_FIRMWARE_VERSION_700)
|
if (h_cfg.eks && kb >= HOS_KB_VERSION_700)
|
||||||
{
|
{
|
||||||
// Check if current Master key is enabled.
|
// Check if current Master key is enabled.
|
||||||
if (h_cfg.eks->enabled)
|
if (h_cfg.eks->enabled)
|
||||||
|
@ -337,7 +337,7 @@ int hos_keygen_t210b01(u32 kb)
|
||||||
se_aes_unwrap_key(10, 14, console_keyseed_4xx);
|
se_aes_unwrap_key(10, 14, console_keyseed_4xx);
|
||||||
|
|
||||||
// Derive master key.
|
// Derive master key.
|
||||||
se_aes_unwrap_key(7, 12, master_kekseed_t210b01[kb - KB_FIRMWARE_VERSION_600]);
|
se_aes_unwrap_key(7, 12, master_kekseed_t210b01[kb - HOS_KB_VERSION_600]);
|
||||||
se_aes_unwrap_key(7, 7, master_keyseed_retail);
|
se_aes_unwrap_key(7, 7, master_keyseed_retail);
|
||||||
|
|
||||||
// Derive latest pkg2 key.
|
// Derive latest pkg2 key.
|
||||||
|
@ -355,7 +355,7 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, bool stock, bool i
|
||||||
tsec_keys_t tsec_keys;
|
tsec_keys_t tsec_keys;
|
||||||
kb_t *kb_data = (kb_t *)keyblob;
|
kb_t *kb_data = (kb_t *)keyblob;
|
||||||
|
|
||||||
if (kb > KB_FIRMWARE_VERSION_MAX)
|
if (kb > HOS_KB_VERSION_MAX)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (h_cfg.t210b01)
|
if (h_cfg.t210b01)
|
||||||
|
@ -376,15 +376,15 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, bool stock, bool i
|
||||||
_hos_eks_get();
|
_hos_eks_get();
|
||||||
|
|
||||||
// Use tsec keygen for old firmware or if EKS keys does not exist for newer.
|
// Use tsec keygen for old firmware or if EKS keys does not exist for newer.
|
||||||
if (kb <= KB_FIRMWARE_VERSION_620 || !h_cfg.eks || (h_cfg.eks && h_cfg.eks->enabled != HOS_EKS_TSEC_VER))
|
if (kb <= HOS_KB_VERSION_620 || !h_cfg.eks || (h_cfg.eks && h_cfg.eks->enabled != HOS_EKS_TSEC_VER))
|
||||||
use_tsec = true;
|
use_tsec = true;
|
||||||
|
|
||||||
if (kb <= KB_FIRMWARE_VERSION_600)
|
if (kb <= HOS_KB_VERSION_600)
|
||||||
{
|
{
|
||||||
tsec_ctxt->size = 0xF00;
|
tsec_ctxt->size = 0xF00;
|
||||||
tsec_ctxt->type = TSEC_FW_TYPE_OLD;
|
tsec_ctxt->type = TSEC_FW_TYPE_OLD;
|
||||||
}
|
}
|
||||||
else if (kb == KB_FIRMWARE_VERSION_620)
|
else if (kb == HOS_KB_VERSION_620)
|
||||||
{
|
{
|
||||||
tsec_ctxt->size = 0x2900;
|
tsec_ctxt->size = 0x2900;
|
||||||
tsec_ctxt->type = TSEC_FW_TYPE_EMU;
|
tsec_ctxt->type = TSEC_FW_TYPE_EMU;
|
||||||
|
@ -434,7 +434,7 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, bool stock, bool i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kb >= KB_FIRMWARE_VERSION_700)
|
if (kb >= HOS_KB_VERSION_700)
|
||||||
{
|
{
|
||||||
// For 7.0.0 and up, save EKS slot if it doesn't exist.
|
// For 7.0.0 and up, save EKS slot if it doesn't exist.
|
||||||
if (use_tsec)
|
if (use_tsec)
|
||||||
|
@ -445,8 +445,8 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, bool stock, bool i
|
||||||
|
|
||||||
// Use 8.1.0 for 7.0.0 otherwise the proper one.
|
// Use 8.1.0 for 7.0.0 otherwise the proper one.
|
||||||
u32 mkey_idx = 0;
|
u32 mkey_idx = 0;
|
||||||
if (kb >= KB_FIRMWARE_VERSION_810)
|
if (kb >= HOS_KB_VERSION_810)
|
||||||
mkey_idx = kb - KB_FIRMWARE_VERSION_810;
|
mkey_idx = kb - HOS_KB_VERSION_810;
|
||||||
|
|
||||||
if (!is_exo)
|
if (!is_exo)
|
||||||
{
|
{
|
||||||
|
@ -475,7 +475,7 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, bool stock, bool i
|
||||||
se_aes_unwrap_key(8, 13, package2_keyseed);
|
se_aes_unwrap_key(8, 13, package2_keyseed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (kb == KB_FIRMWARE_VERSION_620)
|
else if (kb == HOS_KB_VERSION_620)
|
||||||
{
|
{
|
||||||
// Set TSEC key.
|
// Set TSEC key.
|
||||||
se_aes_key_set(12, tsec_keys.tsec, SE_KEY_128_SIZE);
|
se_aes_key_set(12, tsec_keys.tsec, SE_KEY_128_SIZE);
|
||||||
|
@ -552,21 +552,21 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, bool stock, bool i
|
||||||
{
|
{
|
||||||
switch (kb)
|
switch (kb)
|
||||||
{
|
{
|
||||||
case KB_FIRMWARE_VERSION_100:
|
case HOS_KB_VERSION_100:
|
||||||
case KB_FIRMWARE_VERSION_300:
|
case HOS_KB_VERSION_300:
|
||||||
case KB_FIRMWARE_VERSION_301:
|
case HOS_KB_VERSION_301:
|
||||||
se_aes_unwrap_key(13, 15, console_keyseed);
|
se_aes_unwrap_key(13, 15, console_keyseed);
|
||||||
se_aes_unwrap_key(12, 12, master_keyseed_retail);
|
se_aes_unwrap_key(12, 12, master_keyseed_retail);
|
||||||
break;
|
break;
|
||||||
case KB_FIRMWARE_VERSION_400:
|
case HOS_KB_VERSION_400:
|
||||||
se_aes_unwrap_key(13, 15, console_keyseed_4xx);
|
se_aes_unwrap_key(13, 15, console_keyseed_4xx);
|
||||||
se_aes_unwrap_key(15, 15, console_keyseed);
|
se_aes_unwrap_key(15, 15, console_keyseed);
|
||||||
se_aes_unwrap_key(14, 12, master_keyseed_4xx);
|
se_aes_unwrap_key(14, 12, master_keyseed_4xx);
|
||||||
se_aes_unwrap_key(12, 12, master_keyseed_retail);
|
se_aes_unwrap_key(12, 12, master_keyseed_retail);
|
||||||
sbk_wiped = true;
|
sbk_wiped = true;
|
||||||
break;
|
break;
|
||||||
case KB_FIRMWARE_VERSION_500:
|
case HOS_KB_VERSION_500:
|
||||||
case KB_FIRMWARE_VERSION_600:
|
case HOS_KB_VERSION_600:
|
||||||
se_aes_unwrap_key(10, 15, console_keyseed_4xx);
|
se_aes_unwrap_key(10, 15, console_keyseed_4xx);
|
||||||
se_aes_unwrap_key(15, 15, console_keyseed);
|
se_aes_unwrap_key(15, 15, console_keyseed);
|
||||||
se_aes_unwrap_key(14, 12, master_keyseed_4xx);
|
se_aes_unwrap_key(14, 12, master_keyseed_4xx);
|
||||||
|
@ -642,7 +642,7 @@ try_load:
|
||||||
gfx_printf("Identified pkg1 and mkey %d\n\n", ctxt->pkg1_id->kb);
|
gfx_printf("Identified pkg1 and mkey %d\n\n", ctxt->pkg1_id->kb);
|
||||||
|
|
||||||
// Read the correct keyblob for older HOS versions.
|
// Read the correct keyblob for older HOS versions.
|
||||||
if (ctxt->pkg1_id->kb <= KB_FIRMWARE_VERSION_600)
|
if (ctxt->pkg1_id->kb <= HOS_KB_VERSION_600)
|
||||||
{
|
{
|
||||||
ctxt->keyblob = (u8 *)calloc(EMMC_BLOCKSIZE, 1);
|
ctxt->keyblob = (u8 *)calloc(EMMC_BLOCKSIZE, 1);
|
||||||
emummc_storage_read(PKG1_HOS_KEYBLOBS_OFFSET / EMMC_BLOCKSIZE + ctxt->pkg1_id->kb, 1, ctxt->keyblob);
|
emummc_storage_read(PKG1_HOS_KEYBLOBS_OFFSET / EMMC_BLOCKSIZE + ctxt->pkg1_id->kb, 1, ctxt->keyblob);
|
||||||
|
@ -865,7 +865,7 @@ int hos_launch(ini_sec_t *cfg)
|
||||||
if (!ctxt.warmboot || !ctxt.secmon)
|
if (!ctxt.warmboot || !ctxt.secmon)
|
||||||
{
|
{
|
||||||
// Decrypt PK1 or PK11.
|
// Decrypt PK1 or PK11.
|
||||||
if (kb <= KB_FIRMWARE_VERSION_600 || h_cfg.t210b01)
|
if (kb <= HOS_KB_VERSION_600 || h_cfg.t210b01)
|
||||||
{
|
{
|
||||||
if (!pkg1_decrypt(ctxt.pkg1_id, ctxt.pkg1))
|
if (!pkg1_decrypt(ctxt.pkg1_id, ctxt.pkg1))
|
||||||
{
|
{
|
||||||
|
@ -886,7 +886,7 @@ int hos_launch(ini_sec_t *cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unpack PK11.
|
// Unpack PK11.
|
||||||
if (h_cfg.t210b01 || (kb <= KB_FIRMWARE_VERSION_620 && !emummc_enabled))
|
if (h_cfg.t210b01 || (kb <= HOS_KB_VERSION_620 && !emummc_enabled))
|
||||||
{
|
{
|
||||||
// Skip T210B01 OEM header.
|
// Skip T210B01 OEM header.
|
||||||
u32 pk1_offset = 0;
|
u32 pk1_offset = 0;
|
||||||
|
@ -925,7 +925,7 @@ int hos_launch(ini_sec_t *cfg)
|
||||||
else if (!h_cfg.t210b01)
|
else if (!h_cfg.t210b01)
|
||||||
{
|
{
|
||||||
// Patch warmboot on T210 to allow downgrading.
|
// Patch warmboot on T210 to allow downgrading.
|
||||||
if (kb >= KB_FIRMWARE_VERSION_700)
|
if (kb >= HOS_KB_VERSION_700)
|
||||||
{
|
{
|
||||||
_hos_crit_error("No warmboot provided!");
|
_hos_crit_error("No warmboot provided!");
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -1026,7 +1026,7 @@ int hos_launch(ini_sec_t *cfg)
|
||||||
pkg2_merge_kip(&kip1_info, (pkg2_kip1_t *)mki->kip1);
|
pkg2_merge_kip(&kip1_info, (pkg2_kip1_t *)mki->kip1);
|
||||||
|
|
||||||
// Check if FS is compatible with exFAT and if 5.1.0.
|
// Check if FS is compatible with exFAT and if 5.1.0.
|
||||||
if (!ctxt.stock && (sd_fs.fs_type == FS_EXFAT || kb == KB_FIRMWARE_VERSION_500 || ctxt.pkg1_id->fuses == 13))
|
if (!ctxt.stock && (sd_fs.fs_type == FS_EXFAT || kb == HOS_KB_VERSION_500 || ctxt.pkg1_id->fuses == 13))
|
||||||
{
|
{
|
||||||
bool exfat_compat = _get_fs_exfat_compatible(&kip1_info, &ctxt.exo_ctx.hos_revision);
|
bool exfat_compat = _get_fs_exfat_compatible(&kip1_info, &ctxt.exo_ctx.hos_revision);
|
||||||
|
|
||||||
|
@ -1090,23 +1090,23 @@ int hos_launch(ini_sec_t *cfg)
|
||||||
// Finalize per firmware key access. Skip access control if Exosphere 2.
|
// Finalize per firmware key access. Skip access control if Exosphere 2.
|
||||||
switch (kb | (is_exo << 7))
|
switch (kb | (is_exo << 7))
|
||||||
{
|
{
|
||||||
case KB_FIRMWARE_VERSION_100:
|
case HOS_KB_VERSION_100:
|
||||||
case KB_FIRMWARE_VERSION_300:
|
case HOS_KB_VERSION_300:
|
||||||
case KB_FIRMWARE_VERSION_301:
|
case HOS_KB_VERSION_301:
|
||||||
se_key_acc_ctrl(12, SE_KEY_TBL_DIS_KEY_ACCESS_FLAG | SE_KEY_LOCK_FLAG);
|
se_key_acc_ctrl(12, SE_KEY_TBL_DIS_KEY_ACCESS_FLAG | SE_KEY_LOCK_FLAG);
|
||||||
se_key_acc_ctrl(13, SE_KEY_TBL_DIS_KEY_ACCESS_FLAG | SE_KEY_LOCK_FLAG);
|
se_key_acc_ctrl(13, SE_KEY_TBL_DIS_KEY_ACCESS_FLAG | SE_KEY_LOCK_FLAG);
|
||||||
pkg1_state_pkg2_ready = PKG1_STATE_PKG2_READY_OLD;
|
pkg1_state_pkg2_ready = PKG1_STATE_PKG2_READY_OLD;
|
||||||
break;
|
break;
|
||||||
case KB_FIRMWARE_VERSION_400:
|
case HOS_KB_VERSION_400:
|
||||||
case KB_FIRMWARE_VERSION_500:
|
case HOS_KB_VERSION_500:
|
||||||
case KB_FIRMWARE_VERSION_600:
|
case HOS_KB_VERSION_600:
|
||||||
se_key_acc_ctrl(12, SE_KEY_TBL_DIS_KEY_ACCESS_FLAG | SE_KEY_LOCK_FLAG);
|
se_key_acc_ctrl(12, SE_KEY_TBL_DIS_KEY_ACCESS_FLAG | SE_KEY_LOCK_FLAG);
|
||||||
se_key_acc_ctrl(15, SE_KEY_TBL_DIS_KEY_ACCESS_FLAG | SE_KEY_LOCK_FLAG);
|
se_key_acc_ctrl(15, SE_KEY_TBL_DIS_KEY_ACCESS_FLAG | SE_KEY_LOCK_FLAG);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear BCT area for retail units and copy it over if dev unit.
|
// Clear BCT area for retail units and copy it over if dev unit.
|
||||||
if (kb <= KB_FIRMWARE_VERSION_500 && !is_exo)
|
if (kb <= HOS_KB_VERSION_500 && !is_exo)
|
||||||
{
|
{
|
||||||
memset((void *)SECMON_BCT_CFG_ADDR, 0, SZ_4K + SZ_8K);
|
memset((void *)SECMON_BCT_CFG_ADDR, 0, SZ_4K + SZ_8K);
|
||||||
if (fuse_read_hw_state() == FUSE_NX_HW_STATE_DEV)
|
if (fuse_read_hw_state() == FUSE_NX_HW_STATE_DEV)
|
||||||
|
@ -1120,14 +1120,14 @@ int hos_launch(ini_sec_t *cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finalize MC carveout.
|
// Finalize MC carveout.
|
||||||
if (kb <= KB_FIRMWARE_VERSION_301 && !is_exo)
|
if (kb <= HOS_KB_VERSION_301 && !is_exo)
|
||||||
mc_config_carveout();
|
mc_config_carveout();
|
||||||
|
|
||||||
// Lock SE before starting 'SecureMonitor' if < 6.2.0, otherwise lock bootrom and ipatches.
|
// Lock SE before starting 'SecureMonitor' if < 6.2.0, otherwise lock bootrom and ipatches.
|
||||||
_se_lock(kb <= KB_FIRMWARE_VERSION_600 && !is_exo);
|
_se_lock(kb <= HOS_KB_VERSION_600 && !is_exo);
|
||||||
|
|
||||||
// Reset sysctr0 counters.
|
// Reset sysctr0 counters.
|
||||||
if (kb >= KB_FIRMWARE_VERSION_620)
|
if (kb >= HOS_KB_VERSION_620)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < SYSCTR0_COUNTERS; i += sizeof(u32))
|
for (u32 i = 0; i < SYSCTR0_COUNTERS; i += sizeof(u32))
|
||||||
SYSCTR0(SYSCTR0_COUNTERS_BASE + i) = 0;
|
SYSCTR0(SYSCTR0_COUNTERS_BASE + i) = 0;
|
||||||
|
@ -1137,14 +1137,14 @@ int hos_launch(ini_sec_t *cfg)
|
||||||
//pmc_scratch_lock(PMC_SEC_LOCK_LP0_PARAMS);
|
//pmc_scratch_lock(PMC_SEC_LOCK_LP0_PARAMS);
|
||||||
|
|
||||||
// Set secmon mailbox address and clear it.
|
// Set secmon mailbox address and clear it.
|
||||||
if (kb >= KB_FIRMWARE_VERSION_700 || is_exo)
|
if (kb >= HOS_KB_VERSION_700 || is_exo)
|
||||||
{
|
{
|
||||||
memset((void *)SECMON7_MAILBOX_ADDR, 0, 0x200);
|
memset((void *)SECMON7_MAILBOX_ADDR, 0, 0x200);
|
||||||
secmon_mailbox = (secmon_mailbox_t *)(SECMON7_MAILBOX_ADDR + SECMON_STATE_OFFSET);
|
secmon_mailbox = (secmon_mailbox_t *)(SECMON7_MAILBOX_ADDR + SECMON_STATE_OFFSET);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (kb <= KB_FIRMWARE_VERSION_301)
|
if (kb <= HOS_KB_VERSION_301)
|
||||||
memset((void *)SECMON_MAILBOX_ADDR, 0, 0x200);
|
memset((void *)SECMON_MAILBOX_ADDR, 0, 0x200);
|
||||||
secmon_mailbox = (secmon_mailbox_t *)(SECMON_MAILBOX_ADDR + SECMON_STATE_OFFSET);
|
secmon_mailbox = (secmon_mailbox_t *)(SECMON_MAILBOX_ADDR + SECMON_STATE_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,29 +25,32 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define KB_FIRMWARE_VERSION_100 0
|
//!TODO: Update on mkey changes.
|
||||||
#define KB_FIRMWARE_VERSION_300 1
|
enum {
|
||||||
#define KB_FIRMWARE_VERSION_301 2
|
HOS_KB_VERSION_100 = 0,
|
||||||
#define KB_FIRMWARE_VERSION_400 3
|
HOS_KB_VERSION_300 = 1,
|
||||||
#define KB_FIRMWARE_VERSION_500 4
|
HOS_KB_VERSION_301 = 2,
|
||||||
#define KB_FIRMWARE_VERSION_600 5
|
HOS_KB_VERSION_400 = 3,
|
||||||
#define KB_FIRMWARE_VERSION_620 6
|
HOS_KB_VERSION_500 = 4,
|
||||||
#define KB_FIRMWARE_VERSION_700 7
|
HOS_KB_VERSION_600 = 5,
|
||||||
#define KB_FIRMWARE_VERSION_810 8
|
HOS_KB_VERSION_620 = 6,
|
||||||
#define KB_FIRMWARE_VERSION_900 9
|
HOS_KB_VERSION_700 = 7,
|
||||||
#define KB_FIRMWARE_VERSION_910 10
|
HOS_KB_VERSION_810 = 8,
|
||||||
#define KB_FIRMWARE_VERSION_1210 11
|
HOS_KB_VERSION_900 = 9,
|
||||||
#define KB_FIRMWARE_VERSION_1300 12
|
HOS_KB_VERSION_910 = 10,
|
||||||
#define KB_FIRMWARE_VERSION_1400 13
|
HOS_KB_VERSION_1210 = 11,
|
||||||
#define KB_FIRMWARE_VERSION_1500 14
|
HOS_KB_VERSION_1300 = 12,
|
||||||
#define KB_FIRMWARE_VERSION_1600 15
|
HOS_KB_VERSION_1400 = 13,
|
||||||
#define KB_FIRMWARE_VERSION_MAX KB_FIRMWARE_VERSION_1600 //!TODO: Update on mkey changes.
|
HOS_KB_VERSION_1500 = 14,
|
||||||
|
HOS_KB_VERSION_1600 = 15,
|
||||||
|
HOS_KB_VERSION_MAX
|
||||||
|
};
|
||||||
|
|
||||||
#define HOS_TSEC_VERSION 4 //! TODO: Update on TSEC Root Key changes.
|
#define HOS_TSEC_VERSION 4 //! TODO: Update on TSEC Root Key changes.
|
||||||
|
|
||||||
#define HOS_PKG11_MAGIC 0x31314B50
|
#define HOS_PKG11_MAGIC 0x31314B50
|
||||||
#define HOS_EKS_MAGIC 0x31534B45 // EKS1.
|
#define HOS_EKS_MAGIC 0x31534B45 // EKS1.
|
||||||
#define HOS_EKS_TSEC_VER (KB_FIRMWARE_VERSION_700 + HOS_TSEC_VERSION)
|
#define HOS_EKS_TSEC_VER (HOS_KB_VERSION_700 + HOS_TSEC_VERSION)
|
||||||
|
|
||||||
// Use official Mariko secmon when in stock. Needs access to TZRAM.
|
// Use official Mariko secmon when in stock. Needs access to TZRAM.
|
||||||
//#define HOS_MARIKO_STOCK_SECMON
|
//#define HOS_MARIKO_STOCK_SECMON
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 naehrwert
|
* Copyright (c) 2018 naehrwert
|
||||||
* Copyright (c) 2018 st4rk
|
* Copyright (c) 2018 st4rk
|
||||||
* Copyright (c) 2018-2021 CTCaer
|
* Copyright (c) 2018-2023 CTCaer
|
||||||
* Copyright (c) 2018 balika011
|
* Copyright (c) 2018 balika011
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
@ -278,9 +278,9 @@ void pkg1_secmon_patch(void *hos_ctxt, u32 secmon_base, bool t210b01)
|
||||||
else if (t210b01)
|
else if (t210b01)
|
||||||
{
|
{
|
||||||
// For T210B01 we patch 6.X.X as is. Otherwise we decompress the program payload.
|
// For T210B01 we patch 6.X.X as is. Otherwise we decompress the program payload.
|
||||||
if (ctxt->pkg1_id->kb == KB_FIRMWARE_VERSION_600)
|
if (ctxt->pkg1_id->kb == HOS_KB_VERSION_600)
|
||||||
secmon_patchset = _secmon_6_mariko_patchset;
|
secmon_patchset = _secmon_6_mariko_patchset;
|
||||||
else if (ctxt->pkg1_id->kb == KB_FIRMWARE_VERSION_620)
|
else if (ctxt->pkg1_id->kb == HOS_KB_VERSION_620)
|
||||||
secmon_patchset = _secmon_620_mariko_patchset;
|
secmon_patchset = _secmon_620_mariko_patchset;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -289,9 +289,9 @@ void pkg1_secmon_patch(void *hos_ctxt, u32 secmon_base, bool t210b01)
|
||||||
memset((void *)TZRAM_PROG_ADDR, 0, 0x38800);
|
memset((void *)TZRAM_PROG_ADDR, 0, 0x38800);
|
||||||
|
|
||||||
// Get size of compressed program payload and set patch offset.
|
// Get size of compressed program payload and set patch offset.
|
||||||
u32 idx = ctxt->pkg1_id->kb - KB_FIRMWARE_VERSION_700;
|
u32 idx = ctxt->pkg1_id->kb - HOS_KB_VERSION_700;
|
||||||
u32 patch_offset = TZRAM_PROG_PK2_SIG_PATCH;
|
u32 patch_offset = TZRAM_PROG_PK2_SIG_PATCH;
|
||||||
if (ctxt->pkg1_id->kb > KB_FIRMWARE_VERSION_910 || !memcmp(ctxt->pkg1_id->id, "20200303104606", 8)) //TODO: Add 11.0.0 support.
|
if (ctxt->pkg1_id->kb > HOS_KB_VERSION_910 || !memcmp(ctxt->pkg1_id->id, "20200303104606", 8)) //TODO: Add 11.0.0 support.
|
||||||
{
|
{
|
||||||
idx++;
|
idx++;
|
||||||
patch_offset = TZRAM_PROG_PK2_SIG_PATCH_1000;
|
patch_offset = TZRAM_PROG_PK2_SIG_PATCH_1000;
|
||||||
|
@ -419,13 +419,13 @@ int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base, u32 fuses_fw, u8 kb)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Set warmboot address in PMC if required.
|
// Set warmboot address in PMC if required.
|
||||||
if (kb <= KB_FIRMWARE_VERSION_301)
|
if (kb <= HOS_KB_VERSION_301)
|
||||||
PMC(APBDEV_PMC_SCRATCH1) = warmboot_base;
|
PMC(APBDEV_PMC_SCRATCH1) = warmboot_base;
|
||||||
|
|
||||||
// Set Warmboot Physical Address ID for 3.0.0 - 3.0.2.
|
// Set Warmboot Physical Address ID for 3.0.0 - 3.0.2.
|
||||||
if (kb == KB_FIRMWARE_VERSION_300)
|
if (kb == HOS_KB_VERSION_300)
|
||||||
PMC(APBDEV_PMC_SECURE_SCRATCH32) = 0xE3; // Warmboot 3.0.0 PA address id.
|
PMC(APBDEV_PMC_SECURE_SCRATCH32) = 0xE3; // Warmboot 3.0.0 PA address id.
|
||||||
else if (kb == KB_FIRMWARE_VERSION_301)
|
else if (kb == HOS_KB_VERSION_301)
|
||||||
PMC(APBDEV_PMC_SECURE_SCRATCH32) = 0x104; // Warmboot 3.0.1/.2 PA address id.
|
PMC(APBDEV_PMC_SECURE_SCRATCH32) = 0x104; // Warmboot 3.0.1/.2 PA address id.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 naehrwert
|
* Copyright (c) 2018 naehrwert
|
||||||
* Copyright (c) 2018-2022 CTCaer
|
* Copyright (c) 2018-2023 CTCaer
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
@ -667,7 +667,7 @@ pkg2_hdr_t *pkg2_decrypt(void *data, u8 kb, bool is_exo)
|
||||||
pkg2_keyslot = 8;
|
pkg2_keyslot = 8;
|
||||||
|
|
||||||
// Decrypt 7.0.0 pkg2 via 8.1.0 mkey on Erista.
|
// Decrypt 7.0.0 pkg2 via 8.1.0 mkey on Erista.
|
||||||
if (!h_cfg.t210b01 && kb == KB_FIRMWARE_VERSION_700)
|
if (!h_cfg.t210b01 && kb == HOS_KB_VERSION_700)
|
||||||
{
|
{
|
||||||
u8 tmp_mkey[SE_KEY_128_SIZE];
|
u8 tmp_mkey[SE_KEY_128_SIZE];
|
||||||
|
|
||||||
|
@ -758,7 +758,7 @@ void pkg2_build_encrypt(void *dst, void *hos_ctxt, link_t *kips_info, bool is_ex
|
||||||
u8 key_ver = kb ? kb + 1 : 0;
|
u8 key_ver = kb ? kb + 1 : 0;
|
||||||
if (pkg2_keyslot == 9)
|
if (pkg2_keyslot == 9)
|
||||||
{
|
{
|
||||||
key_ver = KB_FIRMWARE_VERSION_810 + 1;
|
key_ver = HOS_KB_VERSION_810 + 1;
|
||||||
pkg2_keyslot = 8;
|
pkg2_keyslot = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 naehrwert
|
* Copyright (c) 2018 naehrwert
|
||||||
* Copyright (c) 2018-2022 CTCaer
|
* Copyright (c) 2018-2023 CTCaer
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
|
|
@ -163,7 +163,7 @@ void config_exosphere(launch_ctxt_t *ctxt, u32 warmboot_base)
|
||||||
exo_fw_no = ctxt->pkg1_id->fuses - 1; // 3.0.1 - 7.0.1, 8.0.x.
|
exo_fw_no = ctxt->pkg1_id->fuses - 1; // 3.0.1 - 7.0.1, 8.0.x.
|
||||||
|
|
||||||
// Set 12.1.0 specific revision.
|
// Set 12.1.0 specific revision.
|
||||||
if (ctxt->pkg1_id->kb == KB_FIRMWARE_VERSION_1210)
|
if (ctxt->pkg1_id->kb == HOS_KB_VERSION_1210)
|
||||||
ctxt->exo_ctx.hos_revision = 1;
|
ctxt->exo_ctx.hos_revision = 1;
|
||||||
|
|
||||||
// Handle 15.0.0+.
|
// Handle 15.0.0+.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 naehrwert
|
* Copyright (c) 2018 naehrwert
|
||||||
* Copyright (c) 2018 Rajko Stojadinovic
|
* Copyright (c) 2018 Rajko Stojadinovic
|
||||||
* Copyright (c) 2018-2022 CTCaer
|
* Copyright (c) 2018-2023 CTCaer
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
@ -797,7 +797,7 @@ static int _emummc_raw_derive_bis_keys(emmc_tool_gui_t *gui, u32 resized_count)
|
||||||
if (memcmp(&cal0->magic, "CAL0", 4))
|
if (memcmp(&cal0->magic, "CAL0", 4))
|
||||||
{
|
{
|
||||||
// Clear EKS keys.
|
// Clear EKS keys.
|
||||||
hos_eks_clear(KB_FIRMWARE_VERSION_MAX);
|
hos_eks_clear(HOS_KB_VERSION_MAX);
|
||||||
|
|
||||||
strcpy(txt_buf, "#FFDD00 BIS keys validation failed!#\n");
|
strcpy(txt_buf, "#FFDD00 BIS keys validation failed!#\n");
|
||||||
error = true;
|
error = true;
|
||||||
|
|
|
@ -1215,7 +1215,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||||
hos_keygen(keyblob, kb, &tsec_ctxt);
|
hos_keygen(keyblob, kb, &tsec_ctxt);
|
||||||
free(keyblob);
|
free(keyblob);
|
||||||
|
|
||||||
if (h_cfg.t210b01 || kb <= KB_FIRMWARE_VERSION_600)
|
if (h_cfg.t210b01 || kb <= HOS_KB_VERSION_600)
|
||||||
{
|
{
|
||||||
if (!pkg1_decrypt(pkg1_id, pkg1))
|
if (!pkg1_decrypt(pkg1_id, pkg1))
|
||||||
{
|
{
|
||||||
|
@ -1227,7 +1227,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h_cfg.t210b01 || kb <= KB_FIRMWARE_VERSION_620)
|
if (h_cfg.t210b01 || kb <= HOS_KB_VERSION_620)
|
||||||
{
|
{
|
||||||
pkg1_unpack(warmboot, secmon, loader, pkg1_id, pkg1 + pk1_offset);
|
pkg1_unpack(warmboot, secmon, loader, pkg1_id, pkg1 + pk1_offset);
|
||||||
pk11_hdr_t *hdr_pk11 = (pk11_hdr_t *)(pkg1 + pk1_offset + pkg1_id->pkg11_off + 0x20);
|
pk11_hdr_t *hdr_pk11 = (pk11_hdr_t *)(pkg1 + pk1_offset + pkg1_id->pkg11_off + 0x20);
|
||||||
|
@ -1361,12 +1361,12 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||||
manual_system_maintenance(true);
|
manual_system_maintenance(true);
|
||||||
|
|
||||||
// Dump INI1.
|
// Dump INI1.
|
||||||
u32 ini1_off = pkg2_hdr->sec_size[PKG2_SEC_KERNEL];
|
u32 ini1_off = pkg2_hdr->sec_size[PKG2_SEC_KERNEL];
|
||||||
u32 ini1_size = pkg2_hdr->sec_size[PKG2_SEC_INI1];
|
u32 ini1_size = pkg2_hdr->sec_size[PKG2_SEC_INI1];
|
||||||
if (!ini1_size)
|
if (!ini1_size)
|
||||||
{
|
{
|
||||||
pkg2_get_newkern_info(pkg2_hdr->data);
|
pkg2_get_newkern_info(pkg2_hdr->data);
|
||||||
ini1_off = pkg2_newkern_ini1_start;
|
ini1_off = pkg2_newkern_ini1_start;
|
||||||
ini1_size = pkg2_newkern_ini1_end - pkg2_newkern_ini1_start;
|
ini1_size = pkg2_newkern_ini1_end - pkg2_newkern_ini1_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1431,7 +1431,7 @@ out_free:
|
||||||
emmc_end();
|
emmc_end();
|
||||||
sd_unmount();
|
sd_unmount();
|
||||||
|
|
||||||
if (kb >= KB_FIRMWARE_VERSION_620)
|
if (kb >= HOS_KB_VERSION_620)
|
||||||
se_aes_key_clear(8);
|
se_aes_key_clear(8);
|
||||||
out_end:
|
out_end:
|
||||||
// Enable buttons.
|
// Enable buttons.
|
||||||
|
|
|
@ -52,7 +52,7 @@ typedef struct _kb_t
|
||||||
u8 padding[0x150];
|
u8 padding[0x150];
|
||||||
} kb_t;
|
} kb_t;
|
||||||
|
|
||||||
static const u8 keyblob_keyseeds[][SE_KEY_128_SIZE] = {
|
static const u8 keyblob_keyseeds[HOS_KB_VERSION_600 - HOS_KB_VERSION_100 + 1][SE_KEY_128_SIZE] = {
|
||||||
{ 0xDF, 0x20, 0x6F, 0x59, 0x44, 0x54, 0xEF, 0xDC, 0x70, 0x74, 0x48, 0x3B, 0x0D, 0xED, 0x9F, 0xD3 }, // 1.0.0.
|
{ 0xDF, 0x20, 0x6F, 0x59, 0x44, 0x54, 0xEF, 0xDC, 0x70, 0x74, 0x48, 0x3B, 0x0D, 0xED, 0x9F, 0xD3 }, // 1.0.0.
|
||||||
{ 0x0C, 0x25, 0x61, 0x5D, 0x68, 0x4C, 0xEB, 0x42, 0x1C, 0x23, 0x79, 0xEA, 0x82, 0x25, 0x12, 0xAC }, // 3.0.0.
|
{ 0x0C, 0x25, 0x61, 0x5D, 0x68, 0x4C, 0xEB, 0x42, 0x1C, 0x23, 0x79, 0xEA, 0x82, 0x25, 0x12, 0xAC }, // 3.0.0.
|
||||||
{ 0x33, 0x76, 0x85, 0xEE, 0x88, 0x4A, 0xAE, 0x0A, 0xC2, 0x8A, 0xFD, 0x7D, 0x63, 0xC0, 0x43, 0x3B }, // 3.0.1.
|
{ 0x33, 0x76, 0x85, 0xEE, 0x88, 0x4A, 0xAE, 0x0A, 0xC2, 0x8A, 0xFD, 0x7D, 0x63, 0xC0, 0x43, 0x3B }, // 3.0.1.
|
||||||
|
@ -79,7 +79,7 @@ static const u8 master_kekseed_t210_max[SE_KEY_128_SIZE] =
|
||||||
{ 0x99, 0x22, 0x09, 0x57, 0xA7, 0xF9, 0x5E, 0x94, 0xFE, 0x78, 0x7F, 0x41, 0xD6, 0xE7, 0x56, 0xE6 }; // 16.0.0.
|
{ 0x99, 0x22, 0x09, 0x57, 0xA7, 0xF9, 0x5E, 0x94, 0xFE, 0x78, 0x7F, 0x41, 0xD6, 0xE7, 0x56, 0xE6 }; // 16.0.0.
|
||||||
|
|
||||||
//!TODO: Update on mkey changes.
|
//!TODO: Update on mkey changes.
|
||||||
static const u8 master_kekseed_t210b01[][SE_KEY_128_SIZE] = {
|
static const u8 master_kekseed_t210b01[HOS_KB_VERSION_MAX - HOS_KB_VERSION_600 + 1][SE_KEY_128_SIZE] = {
|
||||||
{ 0x77, 0x60, 0x5A, 0xD2, 0xEE, 0x6E, 0xF8, 0x3C, 0x3F, 0x72, 0xE2, 0x59, 0x9D, 0xAC, 0x5E, 0x56 }, // 6.0.0.
|
{ 0x77, 0x60, 0x5A, 0xD2, 0xEE, 0x6E, 0xF8, 0x3C, 0x3F, 0x72, 0xE2, 0x59, 0x9D, 0xAC, 0x5E, 0x56 }, // 6.0.0.
|
||||||
{ 0x1E, 0x80, 0xB8, 0x17, 0x3E, 0xC0, 0x60, 0xAA, 0x11, 0xBE, 0x1A, 0x4A, 0xA6, 0x6F, 0xE4, 0xAE }, // 6.2.0.
|
{ 0x1E, 0x80, 0xB8, 0x17, 0x3E, 0xC0, 0x60, 0xAA, 0x11, 0xBE, 0x1A, 0x4A, 0xA6, 0x6F, 0xE4, 0xAE }, // 6.2.0.
|
||||||
{ 0x94, 0x08, 0x67, 0xBD, 0x0A, 0x00, 0x38, 0x84, 0x11, 0xD3, 0x1A, 0xDB, 0xDD, 0x8D, 0xF1, 0x8A }, // 7.0.0.
|
{ 0x94, 0x08, 0x67, 0xBD, 0x0A, 0x00, 0x38, 0x84, 0x11, 0xD3, 0x1A, 0xDB, 0xDD, 0x8D, 0xF1, 0x8A }, // 7.0.0.
|
||||||
|
@ -103,7 +103,7 @@ const u8 package2_keyseed[SE_KEY_128_SIZE] =
|
||||||
{ 0xFB, 0x8B, 0x6A, 0x9C, 0x79, 0x00, 0xC8, 0x49, 0xEF, 0xD2, 0x4D, 0x85, 0x4D, 0x30, 0xA0, 0xC7 };
|
{ 0xFB, 0x8B, 0x6A, 0x9C, 0x79, 0x00, 0xC8, 0x49, 0xEF, 0xD2, 0x4D, 0x85, 0x4D, 0x30, 0xA0, 0xC7 };
|
||||||
|
|
||||||
//!TODO: Update on mkey changes.
|
//!TODO: Update on mkey changes.
|
||||||
static const u8 mkey_vectors[KB_FIRMWARE_VERSION_MAX + 1][SE_KEY_128_SIZE] = {
|
static const u8 mkey_vectors[HOS_KB_VERSION_MAX + 1][SE_KEY_128_SIZE] = {
|
||||||
{ 0x0C, 0xF0, 0x59, 0xAC, 0x85, 0xF6, 0x26, 0x65, 0xE1, 0xE9, 0x19, 0x55, 0xE6, 0xF2, 0x67, 0x3D }, // Zeroes encrypted with mkey 00.
|
{ 0x0C, 0xF0, 0x59, 0xAC, 0x85, 0xF6, 0x26, 0x65, 0xE1, 0xE9, 0x19, 0x55, 0xE6, 0xF2, 0x67, 0x3D }, // Zeroes encrypted with mkey 00.
|
||||||
{ 0x29, 0x4C, 0x04, 0xC8, 0xEB, 0x10, 0xED, 0x9D, 0x51, 0x64, 0x97, 0xFB, 0xF3, 0x4D, 0x50, 0xDD }, // Mkey 00 encrypted with mkey 01.
|
{ 0x29, 0x4C, 0x04, 0xC8, 0xEB, 0x10, 0xED, 0x9D, 0x51, 0x64, 0x97, 0xFB, 0xF3, 0x4D, 0x50, 0xDD }, // Mkey 00 encrypted with mkey 01.
|
||||||
{ 0xDE, 0xCF, 0xEB, 0xEB, 0x10, 0xAE, 0x74, 0xD8, 0xAD, 0x7C, 0xF4, 0x9E, 0x62, 0xE0, 0xE8, 0x72 }, // Mkey 01 encrypted with mkey 02.
|
{ 0xDE, 0xCF, 0xEB, 0xEB, 0x10, 0xAE, 0x74, 0xD8, 0xAD, 0x7C, 0xF4, 0x9E, 0x62, 0xE0, 0xE8, 0x72 }, // Mkey 01 encrypted with mkey 02.
|
||||||
|
@ -123,7 +123,7 @@ static const u8 mkey_vectors[KB_FIRMWARE_VERSION_MAX + 1][SE_KEY_128_SIZE] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
//!TODO: Update on mkey changes.
|
//!TODO: Update on mkey changes.
|
||||||
static const u8 new_console_keyseed[KB_FIRMWARE_VERSION_MAX - KB_FIRMWARE_VERSION_400 + 1][SE_KEY_128_SIZE] = {
|
static const u8 new_console_keyseed[HOS_KB_VERSION_MAX - HOS_KB_VERSION_400 + 1][SE_KEY_128_SIZE] = {
|
||||||
{ 0x8B, 0x4E, 0x1C, 0x22, 0x42, 0x07, 0xC8, 0x73, 0x56, 0x94, 0x08, 0x8B, 0xCC, 0x47, 0x0F, 0x5D }, // 4.x New Device Key Source.
|
{ 0x8B, 0x4E, 0x1C, 0x22, 0x42, 0x07, 0xC8, 0x73, 0x56, 0x94, 0x08, 0x8B, 0xCC, 0x47, 0x0F, 0x5D }, // 4.x New Device Key Source.
|
||||||
{ 0x6C, 0xEF, 0xC6, 0x27, 0x8B, 0xEC, 0x8A, 0x91, 0x99, 0xAB, 0x24, 0xAC, 0x4F, 0x1C, 0x8F, 0x1C }, // 5.x New Device Key Source.
|
{ 0x6C, 0xEF, 0xC6, 0x27, 0x8B, 0xEC, 0x8A, 0x91, 0x99, 0xAB, 0x24, 0xAC, 0x4F, 0x1C, 0x8F, 0x1C }, // 5.x New Device Key Source.
|
||||||
{ 0x70, 0x08, 0x1B, 0x97, 0x44, 0x64, 0xF8, 0x91, 0x54, 0x9D, 0xC6, 0x84, 0x8F, 0x1A, 0xB2, 0xE4 }, // 6.x New Device Key Source.
|
{ 0x70, 0x08, 0x1B, 0x97, 0x44, 0x64, 0xF8, 0x91, 0x54, 0x9D, 0xC6, 0x84, 0x8F, 0x1A, 0xB2, 0xE4 }, // 6.x New Device Key Source.
|
||||||
|
@ -140,7 +140,7 @@ static const u8 new_console_keyseed[KB_FIRMWARE_VERSION_MAX - KB_FIRMWARE_VERSIO
|
||||||
};
|
};
|
||||||
|
|
||||||
//!TODO: Update on mkey changes.
|
//!TODO: Update on mkey changes.
|
||||||
static const u8 new_console_kekseed[KB_FIRMWARE_VERSION_MAX - KB_FIRMWARE_VERSION_400 + 1][SE_KEY_128_SIZE] = {
|
static const u8 new_console_kekseed[HOS_KB_VERSION_MAX - HOS_KB_VERSION_400 + 1][SE_KEY_128_SIZE] = {
|
||||||
{ 0x88, 0x62, 0x34, 0x6E, 0xFA, 0xF7, 0xD8, 0x3F, 0xE1, 0x30, 0x39, 0x50, 0xF0, 0xB7, 0x5D, 0x5D }, // 4.x New Device Keygen Source.
|
{ 0x88, 0x62, 0x34, 0x6E, 0xFA, 0xF7, 0xD8, 0x3F, 0xE1, 0x30, 0x39, 0x50, 0xF0, 0xB7, 0x5D, 0x5D }, // 4.x New Device Keygen Source.
|
||||||
{ 0x06, 0x1E, 0x7B, 0xE9, 0x6D, 0x47, 0x8C, 0x77, 0xC5, 0xC8, 0xE7, 0x94, 0x9A, 0xA8, 0x5F, 0x2E }, // 5.x New Device Keygen Source.
|
{ 0x06, 0x1E, 0x7B, 0xE9, 0x6D, 0x47, 0x8C, 0x77, 0xC5, 0xC8, 0xE7, 0x94, 0x9A, 0xA8, 0x5F, 0x2E }, // 5.x New Device Keygen Source.
|
||||||
{ 0x99, 0xFA, 0x98, 0xBD, 0x15, 0x1C, 0x72, 0xFD, 0x7D, 0x9A, 0xD5, 0x41, 0x00, 0xFD, 0xB2, 0xEF }, // 6.x New Device Keygen Source.
|
{ 0x99, 0xFA, 0x98, 0xBD, 0x15, 0x1C, 0x72, 0xFD, 0x7D, 0x9A, 0xD5, 0x41, 0x00, 0xFD, 0xB2, 0xEF }, // 6.x New Device Keygen Source.
|
||||||
|
@ -292,7 +292,7 @@ void hos_eks_clear(u32 kb)
|
||||||
if (h_cfg.t210b01)
|
if (h_cfg.t210b01)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (h_cfg.eks && kb >= KB_FIRMWARE_VERSION_700)
|
if (h_cfg.eks && kb >= HOS_KB_VERSION_700)
|
||||||
{
|
{
|
||||||
// Check if current Master key is enabled.
|
// Check if current Master key is enabled.
|
||||||
if (h_cfg.eks->enabled)
|
if (h_cfg.eks->enabled)
|
||||||
|
@ -327,7 +327,7 @@ int hos_keygen_t210b01(u32 kb)
|
||||||
se_aes_unwrap_key(10, 14, console_keyseed_4xx);
|
se_aes_unwrap_key(10, 14, console_keyseed_4xx);
|
||||||
|
|
||||||
// Derive master key.
|
// Derive master key.
|
||||||
se_aes_unwrap_key(7, 12, master_kekseed_t210b01[kb - KB_FIRMWARE_VERSION_600]);
|
se_aes_unwrap_key(7, 12, master_kekseed_t210b01[kb - HOS_KB_VERSION_600]);
|
||||||
se_aes_unwrap_key(7, 7, master_keyseed_retail);
|
se_aes_unwrap_key(7, 7, master_keyseed_retail);
|
||||||
|
|
||||||
// Derive latest pkg2 key.
|
// Derive latest pkg2 key.
|
||||||
|
@ -343,7 +343,7 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt)
|
||||||
tsec_keys_t tsec_keys;
|
tsec_keys_t tsec_keys;
|
||||||
kb_t *kb_data = (kb_t *)keyblob;
|
kb_t *kb_data = (kb_t *)keyblob;
|
||||||
|
|
||||||
if (kb > KB_FIRMWARE_VERSION_MAX)
|
if (kb > HOS_KB_VERSION_MAX)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (h_cfg.t210b01)
|
if (h_cfg.t210b01)
|
||||||
|
@ -355,15 +355,15 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt)
|
||||||
_hos_eks_get();
|
_hos_eks_get();
|
||||||
|
|
||||||
// Use tsec keygen for old firmware or if EKS keys does not exist for newer.
|
// Use tsec keygen for old firmware or if EKS keys does not exist for newer.
|
||||||
if (kb <= KB_FIRMWARE_VERSION_620 || !h_cfg.eks || (h_cfg.eks && h_cfg.eks->enabled != HOS_EKS_TSEC_VER))
|
if (kb <= HOS_KB_VERSION_620 || !h_cfg.eks || (h_cfg.eks && h_cfg.eks->enabled != HOS_EKS_TSEC_VER))
|
||||||
use_tsec = true;
|
use_tsec = true;
|
||||||
|
|
||||||
if (kb <= KB_FIRMWARE_VERSION_600)
|
if (kb <= HOS_KB_VERSION_600)
|
||||||
{
|
{
|
||||||
tsec_ctxt->size = 0xF00;
|
tsec_ctxt->size = 0xF00;
|
||||||
tsec_ctxt->type = TSEC_FW_TYPE_OLD;
|
tsec_ctxt->type = TSEC_FW_TYPE_OLD;
|
||||||
}
|
}
|
||||||
else if (kb == KB_FIRMWARE_VERSION_620)
|
else if (kb == HOS_KB_VERSION_620)
|
||||||
{
|
{
|
||||||
tsec_ctxt->size = 0x2900;
|
tsec_ctxt->size = 0x2900;
|
||||||
tsec_ctxt->type = TSEC_FW_TYPE_EMU;
|
tsec_ctxt->type = TSEC_FW_TYPE_EMU;
|
||||||
|
@ -413,7 +413,7 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kb >= KB_FIRMWARE_VERSION_700)
|
if (kb >= HOS_KB_VERSION_700)
|
||||||
{
|
{
|
||||||
// For 7.0.0 and up, save EKS slot if it doesn't exist.
|
// For 7.0.0 and up, save EKS slot if it doesn't exist.
|
||||||
if (use_tsec)
|
if (use_tsec)
|
||||||
|
@ -439,7 +439,7 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt)
|
||||||
// Package2 key.
|
// Package2 key.
|
||||||
se_aes_unwrap_key(8, 7, package2_keyseed);
|
se_aes_unwrap_key(8, 7, package2_keyseed);
|
||||||
}
|
}
|
||||||
else if (kb == KB_FIRMWARE_VERSION_620)
|
else if (kb == HOS_KB_VERSION_620)
|
||||||
{
|
{
|
||||||
// Set TSEC key.
|
// Set TSEC key.
|
||||||
se_aes_key_set(12, tsec_keys.tsec, SE_KEY_128_SIZE);
|
se_aes_key_set(12, tsec_keys.tsec, SE_KEY_128_SIZE);
|
||||||
|
@ -496,20 +496,20 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt)
|
||||||
|
|
||||||
switch (kb)
|
switch (kb)
|
||||||
{
|
{
|
||||||
case KB_FIRMWARE_VERSION_100:
|
case HOS_KB_VERSION_100:
|
||||||
case KB_FIRMWARE_VERSION_300:
|
case HOS_KB_VERSION_300:
|
||||||
case KB_FIRMWARE_VERSION_301:
|
case HOS_KB_VERSION_301:
|
||||||
se_aes_unwrap_key(13, 15, console_keyseed);
|
se_aes_unwrap_key(13, 15, console_keyseed);
|
||||||
se_aes_unwrap_key(12, 12, master_keyseed_retail);
|
se_aes_unwrap_key(12, 12, master_keyseed_retail);
|
||||||
break;
|
break;
|
||||||
case KB_FIRMWARE_VERSION_400:
|
case HOS_KB_VERSION_400:
|
||||||
se_aes_unwrap_key(13, 15, console_keyseed_4xx);
|
se_aes_unwrap_key(13, 15, console_keyseed_4xx);
|
||||||
se_aes_unwrap_key(15, 15, console_keyseed);
|
se_aes_unwrap_key(15, 15, console_keyseed);
|
||||||
//se_aes_unwrap_key(14, 12, master_keyseed_4xx); // In this context it's useless. So don't kill SBK.
|
//se_aes_unwrap_key(14, 12, master_keyseed_4xx); // In this context it's useless. So don't kill SBK.
|
||||||
se_aes_unwrap_key(12, 12, master_keyseed_retail);
|
se_aes_unwrap_key(12, 12, master_keyseed_retail);
|
||||||
break;
|
break;
|
||||||
case KB_FIRMWARE_VERSION_500:
|
case HOS_KB_VERSION_500:
|
||||||
case KB_FIRMWARE_VERSION_600:
|
case HOS_KB_VERSION_600:
|
||||||
se_aes_unwrap_key(10, 15, console_keyseed_4xx);
|
se_aes_unwrap_key(10, 15, console_keyseed_4xx);
|
||||||
se_aes_unwrap_key(15, 15, console_keyseed);
|
se_aes_unwrap_key(15, 15, console_keyseed);
|
||||||
//se_aes_unwrap_key(14, 12, master_keyseed_4xx); // In this context it's useless. So don't kill SBK.
|
//se_aes_unwrap_key(14, 12, master_keyseed_4xx); // In this context it's useless. So don't kill SBK.
|
||||||
|
@ -547,7 +547,7 @@ static void _hos_validate_mkey()
|
||||||
} while (mkey_idx - 1);
|
} while (mkey_idx - 1);
|
||||||
|
|
||||||
se_aes_key_clear(2);
|
se_aes_key_clear(2);
|
||||||
hos_eks_clear(KB_FIRMWARE_VERSION_MAX);
|
hos_eks_clear(HOS_KB_VERSION_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _hos_bis_print_key(u32 idx, u8 *key)
|
static void _hos_bis_print_key(u32 idx, u8 *key)
|
||||||
|
@ -566,14 +566,14 @@ static void _hos_bis_print_key(u32 idx, u8 *key)
|
||||||
int hos_bis_keygen()
|
int hos_bis_keygen()
|
||||||
{
|
{
|
||||||
u32 keygen_rev = 0;
|
u32 keygen_rev = 0;
|
||||||
u32 console_key_slot = 15; // KB_FIRMWARE_VERSION_MAX. Only for Erista.
|
u32 console_key_slot = 15; // HOS_KB_VERSION_MAX. Only for Erista.
|
||||||
tsec_ctxt_t tsec_ctxt = {0};
|
tsec_ctxt_t tsec_ctxt = {0};
|
||||||
|
|
||||||
if (!bis_keys)
|
if (!bis_keys)
|
||||||
bis_keys = malloc(SE_KEY_128_SIZE * 6);
|
bis_keys = malloc(SE_KEY_128_SIZE * 6);
|
||||||
|
|
||||||
// Run initial keygen.
|
// Run initial keygen.
|
||||||
hos_keygen(NULL, KB_FIRMWARE_VERSION_MAX, &tsec_ctxt);
|
hos_keygen(NULL, HOS_KB_VERSION_MAX, &tsec_ctxt);
|
||||||
|
|
||||||
// All Mariko use new device keygen. New keygen was introduced in 4.0.0.
|
// All Mariko use new device keygen. New keygen was introduced in 4.0.0.
|
||||||
// We check unconditionally in order to support downgrades.
|
// We check unconditionally in order to support downgrades.
|
||||||
|
@ -587,7 +587,7 @@ int hos_bis_keygen()
|
||||||
u32 mkey_idx = sizeof(mkey_vectors) / SE_KEY_128_SIZE;
|
u32 mkey_idx = sizeof(mkey_vectors) / SE_KEY_128_SIZE;
|
||||||
|
|
||||||
// Keygen revision uses bootloader version, which starts from 1.
|
// Keygen revision uses bootloader version, which starts from 1.
|
||||||
keygen_rev -= (KB_FIRMWARE_VERSION_400 + 1);
|
keygen_rev -= (HOS_KB_VERSION_400 + 1);
|
||||||
|
|
||||||
// Derive mkey 0.
|
// Derive mkey 0.
|
||||||
do
|
do
|
||||||
|
@ -637,7 +637,7 @@ int hos_bis_keygen()
|
||||||
se_aes_crypt_block_ecb(2, DECRYPT, bis_keys + (4 * SE_KEY_128_SIZE), bis_keyseed[4]);
|
se_aes_crypt_block_ecb(2, DECRYPT, bis_keys + (4 * SE_KEY_128_SIZE), bis_keyseed[4]);
|
||||||
se_aes_crypt_block_ecb(2, DECRYPT, bis_keys + (5 * SE_KEY_128_SIZE), bis_keyseed[5]);
|
se_aes_crypt_block_ecb(2, DECRYPT, bis_keys + (5 * SE_KEY_128_SIZE), bis_keyseed[5]);
|
||||||
|
|
||||||
// Validate key because KB_FIRMWARE_VERSION_MAX.
|
// Validate key because HOS_KB_VERSION_MAX.
|
||||||
if (!h_cfg.t210b01)
|
if (!h_cfg.t210b01)
|
||||||
_hos_validate_mkey();
|
_hos_validate_mkey();
|
||||||
|
|
||||||
|
@ -706,7 +706,7 @@ int hos_dump_cal0()
|
||||||
cal0_buf = NULL;
|
cal0_buf = NULL;
|
||||||
|
|
||||||
// Clear EKS keys.
|
// Clear EKS keys.
|
||||||
hos_eks_clear(KB_FIRMWARE_VERSION_MAX);
|
hos_eks_clear(HOS_KB_VERSION_MAX);
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,29 +25,32 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define KB_FIRMWARE_VERSION_100 0
|
//!TODO: Update on mkey changes.
|
||||||
#define KB_FIRMWARE_VERSION_300 1
|
enum {
|
||||||
#define KB_FIRMWARE_VERSION_301 2
|
HOS_KB_VERSION_100 = 0,
|
||||||
#define KB_FIRMWARE_VERSION_400 3
|
HOS_KB_VERSION_300 = 1,
|
||||||
#define KB_FIRMWARE_VERSION_500 4
|
HOS_KB_VERSION_301 = 2,
|
||||||
#define KB_FIRMWARE_VERSION_600 5
|
HOS_KB_VERSION_400 = 3,
|
||||||
#define KB_FIRMWARE_VERSION_620 6
|
HOS_KB_VERSION_500 = 4,
|
||||||
#define KB_FIRMWARE_VERSION_700 7
|
HOS_KB_VERSION_600 = 5,
|
||||||
#define KB_FIRMWARE_VERSION_810 8
|
HOS_KB_VERSION_620 = 6,
|
||||||
#define KB_FIRMWARE_VERSION_900 9
|
HOS_KB_VERSION_700 = 7,
|
||||||
#define KB_FIRMWARE_VERSION_910 10
|
HOS_KB_VERSION_810 = 8,
|
||||||
#define KB_FIRMWARE_VERSION_1210 11
|
HOS_KB_VERSION_900 = 9,
|
||||||
#define KB_FIRMWARE_VERSION_1300 12
|
HOS_KB_VERSION_910 = 10,
|
||||||
#define KB_FIRMWARE_VERSION_1400 13
|
HOS_KB_VERSION_1210 = 11,
|
||||||
#define KB_FIRMWARE_VERSION_1500 14
|
HOS_KB_VERSION_1300 = 12,
|
||||||
#define KB_FIRMWARE_VERSION_1600 15
|
HOS_KB_VERSION_1400 = 13,
|
||||||
#define KB_FIRMWARE_VERSION_MAX KB_FIRMWARE_VERSION_1600 //!TODO: Update on mkey changes.
|
HOS_KB_VERSION_1500 = 14,
|
||||||
|
HOS_KB_VERSION_1600 = 15,
|
||||||
|
HOS_KB_VERSION_MAX
|
||||||
|
};
|
||||||
|
|
||||||
#define HOS_TSEC_VERSION 4 //! TODO: Update on TSEC Root Key changes.
|
#define HOS_TSEC_VERSION 4 //! TODO: Update on TSEC Root Key changes.
|
||||||
|
|
||||||
#define HOS_PKG11_MAGIC 0x31314B50
|
#define HOS_PKG11_MAGIC 0x31314B50
|
||||||
#define HOS_EKS_MAGIC 0x31534B45 // EKS1.
|
#define HOS_EKS_MAGIC 0x31534B45 // EKS1.
|
||||||
#define HOS_EKS_TSEC_VER (KB_FIRMWARE_VERSION_700 + HOS_TSEC_VERSION)
|
#define HOS_EKS_TSEC_VER (HOS_KB_VERSION_700 + HOS_TSEC_VERSION)
|
||||||
|
|
||||||
typedef struct _hos_eks_mbr_t
|
typedef struct _hos_eks_mbr_t
|
||||||
{
|
{
|
||||||
|
|
|
@ -117,9 +117,9 @@ const u8 *pkg1_unpack(void *wm_dst, void *sm_dst, void *ldr_dst, const pkg1_id_t
|
||||||
u32 sec_size[3] = { hdr->wb_size, hdr->ldr_size, hdr->sm_size };
|
u32 sec_size[3] = { hdr->wb_size, hdr->ldr_size, hdr->sm_size };
|
||||||
|
|
||||||
// Get correct header mapping.
|
// Get correct header mapping.
|
||||||
if (id->kb == KB_FIRMWARE_VERSION_100 && !strcmp(id->id, "20161121183008"))
|
if (id->kb == HOS_KB_VERSION_100 && !strcmp(id->id, "20161121183008"))
|
||||||
sec_map = sec_map_100;
|
sec_map = sec_map_100;
|
||||||
else if (id->kb >= KB_FIRMWARE_VERSION_100 && id->kb <= KB_FIRMWARE_VERSION_301)
|
else if (id->kb >= HOS_KB_VERSION_100 && id->kb <= HOS_KB_VERSION_301)
|
||||||
sec_map = sec_map_2xx;
|
sec_map = sec_map_2xx;
|
||||||
else
|
else
|
||||||
sec_map = sec_map_4xx;
|
sec_map = sec_map_4xx;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 naehrwert
|
* Copyright (c) 2018 naehrwert
|
||||||
* Copyright (c) 2018-2021 CTCaer
|
* Copyright (c) 2018-2023 CTCaer
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
@ -109,7 +109,7 @@ DPRINTF(" kip1 %d:%s @ %08X (%08X)\n", i, kip1->name, (u32)kip1, ki->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
//!TODO: Update on mkey changes.
|
//!TODO: Update on mkey changes.
|
||||||
static const u8 mkey_vector_7xx[][SE_KEY_128_SIZE] =
|
static const u8 mkey_vector_7xx[HOS_KB_VERSION_MAX - HOS_KB_VERSION_810 + 1][SE_KEY_128_SIZE] =
|
||||||
{
|
{
|
||||||
// Master key 7 encrypted with 8. (7.0.0 with 8.1.0)
|
// Master key 7 encrypted with 8. (7.0.0 with 8.1.0)
|
||||||
{ 0xEA, 0x60, 0xB3, 0xEA, 0xCE, 0x8F, 0x24, 0x46, 0x7D, 0x33, 0x9C, 0xD1, 0xBC, 0x24, 0x98, 0x29 },
|
{ 0xEA, 0x60, 0xB3, 0xEA, 0xCE, 0x8F, 0x24, 0x46, 0x7D, 0x33, 0x9C, 0xD1, 0xBC, 0x24, 0x98, 0x29 },
|
||||||
|
@ -165,13 +165,13 @@ pkg2_hdr_t *pkg2_decrypt(void *data, u8 kb)
|
||||||
goto key_found;
|
goto key_found;
|
||||||
|
|
||||||
// Decrypt older pkg2 via new mkeys.
|
// Decrypt older pkg2 via new mkeys.
|
||||||
if ((kb >= KB_FIRMWARE_VERSION_700) && (kb < KB_FIRMWARE_VERSION_MAX))
|
if ((kb >= HOS_KB_VERSION_700) && (kb < HOS_KB_VERSION_MAX))
|
||||||
{
|
{
|
||||||
u8 tmp_mkey[SE_KEY_128_SIZE];
|
u8 tmp_mkey[SE_KEY_128_SIZE];
|
||||||
u8 decr_slot = 7; // THK mkey or T210B01 mkey.
|
u8 decr_slot = 7; // THK mkey or T210B01 mkey.
|
||||||
u8 mkey_seeds_cnt = sizeof(mkey_vector_7xx) / SE_KEY_128_SIZE;
|
u8 mkey_seeds_cnt = sizeof(mkey_vector_7xx) / SE_KEY_128_SIZE;
|
||||||
u8 mkey_seeds_idx = mkey_seeds_cnt; // Real index + 1.
|
u8 mkey_seeds_idx = mkey_seeds_cnt; // Real index + 1.
|
||||||
u8 mkey_seeds_min_idx = mkey_seeds_cnt - (KB_FIRMWARE_VERSION_MAX - kb);
|
u8 mkey_seeds_min_idx = mkey_seeds_cnt - (HOS_KB_VERSION_MAX - kb);
|
||||||
|
|
||||||
while (mkey_seeds_cnt)
|
while (mkey_seeds_cnt)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue