From eaa4d6323ee0c56c14388e905e229ea11919bc3c Mon Sep 17 00:00:00 2001 From: Aurora Date: Mon, 19 Sep 2016 00:14:32 +0200 Subject: [PATCH] Minor stuff --- source/crypto.c | 15 ++++----------- source/crypto.h | 2 +- source/draw.c | 3 --- source/firm.c | 2 +- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/source/crypto.c b/source/crypto.c index bfdc0e9..629d6c6 100755 --- a/source/crypto.c +++ b/source/crypto.c @@ -292,16 +292,12 @@ static void sha(void *res, const void *src, u32 size, u32 mode) memcpy(res, (void *)REG_SHA_HASH, hashSize); } -/**************************************************************** -* NAND/FIRM crypto -****************************************************************/ +/*****************************************************************/ static u8 __attribute__((aligned(4))) nandCTR[0x10]; static u8 nandSlot; - static u32 fatStart; -//Initialize the CTRNAND crypto void ctrNandInit(void) { 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) { u8 __attribute__((aligned(4))) tmpCTR[0x10]; @@ -350,8 +345,7 @@ u32 ctrNandRead(u32 sector, u32 sectorCount, u8 *outbuf) return result; } -//Sets the 7.x NCCH KeyX and the 6.x gamecard save data KeyY -void setRSAMod0DerivedKeys(void) +void set6x7xKeys(void) { if(!isDevUnit) { @@ -404,7 +398,6 @@ void decryptNusFirm(u8 *inbuf, u8 *outbuf, u32 ncchSize) decryptExeFs(outbuf); } -//ARM9Loader replacement void arm9Loader(u8 *arm9Section) { #ifdef DEV @@ -430,7 +423,7 @@ void arm9Loader(u8 *arm9Section) //Firm keys u8 __attribute__((aligned(4))) keyY[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 memcpy(keyY, arm9Section + 0x10, 0x10); @@ -442,7 +435,7 @@ void arm9Loader(u8 *arm9Section) for(u8 *tmp = arm9Section + 0x30; *tmp != 0; tmp++) arm9BinSize = (arm9BinSize << 3) + (arm9BinSize << 1) + *tmp - '0'; - if(a9lVersion) + if(a9lVersion > 0) { u8 __attribute__((aligned(4))) keyX[0x10]; diff --git a/source/crypto.h b/source/crypto.h index 1ed87c2..e1196a8 100755 --- a/source/crypto.h +++ b/source/crypto.h @@ -107,7 +107,7 @@ extern FirmwareSource firmSource; void ctrNandInit(void); u32 ctrNandRead(u32 sector, u32 sectorCount, u8 *outbuf); -void setRSAMod0DerivedKeys(void); +void set6x7xKeys(void); void decryptExeFs(u8 *inbuf); void decryptNusFirm(u8 *inbuf, u8 *outbuf, u32 ncchSize); void arm9Loader(u8 *arm9Section); diff --git a/source/draw.c b/source/draw.c index 4fcc297..6f000f0 100644 --- a/source/draw.c +++ b/source/draw.c @@ -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) { for(u32 i = 0, line_i = 0; i < strlen(string); i++) - { switch(string[i]) { case '\n': @@ -104,7 +103,5 @@ u32 drawString(const char *string, bool isTopScreen, u32 posX, u32 posY, u32 col break; } - } - return posY; } \ No newline at end of file diff --git a/source/firm.c b/source/firm.c index 9ce78ad..805fbcd 100755 --- a/source/firm.c +++ b/source/firm.c @@ -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 - else if(!isA9lh && firmVersion >= 0x29) setRSAMod0DerivedKeys(); + else if(!isA9lh && firmVersion >= 0x29) set6x7xKeys(); //Find the Process9 .code location, size and memory address u32 process9Size,