5 Commits

Author SHA1 Message Date
7defba226a Bump version to v1.9.1 2021-04-06 16:45:21 -06:00
dd3add9327 pkg1: Recognize 12.0.0 2021-04-06 16:44:08 -06:00
20c0df3715 Validate pkg1_identify result for main menu 2021-04-06 16:43:44 -06:00
b3f6e055b2 Reconfigure messages to conserve payload size 2021-01-05 15:38:53 -07:00
b77d42e8e3 keys: Dump partial AES keys even if 0 titlekeys 2021-01-05 15:24:54 -07:00
5 changed files with 26 additions and 22 deletions

View File

@ -11,7 +11,7 @@ include $(DEVKITARM)/base_rules
IPL_LOAD_ADDR := 0x40003000
LPVERSION_MAJOR := 1
LPVERSION_MINOR := 9
LPVERSION_BUGFX := 0
LPVERSION_BUGFX := 1
################################################################################

View File

@ -39,6 +39,7 @@ static const pkg1_id_t _pkg1_ids[] = {
{ "20191021113848", 10}, //9.1.0
{ "20200303104606", 10}, //10.0.0 - 10.2.0
{ "20201030110855", 10}, //11.0.0
{ "20210129111626", 10}, //12.0.0
{ NULL } //End.
};

View File

@ -157,7 +157,6 @@ int reboot_to_sept(const u8 *tsec_fw, const u32 tsec_size, const u32 kb)
f_close(&fp);
sd_unmount();
gfx_printf("\n%kPress Power or Vol +/-\n to Reboot to Sept...", colors[(color_idx++) % 6]);
u32 pk1t_sept = SEPT_PK1T_ADDR - (ALIGN(PATCHED_RELOC_SZ, 0x10) + WB_RST_SIZE);

View File

@ -127,8 +127,7 @@ static u8 *_read_pkg1(sdmmc_t *sdmmc, const pkg1_id_t **pkg1_id) {
static bool _handle_sept(void *tsec_fw, u32 tsec_size, u32 kb, void *out_key) {
sd_mount();
if (!f_stat("sd:/sept/payload.bak", NULL)) {
if (f_unlink("sd:/sept/payload.bin"))
gfx_printf("%kNote: no payload.bin already in /sept\n", colors[(color_idx++) % 6]);
f_unlink("sd:/sept/payload.bin");
f_rename("sd:/sept/payload.bak", "sd:/sept/payload.bin");
}
@ -152,7 +151,7 @@ static bool _handle_sept(void *tsec_fw, u32 tsec_size, u32 kb, void *out_key) {
volatile reloc_meta_t *relocator = (reloc_meta_t *)(IPL_LOAD_ADDR + RELOC_META_OFF);
u32 payload_size = relocator->end - IPL_LOAD_ADDR;
if (f_open(&fp, "sd:/sept/payload.bin", FA_CREATE_NEW | FA_WRITE)) {
EPRINTF("Unable to open /sept/payload.bin to write.");
EPRINTF("Unable to write self to /sept/payload.bin.");
return false;
}
gfx_printf("%kWrite self to /sept/payload.bin...", colors[(color_idx++) % 6]);
@ -259,7 +258,7 @@ static void _derive_master_keys_post_620(u32 pkg1_kb, key_derivation_ctx_t *keys
memset(keys->master_key[kb], 0, AES_128_KEY_SIZE);
}
if (_key_exists(keys->temp_key)) {
EPRINTFARGS("Unable to derive master key. kb = %d.\n Check sept files on SD and retry.", pkg1_kb);
EPRINTFARGS("Unable to derive master key. kb = %d.", pkg1_kb);
memset(keys->master_key, 0, sizeof(keys->master_key));
}
}
@ -576,7 +575,6 @@ static bool _derive_titlekeys(key_derivation_ctx_t *keys, titlekey_buffer_t *tit
gfx_printf("%kTitlekeys... \n", colors[(color_idx++) % 6]);
u32 buf_size = 0x4000;
rsa_keypair_t rsa_keypair = {0};
if (!emummc_storage_read(&emmc_storage, NX_EMMC_CALIBRATION_OFFSET / NX_EMMC_BLOCKSIZE, NX_EMMC_CALIBRATION_SIZE / NX_EMMC_BLOCKSIZE, titlekey_buffer->read_buffer)) {
@ -624,6 +622,7 @@ static bool _derive_titlekeys(key_derivation_ctx_t *keys, titlekey_buffer_t *tit
se_rsa_key_set(0, rsa_keypair.modulus, sizeof(rsa_keypair.modulus), rsa_keypair.private_exponent, sizeof(rsa_keypair.private_exponent));
const u32 buf_size = 0x4000;
_get_titlekeys_from_save(buf_size, keys->save_mac_key, titlekey_buffer, NULL);
_get_titlekeys_from_save(buf_size, keys->save_mac_key, titlekey_buffer, &rsa_keypair);
@ -708,6 +707,7 @@ static void _save_mariko_partial_keys(char *text_buffer) {
}
free(data);
sd_save_to_file(text_buffer, strlen(text_buffer), "sd:/switch/partialaes.keys");
gfx_printf("%kWrote partials to sd:/switch/partialaes.keys\n", colors[(color_idx++) % 6]);
}
static void _save_keys_to_sd(key_derivation_ctx_t *keys, titlekey_buffer_t *titlekey_buffer, const pkg1_id_t *pkg1_id, u32 start_whole_operation_time, u32 derivable_key_count) {
@ -796,6 +796,11 @@ static void _save_keys_to_sd(key_derivation_ctx_t *keys, titlekey_buffer_t *titl
} else
EPRINTF("Unable to save keys to SD.");
if (h_cfg.t210b01) {
memset(text_buffer, 0, text_buffer_size);
_save_mariko_partial_keys(text_buffer);
}
if (_titlekey_count == 0) {
free(text_buffer);
return;
@ -818,11 +823,6 @@ static void _save_keys_to_sd(key_derivation_ctx_t *keys, titlekey_buffer_t *titl
} else
EPRINTF("Unable to save titlekeys to SD.");
if (h_cfg.t210b01) {
memset(text_buffer, 0, text_buffer_size);
_save_mariko_partial_keys(text_buffer);
}
free(text_buffer);
}

View File

@ -304,6 +304,7 @@ void _get_key_generations(char *sysnand_label, char *emunand_label)
u32 pk1_offset = h_cfg.t210b01 ? sizeof(bl_hdr_t210b01_t) : 0; // Skip T210B01 OEM header.
const pkg1_id_t *pkg1_id = pkg1_identify(pkg1 + pk1_offset);
if (pkg1_id) {
sprintf(sysnand_label + 36, "% 3d", pkg1_id->kb);
ment_top[0].caption = sysnand_label;
if (h_cfg.emummc_force_disable)
@ -311,6 +312,7 @@ void _get_key_generations(char *sysnand_label, char *emunand_label)
free(pkg1);
return;
}
}
emummc_storage_init_mmc(&storage, &sdmmc);
memset(pkg1, 0, PKG1_MAX_SIZE);
@ -319,9 +321,11 @@ void _get_key_generations(char *sysnand_label, char *emunand_label)
emummc_storage_end(&storage);
pkg1_id = pkg1_identify(pkg1 + pk1_offset);
if (pkg1_id) {
sprintf(emunand_label + 36, "% 3d", pkg1_id->kb);
free(pkg1);
ment_top[1].caption = emunand_label;
}
}
extern void pivot_stack(u32 stack_top);