diff --git a/bootloader/frontend/fe_emmc_tools.c b/bootloader/frontend/fe_emmc_tools.c index d3e3704..34d8183 100644 --- a/bootloader/frontend/fe_emmc_tools.c +++ b/bootloader/frontend/fe_emmc_tools.c @@ -37,7 +37,6 @@ #define NUM_SECTORS_PER_ITER 8192 // 4MB Cache. #define OUT_FILENAME_SZ 128 -#define HASH_FILENAME_SZ (OUT_FILENAME_SZ + 11) // 11 == strlen(".sha256sums") #define SHA256_SZ 0x20 extern sdmmc_t sd_sdmmc; @@ -55,44 +54,17 @@ extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_st static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFilename, emmc_part_t *part) { FIL fp; - FIL hashFp; u8 sparseShouldVerify = 4; u32 btn = 0; u32 prevPct = 200; u32 sdFileSector = 0; int res = 0; - const char hexa[] = "0123456789abcdef"; u8 hashEm[SHA256_SZ]; u8 hashSd[SHA256_SZ]; if (f_open(&fp, outFilename, FA_READ) == FR_OK) { - if (h_cfg.verification == 3) - { - char hashFilename[HASH_FILENAME_SZ]; - strncpy(hashFilename, outFilename, OUT_FILENAME_SZ - 1); - strcat(hashFilename, ".sha256sums"); - - res = f_open(&hashFp, hashFilename, FA_CREATE_ALWAYS | FA_WRITE); - if (res) - { - f_close(&fp); - - gfx_con.fntsz = 16; - EPRINTFARGS("\nHash file could not be opened for write (error %d).\n\nAborting..\n", res); - return 1; - } - - char chunkSizeAscii[10]; - itoa(NUM_SECTORS_PER_ITER * NX_EMMC_BLOCKSIZE, chunkSizeAscii, 10); - chunkSizeAscii[9] = '\0'; - - f_puts("# chunksize: ", &hashFp); - f_puts(chunkSizeAscii, &hashFp); - f_puts("\n", &hashFp); - } - u32 totalSectorsVer = (u32)((u64)f_size(&fp) >> (u64)9); u8 *bufEm = (u8 *)EMMC_BUF_ALIGNED; @@ -118,8 +90,6 @@ static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFi num, lba_curr); f_close(&fp); - if (h_cfg.verification == 3) - f_close(&hashFp); return 1; } f_lseek(&fp, (u64)sdFileSector << (u64)9); @@ -129,9 +99,6 @@ static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFi EPRINTFARGS("\nFailed to read %d blocks (@LBA %08X),\nfrom sd card!\n\nVerification failed..\n", num, lba_curr); f_close(&fp); - if (h_cfg.verification == 3) - f_close(&hashFp); - return 1; } @@ -145,27 +112,8 @@ static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFi EPRINTFARGS("\nSD and eMMC data (@LBA %08X),\ndo not match!\n\nVerification failed..\n", lba_curr); f_close(&fp); - if (h_cfg.verification == 3) - f_close(&hashFp); - return 1; } - - if (h_cfg.verification == 3) - { - // Transform computed hash to readable hexadecimal - char hashStr[SHA256_SZ * 2 + 1]; - char *hashStrPtr = hashStr; - for (int i = 0; i < SHA256_SZ; i++) - { - *(hashStrPtr++) = hexa[hashSd[i] >> 4]; - *(hashStrPtr++) = hexa[hashSd[i] & 0x0F]; - } - hashStr[SHA256_SZ * 2] = '\0'; - - f_puts(hashStr, &hashFp); - f_puts("\n", &hashFp); - } } pct = (u64)((u64)(lba_curr - part->lba_start) * 100u) / (u64)(part->lba_end - part->lba_start); @@ -189,13 +137,11 @@ static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFi msleep(1000); f_close(&fp); - f_close(&hashFp); return 0; } } f_close(&fp); - f_close(&hashFp); tui_pbar(0, gfx_con.y, pct, 0xFFCCCCCC, 0xFF555555); diff --git a/bootloader/frontend/fe_tools.c b/bootloader/frontend/fe_tools.c index c8a143c..187b2f9 100644 --- a/bootloader/frontend/fe_tools.c +++ b/bootloader/frontend/fe_tools.c @@ -121,7 +121,7 @@ void dump_packages12() sdmmc_storage_read(&storage, 0x180000 / NX_EMMC_BLOCKSIZE + kb, 1, keyblob); // Decrypt. - keygen(keyblob, kb, &tsec_ctxt); + keygen(keyblob, kb, &tsec_ctxt, NULL); if (kb <= KB_FIRMWARE_VERSION_600) h_cfg.se_keygen_done = 1; free(keyblob);