1
0
Fork 0
mirror of https://github.com/Scandal-UK/Incognito_RCM.git synced 2024-11-25 21:32:28 +00:00

formatting

This commit is contained in:
jimzrt 2019-10-07 20:11:26 +02:00
parent e7a4f341d9
commit eb1b27366e

View file

@ -71,7 +71,6 @@ sdmmc_t sdmmc;
emmc_part_t *system_part; emmc_part_t *system_part;
emmc_part_t *prodinfo_part; emmc_part_t *prodinfo_part;
#define SECTORS_IN_CLUSTER 32 #define SECTORS_IN_CLUSTER 32
#define PRODINFO_SIZE 0x3FBC00 #define PRODINFO_SIZE 0x3FBC00
@ -287,13 +286,16 @@ bool dump_keys()
se_aes_key_set(8, bis_key[0] + 0x00, 0x10); se_aes_key_set(8, bis_key[0] + 0x00, 0x10);
se_aes_key_set(9, bis_key[0] + 0x10, 0x10); se_aes_key_set(9, bis_key[0] + 0x10, 0x10);
gfx_printf("%kGot keys!\n%kValidate...", COLOR_GREEN,COLOR_YELLOW); gfx_printf("%kGot keys!\n%kValidate...", COLOR_GREEN, COLOR_YELLOW);
const char magic[4] = "CAL0"; const char magic[4] = "CAL0";
char buffer[4]; char buffer[4];
readData((u8 *)buffer, 0, 4, NULL); readData((u8 *)buffer, 0, 4, NULL);
if(memcmp(magic, buffer, 4) == 0){ if (memcmp(magic, buffer, 4) == 0)
{
gfx_printf("%kOK!\n", COLOR_GREEN); gfx_printf("%kOK!\n", COLOR_GREEN);
} else { }
else
{
gfx_printf("%kError!\n", COLOR_RED); gfx_printf("%kError!\n", COLOR_RED);
return false; return false;
} }
@ -380,7 +382,6 @@ bool incognito()
if (!writeCal0Hash()) if (!writeCal0Hash())
return false; return false;
gfx_printf("\n%kIncognito done!\n", COLOR_GREEN); gfx_printf("\n%kIncognito done!\n", COLOR_GREEN);
return true; return true;
} }
@ -630,10 +631,13 @@ bool verifyHash(u32 hashOffset, u32 offset, u32 sz, u8 *blob)
{ {
bool result = false; bool result = false;
u8 *buffer = (u8 *)malloc(sz); u8 *buffer = (u8 *)malloc(sz);
if(blob == NULL){ if (blob == NULL)
if(!readData(buffer, offset, sz, NULL)) {
if (!readData(buffer, offset, sz, NULL))
goto out; goto out;
} else { }
else
{
memcpy(buffer, blob + offset, sz); memcpy(buffer, blob + offset, sz);
} }
u8 hash1[0x20]; u8 hash1[0x20];
@ -641,10 +645,13 @@ bool verifyHash(u32 hashOffset, u32 offset, u32 sz, u8 *blob)
u8 hash2[0x20]; u8 hash2[0x20];
if(blob == NULL){ if (blob == NULL)
if(!readData(hash2, hashOffset, 0x20, NULL)) {
if (!readData(hash2, hashOffset, 0x20, NULL))
goto out; goto out;
} else { }
else
{
memcpy(hash2, blob + hashOffset, 0x20); memcpy(hash2, blob + hashOffset, 0x20);
} }
@ -665,7 +672,8 @@ out:
s32 getClientCertSize() s32 getClientCertSize()
{ {
s32 buffer; s32 buffer;
if(!RETRY(readData((u8 *)&buffer, 0x0AD0, sizeof(buffer), NULL))){ if (!RETRY(readData((u8 *)&buffer, 0x0AD0, sizeof(buffer), NULL)))
{
return -1; return -1;
} }
return buffer; return buffer;
@ -674,7 +682,8 @@ s32 getClientCertSize()
s32 getCalibrationDataSize() s32 getCalibrationDataSize()
{ {
s32 buffer; s32 buffer;
if(!RETRY(readData((u8 *)&buffer, 0x08, sizeof(buffer), NULL))){ if (!RETRY(readData((u8 *)&buffer, 0x08, sizeof(buffer), NULL)))
{
return -1; return -1;
} }
return buffer; return buffer;
@ -683,7 +692,7 @@ s32 getCalibrationDataSize()
bool writeCal0Hash() bool writeCal0Hash()
{ {
s32 calibrationSize = getCalibrationDataSize(); s32 calibrationSize = getCalibrationDataSize();
if(calibrationSize == -1) if (calibrationSize == -1)
return false; return false;
return writeHash(0x20, 0x40, calibrationSize); return writeHash(0x20, 0x40, calibrationSize);
@ -692,7 +701,7 @@ bool writeCal0Hash()
bool writeClientCertHash() bool writeClientCertHash()
{ {
s32 certSize = getClientCertSize(); s32 certSize = getClientCertSize();
if(certSize == -1) if (certSize == -1)
return false; return false;
return writeHash(0x12E0, 0xAE0, certSize); return writeHash(0x12E0, 0xAE0, certSize);
@ -701,7 +710,7 @@ bool writeClientCertHash()
bool verifyCal0Hash(u8 *blob) bool verifyCal0Hash(u8 *blob)
{ {
s32 calibrationSize = getCalibrationDataSize(); s32 calibrationSize = getCalibrationDataSize();
if(calibrationSize == -1) if (calibrationSize == -1)
return false; return false;
return verifyHash(0x20, 0x40, calibrationSize, blob); return verifyHash(0x20, 0x40, calibrationSize, blob);
@ -710,7 +719,7 @@ bool verifyCal0Hash(u8 *blob)
bool verifyClientCertHash(u8 *blob) bool verifyClientCertHash(u8 *blob)
{ {
s32 certSize = getClientCertSize(); s32 certSize = getClientCertSize();
if(certSize == -1) if (certSize == -1)
return false; return false;
return verifyHash(0x12E0, 0xAE0, certSize, blob); return verifyHash(0x12E0, 0xAE0, certSize, blob);
@ -723,9 +732,12 @@ bool verifyProdinfo(u8 *blob)
if (verifyClientCertHash(blob) && verifyCal0Hash(blob)) if (verifyClientCertHash(blob) && verifyCal0Hash(blob))
{ {
char serial[15] = ""; char serial[15] = "";
if(blob == NULL){ if (blob == NULL)
{
readData((u8 *)serial, 0x250, 14, NULL); readData((u8 *)serial, 0x250, 14, NULL);
} else { }
else
{
memcpy(serial, blob + 0x250, 14); memcpy(serial, blob + 0x250, 14);
} }
@ -853,7 +865,8 @@ bool backupProdinfo()
gfx_printf("\n%kError reading from NAND!\n", COLOR_RED); gfx_printf("\n%kError reading from NAND!\n", COLOR_RED);
goto out; goto out;
} }
if(!verifyProdinfo(bufferNX)){ if (!verifyProdinfo(bufferNX))
{
goto out; goto out;
} }
gfx_printf("%k\nWriting to file...\n", COLOR_YELLOW); gfx_printf("%k\nWriting to file...\n", COLOR_YELLOW);
@ -907,7 +920,8 @@ bool restoreProdinfo()
gfx_printf("\n%kError reading from file!\n", COLOR_RED); gfx_printf("\n%kError reading from file!\n", COLOR_RED);
goto out; goto out;
} }
if(!verifyProdinfo(bufferNX)){ if (!verifyProdinfo(bufferNX))
{
goto out; goto out;
} }
gfx_printf("%kWriting to NAND...\n", COLOR_YELLOW); gfx_printf("%kWriting to NAND...\n", COLOR_YELLOW);