diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index 93e8a986..588be8db 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -2,7 +2,7 @@ * Copyright (c) 2018 naehrwert * Copyright (c) 2018 st4rk * Copyright (c) 2018 Ced2911 - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * Copyright (c) 2018 balika011 * * This program is free software; you can redistribute it and/or modify it @@ -1008,14 +1008,14 @@ void hos_launch(ini_sec_t *cfg) { EHPRINTFARGS("Failed to apply '%s'!", failed_patch); - bool emmc_patch_failed = !strcmp(failed_patch, "emummc"); - if (!emmc_patch_failed) + bool emu_patch_failed = !strcmp(failed_patch, "emummc"); + if (!emu_patch_failed) { gfx_puts("\nPress POWER to continue.\nPress VOL to go to the menu.\n"); display_backlight_brightness(h_cfg.backlight, 1000); } - if (emmc_patch_failed || !(btn_wait() & BTN_POWER)) + if (emu_patch_failed || !(btn_wait() & BTN_POWER)) goto error; // MUST stop here, because if user requests 'nogc' but it's not applied, their GC controller gets updated! } diff --git a/bootloader/hos/pkg2.c b/bootloader/hos/pkg2.c index ee73cc17..a6365e52 100644 --- a/bootloader/hos/pkg2.c +++ b/bootloader/hos/pkg2.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -730,7 +730,7 @@ DPRINTF("sec %d has size %08X\n", i, hdr->sec_size[i]); if (!hdr->sec_size[i]) continue; - se_aes_crypt_ctr(pkg2_keyslot, pdata, pdata, hdr->sec_size[i], &hdr->sec_ctr[i * SE_AES_IV_SIZE]); + se_aes_crypt_ctr(pkg2_keyslot, pdata, pdata, hdr->sec_size[i], hdr->sec_ctr[i]); pdata += hdr->sec_size[i]; } @@ -776,7 +776,7 @@ DPRINTF("adding kip1 '%s' @ %08X (%08X)\n", (char *)ki->kip1->name, (u32)ki->kip { hdr->sec_size[PKG2_SEC_INI1] = ini1_size; hdr->sec_off[PKG2_SEC_INI1] = 0x14080000; - se_aes_crypt_ctr(8, ini1, ini1, ini1_size, &hdr->sec_ctr[PKG2_SEC_INI1 * SE_AES_IV_SIZE]); + se_aes_crypt_ctr(8, ini1, ini1, ini1_size, hdr->sec_ctr[PKG2_SEC_INI1]); } else { @@ -854,7 +854,7 @@ DPRINTF("%s @ %08X (%08X)\n", is_meso ? "Mesosphere": "kernel",(u32)ctxt->kernel kernel_size += ini1_size; } hdr->sec_size[PKG2_SEC_KERNEL] = kernel_size; - se_aes_crypt_ctr(pkg2_keyslot, pdst, pdst, kernel_size, &hdr->sec_ctr[PKG2_SEC_KERNEL * SE_AES_IV_SIZE]); + se_aes_crypt_ctr(pkg2_keyslot, pdst, pdst, kernel_size, hdr->sec_ctr[PKG2_SEC_KERNEL]); pdst += kernel_size; DPRINTF("kernel encrypted\n"); @@ -870,7 +870,7 @@ DPRINTF("INI1 encrypted\n"); u8 *pk2_hash_data = (u8 *)dst + 0x100 + sizeof(pkg2_hdr_t); for (u32 i = PKG2_SEC_KERNEL; i <= PKG2_SEC_UNUSED; i++) { - se_sha_hash_256_oneshot(&hdr->sec_sha256[SE_SHA_256_SIZE * i], (void *)pk2_hash_data, hdr->sec_size[i]); + se_sha_hash_256_oneshot(hdr->sec_sha256[i], (void *)pk2_hash_data, hdr->sec_size[i]); pk2_hash_data += hdr->sec_size[i]; } } diff --git a/bootloader/hos/pkg2.h b/bootloader/hos/pkg2.h index e0bc1b59..c6ee4dfb 100644 --- a/bootloader/hos/pkg2.h +++ b/bootloader/hos/pkg2.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -71,7 +71,7 @@ enum typedef struct _pkg2_hdr_t { /* 0x000 */ u8 ctr[0x10]; -/* 0x010 */ u8 sec_ctr[0x40]; +/* 0x010 */ u8 sec_ctr[4][SE_AES_IV_SIZE]; /* 0x050 */ u32 magic; /* 0x054 */ u32 base; /* 0x058 */ u32 pad0; @@ -80,7 +80,7 @@ typedef struct _pkg2_hdr_t /* 0x05E */ u16 pad1; /* 0x060 */ u32 sec_size[4]; /* 0x070 */ u32 sec_off[4]; -/* 0x080 */ u8 sec_sha256[0x80]; +/* 0x080 */ u8 sec_sha256[4][SE_SHA_256_SIZE]; /* 0x100 */ u8 data[]; } pkg2_hdr_t; diff --git a/nyx/nyx_gui/hos/pkg2.c b/nyx/nyx_gui/hos/pkg2.c index bc851c8c..6bc6faa5 100644 --- a/nyx/nyx_gui/hos/pkg2.c +++ b/nyx/nyx_gui/hos/pkg2.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -209,7 +209,7 @@ DPRINTF("sec %d has size %08X\n", i, hdr->sec_size[i]); if (!hdr->sec_size[i]) continue; - se_aes_crypt_ctr(pkg2_keyslot, pdata, pdata, hdr->sec_size[i], &hdr->sec_ctr[i * SE_AES_IV_SIZE]); + se_aes_crypt_ctr(pkg2_keyslot, pdata, pdata, hdr->sec_size[i], hdr->sec_ctr[i]); pdata += hdr->sec_size[i]; } diff --git a/nyx/nyx_gui/hos/pkg2.h b/nyx/nyx_gui/hos/pkg2.h index 6b153543..4c12dc38 100644 --- a/nyx/nyx_gui/hos/pkg2.h +++ b/nyx/nyx_gui/hos/pkg2.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -39,7 +39,7 @@ extern u32 pkg2_newkern_ini1_end; typedef struct _pkg2_hdr_t { /* 0x000 */ u8 ctr[0x10]; -/* 0x010 */ u8 sec_ctr[0x40]; +/* 0x010 */ u8 sec_ctr[4][SE_AES_IV_SIZE]; /* 0x050 */ u32 magic; /* 0x054 */ u32 base; /* 0x058 */ u32 pad0; @@ -48,7 +48,7 @@ typedef struct _pkg2_hdr_t /* 0x05E */ u16 pad1; /* 0x060 */ u32 sec_size[4]; /* 0x070 */ u32 sec_off[4]; -/* 0x080 */ u8 sec_sha256[0x80]; +/* 0x080 */ u8 sec_sha256[4][SE_SHA_256_SIZE]; /* 0x100 */ u8 data[]; } pkg2_hdr_t;