Minor stuff

This commit is contained in:
Aurora 2016-09-26 13:53:58 +02:00
parent 7884be106d
commit 9d84a92b1f
6 changed files with 19 additions and 22 deletions

View File

@ -349,8 +349,6 @@ u32 ctrNandRead(u32 sector, u32 sectorCount, u8 *outbuf)
void set6x7xKeys(void)
{
if(!isDevUnit)
{
const u8 __attribute__((aligned(4))) keyX0x25[AES_BLOCK_SIZE] = {0xCE, 0xE7, 0xD8, 0xAB, 0x30, 0xC0, 0x0D, 0xAE, 0x85, 0x0E, 0xF5, 0xE3, 0x82, 0xAC, 0x5A, 0xF3};
const u8 __attribute__((aligned(4))) keyY0x2F[AES_BLOCK_SIZE] = {0xC3, 0x69, 0xBA, 0xA2, 0x1E, 0x18, 0x8A, 0x88, 0xA9, 0xAA, 0x94, 0xE5, 0x50, 0x6A, 0x9F, 0x16};
@ -361,7 +359,6 @@ void set6x7xKeys(void)
when non-zero it clears this block and continues to do the key generation.
Otherwise when this block was already all-zero, it immediately returns. */
memset32((void *)0x01FFCD00, 0, 0x10);
}
}
void decryptExeFs(u8 *inbuf)
@ -382,8 +379,8 @@ void decryptExeFs(u8 *inbuf)
void decryptNusFirm(const u8 *inbuf, u8 *outbuf, u32 ncchSize)
{
const u8 keyY0x3D[AES_BLOCK_SIZE] = {0x0C, 0x76, 0x72, 0x30, 0xF0, 0x99, 0x8F, 0x1C, 0x46, 0x82, 0x82, 0x02, 0xFA, 0xAC, 0xBE, 0x4C};
u8 __attribute__((aligned(4))) cetkIv[AES_BLOCK_SIZE] = {0};
u8 __attribute__((aligned(4))) titleKey[AES_BLOCK_SIZE];
u8 __attribute__((aligned(4))) cetkIv[AES_BLOCK_SIZE] = {0};
memcpy(titleKey, inbuf + 0x1BF, sizeof(titleKey));
memcpy(cetkIv, inbuf + 0x1DC, 8);
@ -485,7 +482,7 @@ void computePinHash(u8 *outbuf, const u8 *inbuf)
u8 __attribute__((aligned(4))) cid[AES_BLOCK_SIZE];
u8 __attribute__((aligned(4))) cipherText[AES_BLOCK_SIZE];
if(!didShaHashBackup)
if(isA9lh && !didShaHashBackup)
{
memcpy(shaHashBackup, (void *)REG_SHA_HASH, sizeof(shaHashBackup));
didShaHashBackup = true;

View File

@ -102,7 +102,7 @@
#define SHA_1_HASH_SIZE (160 / 8)
extern u32 emuOffset;
extern bool isN3DS, isDevUnit;
extern bool isN3DS, isDevUnit, isA9lh;
extern FirmwareSource firmSource;
void ctrNandInit(void);

View File

@ -45,13 +45,13 @@ static const firmSectionHeader *section;
u32 emuOffset;
bool isN3DS,
isDevUnit,
isA9lh,
isFirmlaunch;
CfgData configData;
FirmwareSource firmSource;
void main(void)
{
bool isA9lh;
u32 configTemp,
emuHeader;
FirmwareType firmType;
@ -253,7 +253,7 @@ void main(void)
switch(firmType)
{
case NATIVE_FIRM:
patchNativeFirm(firmVersion, nandType, emuHeader, isA9lh, devMode);
patchNativeFirm(firmVersion, nandType, emuHeader, devMode);
break;
case SAFE_FIRM:
case NATIVE_FIRM1X2X:
@ -338,7 +338,7 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource, bo
return firmVersion;
}
static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isA9lh, u32 devMode)
static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, u32 devMode)
{
u8 *arm9Section = (u8 *)firm + section[2].offset,
*arm11Section1 = (u8 *)firm + section[1].offset;
@ -350,8 +350,8 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32
firm->arm9Entry = (u8 *)0x801B01C;
}
//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) set6x7xKeys();
//Sets the 7.x NCCH KeyX and the 6.x gamecard save data KeyY on >= 6.0 O3DS FIRMs, if not using A9LH or a dev unit
else if(!isA9lh && firmVersion >= 0x29 && !isDevUnit) set6x7xKeys();
//Find the Process9 .code location, size and memory address
u32 process9Size,

View File

@ -48,7 +48,7 @@ typedef struct firmHeader {
} firmHeader;
static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource, bool loadFromSd);
static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isA9lh, u32 devMode);
static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, u32 devMode);
static inline void patchLegacyFirm(FirmwareType firmType, u32 firmVersion, u32 devMode);
static inline void patch1x2xNativeAndSafeFirm(u32 devMode);
static inline void copySection0AndInjectSystemModules(FirmwareType firmType, bool loadFromSd);

View File

@ -139,7 +139,7 @@ void loadPayload(u32 pressed)
{
loaderAddress[1] = payloadSize;
restoreShaHashBackup();
if(isA9lh) restoreShaHashBackup();
initScreens();
flushDCacheRange(loaderAddress, loader_bin_size);

View File

@ -26,7 +26,7 @@
#define PATTERN(a) a "_*.bin"
extern bool isN3DS;
extern bool isN3DS, isA9lh;
void mountFs(void);
u32 fileRead(void *dest, const char *path, u32 maxSize);