From 7aa1e776426a5edaf54b1c7fbc129807900a8fbe Mon Sep 17 00:00:00 2001 From: CTCaer Date: Mon, 11 Jan 2021 23:28:06 +0200 Subject: [PATCH] nyx: Do not over decrypt pkg1 on t210b01 --- bootloader/hos/hos.c | 3 ++- bootloader/hos/pkg1.c | 1 + nyx/nyx_gui/hos/pkg1.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index 394d36e..6c202c5 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -970,7 +970,8 @@ int hos_launch(ini_sec_t *cfg) } // Patch kip1s in memory if needed. - gfx_printf("%kPatching kips%k\n", 0xFFFFBA00, 0xFFCCCCCC); + if (ctxt.kip1_patches) + gfx_printf("%kPatching kips%k\n", 0xFFFFBA00, 0xFFCCCCCC); const char* unappliedPatch = pkg2_patch_kips(&kip1_info, ctxt.kip1_patches); if (unappliedPatch != NULL) { diff --git a/bootloader/hos/pkg1.c b/bootloader/hos/pkg1.c index 02d9071..0874823 100644 --- a/bootloader/hos/pkg1.c +++ b/bootloader/hos/pkg1.c @@ -211,6 +211,7 @@ int pkg1_decrypt(const pkg1_id_t *id, u8 *pkg1) hdr = (pk11_hdr_t *)(pkg1 + id->pkg11_off + 0x20); // Use BEK for T210B01. + // Additionally, skip 0x20 bytes from decryption to maintain the header. se_aes_iv_clear(13); se_aes_crypt_cbc(13, 0, pkg1 + 0x20, oem_hdr->size - 0x20, pkg1 + 0x20, oem_hdr->size - 0x20); } diff --git a/nyx/nyx_gui/hos/pkg1.c b/nyx/nyx_gui/hos/pkg1.c index be231d3..e4a6f21 100644 --- a/nyx/nyx_gui/hos/pkg1.c +++ b/nyx/nyx_gui/hos/pkg1.c @@ -94,8 +94,9 @@ int pkg1_decrypt(const pkg1_id_t *id, u8 *pkg1) hdr = (pk11_hdr_t *)(pkg1 + id->pkg11_off + 0x20); // Use BEK for T210B01. + // Additionally, skip 0x20 bytes from decryption to maintain the header. se_aes_iv_clear(13); - se_aes_crypt_cbc(13, 0, pkg1 + 0x20, oem_hdr->size, pkg1 + 0x20, oem_hdr->size); + se_aes_crypt_cbc(13, 0, pkg1 + 0x20, oem_hdr->size - 0x20, pkg1 + 0x20, oem_hdr->size - 0x20); } // Return if header is valid.