Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static pkg1_id_t _pkg1_ids[] = {
- { "20161121183008", 0, 0x1900, 0x3FE0, { 2, 1, 0 }, 0x4002B020, 0x8000D000, true, NULL, NULL }, //1.0.0 (Patched relocator)
- { "20170210155124", 0, 0x1900, 0x3FE0, { 0, 1, 2 }, 0x4002D000, 0x8000D000, true, NULL, NULL }, //2.0.0 - 2.3.0
- { "20170519101410", 1, 0x1A00, 0x3FE0, { 0, 1, 2 }, 0x4002D000, 0x8000D000, true, NULL, NULL }, //3.0.0
- { "20170710161758", 2, 0x1A00, 0x3FE0, { 0, 1, 2 }, 0x4002D000, 0x8000D000, true, NULL, NULL }, //3.0.1 - 3.0.2
- { "20170921172629", 3, 0x1800, 0x3FE0, { 1, 2, 0 }, 0x4002B000, 0x4003B000, false, NULL, NULL }, //4.0.0 - 4.1.0
- { "20180220163747", 4, 0x1900, 0x3FE0, { 1, 2, 0 }, 0x4002B000, 0x4003B000, false, NULL, NULL }, //5.0.0 - 5.1.0
- { "20180802162753", 5, 0x1900, 0x3FE0, { 1, 2, 0 }, 0x4002B000, 0x4003D800, false, NULL, NULL }, //6.0.0 - 6.1.0
- { "20181107105733", 6, 0x0E00, 0x6FE0, { 1, 2, 0 }, 0x4002B000, 0x4003D800, false, NULL, NULL }, //6.2.0
- { NULL } //End.
- };
- extern void *fileBuf;
- gfx_puts(&gfx_con, "Get TSEC...");
- u32 start_time = get_tmr_ms(), end_time;
- _key_count = 0;
- u32 retries = 0;
- u32 key_ver_max = 1;
- tsec_ctxt_t tsec_ctxt;
- // Read package1.
- u8 *pkg1 = (u8 *)malloc(0x40000);
- fileBuf = sd_file_read(firmpath);
- memcpy(pkg1, fileBuf, filesize);
- free(fileBuf);
- fileBuf = NULL;
- gfx_puts(&gfx_con, "got pkg1\n");
- const pkg1_id_t *pkg1_id = &_pkg1_ids[0]; // rob double check this
- /*const pkg1_id_t *pkg1_id = pkg1_identify(pkg1);
- if (!pkg1_id) {
- EPRINTFARGS("Unknown package1 version for reading\nTSEC firmware (= '%s').",
- (char *)pkg1 + 0x10);
- goto out_wait;
- }*/
- u8 tsec_keys[0x10 * 3];
- int res = 0;
- tsec_ctxt.size = 0xF00;
- tsec_ctxt.fw = (u8 *)pkg1 + pkg1_id->tsec_off;
- tsec_ctxt.pkg1 = pkg1;
- tsec_ctxt.pkg11_off = pkg1_id->pkg11_off;
- tsec_ctxt.secmon_base = pkg1_id->secmon_base;
- if (pkg1_id->kb >= KB_FIRMWARE_VERSION_620) {
- tsec_ctxt.size = 0x2900;
- u8 *tsec_paged = (u8 *)page_alloc(3);
- memcpy(tsec_paged, (void *)tsec_ctxt.fw, tsec_ctxt.size);
- tsec_ctxt.fw = tsec_paged;
- key_ver_max = 1;
- }
- for (u32 i = 1; i <= key_ver_max; i++) {
- tsec_ctxt.key_ver = i;
- while (tsec_query(tsec_keys + ((i - 1) * 0x10), pkg1_id->kb, &tsec_ctxt) < 0) {
- if (pkg1_id->kb <= KB_FIRMWARE_VERSION_600)
- memset(tsec_keys + ((i - 1) * 0x10), 0x00, 0x10);
- else
- memset(tsec_keys, 0x00, 0x30);
- retries++;
- if (retries > 3) {
- res = -1;
- break;
- }
- }
- }
- free(pkg1);
- if (res < 0) {
- EPRINTF("ERROR dumping TSEC. Try again.\n");
- goto out_wait;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement