Minor stuff

This commit is contained in:
Aurora 2016-09-19 00:14:32 +02:00
parent 4e7ac41a6c
commit eaa4d6323e
4 changed files with 6 additions and 16 deletions

View File

@ -292,16 +292,12 @@ static void sha(void *res, const void *src, u32 size, u32 mode)
memcpy(res, (void *)REG_SHA_HASH, hashSize); memcpy(res, (void *)REG_SHA_HASH, hashSize);
} }
/**************************************************************** /*****************************************************************/
* NAND/FIRM crypto
****************************************************************/
static u8 __attribute__((aligned(4))) nandCTR[0x10]; static u8 __attribute__((aligned(4))) nandCTR[0x10];
static u8 nandSlot; static u8 nandSlot;
static u32 fatStart; static u32 fatStart;
//Initialize the CTRNAND crypto
void ctrNandInit(void) void ctrNandInit(void)
{ {
u8 __attribute__((aligned(4))) cid[0x10]; u8 __attribute__((aligned(4))) cid[0x10];
@ -326,7 +322,6 @@ void ctrNandInit(void)
} }
} }
//Read and decrypt from the selected CTRNAND
u32 ctrNandRead(u32 sector, u32 sectorCount, u8 *outbuf) u32 ctrNandRead(u32 sector, u32 sectorCount, u8 *outbuf)
{ {
u8 __attribute__((aligned(4))) tmpCTR[0x10]; u8 __attribute__((aligned(4))) tmpCTR[0x10];
@ -350,8 +345,7 @@ u32 ctrNandRead(u32 sector, u32 sectorCount, u8 *outbuf)
return result; return result;
} }
//Sets the 7.x NCCH KeyX and the 6.x gamecard save data KeyY void set6x7xKeys(void)
void setRSAMod0DerivedKeys(void)
{ {
if(!isDevUnit) if(!isDevUnit)
{ {
@ -404,7 +398,6 @@ void decryptNusFirm(u8 *inbuf, u8 *outbuf, u32 ncchSize)
decryptExeFs(outbuf); decryptExeFs(outbuf);
} }
//ARM9Loader replacement
void arm9Loader(u8 *arm9Section) void arm9Loader(u8 *arm9Section)
{ {
#ifdef DEV #ifdef DEV
@ -430,7 +423,7 @@ void arm9Loader(u8 *arm9Section)
//Firm keys //Firm keys
u8 __attribute__((aligned(4))) keyY[0x10]; u8 __attribute__((aligned(4))) keyY[0x10];
u8 __attribute__((aligned(4))) arm9BinCTR[0x10]; u8 __attribute__((aligned(4))) arm9BinCTR[0x10];
u8 arm9BinSlot = a9lVersion != 0 ? 0x16 : 0x15; u8 arm9BinSlot = a9lVersion > 0 ? 0x16 : 0x15;
//Setup keys needed for arm9bin decryption //Setup keys needed for arm9bin decryption
memcpy(keyY, arm9Section + 0x10, 0x10); memcpy(keyY, arm9Section + 0x10, 0x10);
@ -442,7 +435,7 @@ void arm9Loader(u8 *arm9Section)
for(u8 *tmp = arm9Section + 0x30; *tmp != 0; tmp++) for(u8 *tmp = arm9Section + 0x30; *tmp != 0; tmp++)
arm9BinSize = (arm9BinSize << 3) + (arm9BinSize << 1) + *tmp - '0'; arm9BinSize = (arm9BinSize << 3) + (arm9BinSize << 1) + *tmp - '0';
if(a9lVersion) if(a9lVersion > 0)
{ {
u8 __attribute__((aligned(4))) keyX[0x10]; u8 __attribute__((aligned(4))) keyX[0x10];

View File

@ -107,7 +107,7 @@ extern FirmwareSource firmSource;
void ctrNandInit(void); void ctrNandInit(void);
u32 ctrNandRead(u32 sector, u32 sectorCount, u8 *outbuf); u32 ctrNandRead(u32 sector, u32 sectorCount, u8 *outbuf);
void setRSAMod0DerivedKeys(void); void set6x7xKeys(void);
void decryptExeFs(u8 *inbuf); void decryptExeFs(u8 *inbuf);
void decryptNusFirm(u8 *inbuf, u8 *outbuf, u32 ncchSize); void decryptNusFirm(u8 *inbuf, u8 *outbuf, u32 ncchSize);
void arm9Loader(u8 *arm9Section); void arm9Loader(u8 *arm9Section);

View File

@ -77,7 +77,6 @@ void drawCharacter(char character, bool isTopScreen, u32 posX, u32 posY, u32 col
u32 drawString(const char *string, bool isTopScreen, u32 posX, u32 posY, u32 color) u32 drawString(const char *string, bool isTopScreen, u32 posX, u32 posY, u32 color)
{ {
for(u32 i = 0, line_i = 0; i < strlen(string); i++) for(u32 i = 0, line_i = 0; i < strlen(string); i++)
{
switch(string[i]) switch(string[i])
{ {
case '\n': case '\n':
@ -104,7 +103,5 @@ u32 drawString(const char *string, bool isTopScreen, u32 posX, u32 posY, u32 col
break; break;
} }
}
return posY; return posY;
} }

View File

@ -395,7 +395,7 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32
} }
//Sets the 7.x NCCH KeyX and the 6.x gamecard save data KeyY on >= 6.0 O3DS FIRMs, if not using A9LH //Sets the 7.x NCCH KeyX and the 6.x gamecard save data KeyY on >= 6.0 O3DS FIRMs, if not using A9LH
else if(!isA9lh && firmVersion >= 0x29) setRSAMod0DerivedKeys(); else if(!isA9lh && firmVersion >= 0x29) set6x7xKeys();
//Find the Process9 .code location, size and memory address //Find the Process9 .code location, size and memory address
u32 process9Size, u32 process9Size,