mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 11:21:23 +00:00
Remove backup hash mode from main to reduce bin size.
This commit is contained in:
parent
c40c125462
commit
078ef1c4f1
2 changed files with 1 additions and 55 deletions
|
@ -37,7 +37,6 @@
|
||||||
|
|
||||||
#define NUM_SECTORS_PER_ITER 8192 // 4MB Cache.
|
#define NUM_SECTORS_PER_ITER 8192 // 4MB Cache.
|
||||||
#define OUT_FILENAME_SZ 128
|
#define OUT_FILENAME_SZ 128
|
||||||
#define HASH_FILENAME_SZ (OUT_FILENAME_SZ + 11) // 11 == strlen(".sha256sums")
|
|
||||||
#define SHA256_SZ 0x20
|
#define SHA256_SZ 0x20
|
||||||
|
|
||||||
extern sdmmc_t sd_sdmmc;
|
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)
|
static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFilename, emmc_part_t *part)
|
||||||
{
|
{
|
||||||
FIL fp;
|
FIL fp;
|
||||||
FIL hashFp;
|
|
||||||
u8 sparseShouldVerify = 4;
|
u8 sparseShouldVerify = 4;
|
||||||
u32 btn = 0;
|
u32 btn = 0;
|
||||||
u32 prevPct = 200;
|
u32 prevPct = 200;
|
||||||
u32 sdFileSector = 0;
|
u32 sdFileSector = 0;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
const char hexa[] = "0123456789abcdef";
|
|
||||||
|
|
||||||
u8 hashEm[SHA256_SZ];
|
u8 hashEm[SHA256_SZ];
|
||||||
u8 hashSd[SHA256_SZ];
|
u8 hashSd[SHA256_SZ];
|
||||||
|
|
||||||
if (f_open(&fp, outFilename, FA_READ) == FR_OK)
|
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);
|
u32 totalSectorsVer = (u32)((u64)f_size(&fp) >> (u64)9);
|
||||||
|
|
||||||
u8 *bufEm = (u8 *)EMMC_BUF_ALIGNED;
|
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);
|
num, lba_curr);
|
||||||
|
|
||||||
f_close(&fp);
|
f_close(&fp);
|
||||||
if (h_cfg.verification == 3)
|
|
||||||
f_close(&hashFp);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
f_lseek(&fp, (u64)sdFileSector << (u64)9);
|
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);
|
EPRINTFARGS("\nFailed to read %d blocks (@LBA %08X),\nfrom sd card!\n\nVerification failed..\n", num, lba_curr);
|
||||||
|
|
||||||
f_close(&fp);
|
f_close(&fp);
|
||||||
if (h_cfg.verification == 3)
|
|
||||||
f_close(&hashFp);
|
|
||||||
|
|
||||||
return 1;
|
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);
|
EPRINTFARGS("\nSD and eMMC data (@LBA %08X),\ndo not match!\n\nVerification failed..\n", lba_curr);
|
||||||
|
|
||||||
f_close(&fp);
|
f_close(&fp);
|
||||||
if (h_cfg.verification == 3)
|
|
||||||
f_close(&hashFp);
|
|
||||||
|
|
||||||
return 1;
|
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);
|
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);
|
msleep(1000);
|
||||||
|
|
||||||
f_close(&fp);
|
f_close(&fp);
|
||||||
f_close(&hashFp);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f_close(&fp);
|
f_close(&fp);
|
||||||
f_close(&hashFp);
|
|
||||||
|
|
||||||
tui_pbar(0, gfx_con.y, pct, 0xFFCCCCCC, 0xFF555555);
|
tui_pbar(0, gfx_con.y, pct, 0xFFCCCCCC, 0xFF555555);
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ void dump_packages12()
|
||||||
sdmmc_storage_read(&storage, 0x180000 / NX_EMMC_BLOCKSIZE + kb, 1, keyblob);
|
sdmmc_storage_read(&storage, 0x180000 / NX_EMMC_BLOCKSIZE + kb, 1, keyblob);
|
||||||
|
|
||||||
// Decrypt.
|
// Decrypt.
|
||||||
keygen(keyblob, kb, &tsec_ctxt);
|
keygen(keyblob, kb, &tsec_ctxt, NULL);
|
||||||
if (kb <= KB_FIRMWARE_VERSION_600)
|
if (kb <= KB_FIRMWARE_VERSION_600)
|
||||||
h_cfg.se_keygen_done = 1;
|
h_cfg.se_keygen_done = 1;
|
||||||
free(keyblob);
|
free(keyblob);
|
||||||
|
|
Loading…
Reference in a new issue