Merge branch 'master' into developer

This commit is contained in:
Aurora 2016-08-16 23:10:25 +02:00
commit de3eb6ccd7
6 changed files with 38 additions and 44 deletions

View File

@ -23,11 +23,13 @@
#include "memory.h" #include "memory.h"
#include "cache.h" #include "cache.h"
extern u32 payloadSize; //defined in start.s
void main(void) void main(void)
{ {
void *payloadAddress = (void *)0x23F00000; void *payloadAddress = (void *)0x23F00000;
memcpy(payloadAddress, (void*)0x24F00000, *(u32 *)0x24FFFF04); memcpy(payloadAddress, (void*)0x24F00000, payloadSize);
flushCaches(); flushCaches();

View File

@ -24,4 +24,6 @@
_start: _start:
b main b main
.global payloadSize
payloadSize:
.word 0 .word 0

View File

@ -27,7 +27,7 @@
void locateEmuNAND(u32 *off, u32 *head, FirmwareSource *emuNAND) void locateEmuNAND(u32 *off, u32 *head, FirmwareSource *emuNAND)
{ {
static u8 *const temp = (u8 *)0x24300000; static u8 temp[0x200];
const u32 nandSize = getMMCDevice(0)->total_size; const u32 nandSize = getMMCDevice(0)->total_size;
u32 nandOffset = *emuNAND == FIRMWARE_EMUNAND ? 0 : u32 nandOffset = *emuNAND == FIRMWARE_EMUNAND ? 0 :

View File

@ -34,7 +34,6 @@
#include "screen.h" #include "screen.h"
#include "buttons.h" #include "buttons.h"
#include "pin.h" #include "pin.h"
#include "i2c.h"
#include "../build/injector.h" #include "../build/injector.h"
extern u16 launchedFirmTIDLow[8]; //defined in start.s extern u16 launchedFirmTIDLow[8]; //defined in start.s
@ -49,8 +48,6 @@ bool isN3DS, isDevUnit;
FirmwareSource firmSource; FirmwareSource firmSource;
PINData pin;
void main(void) void main(void)
{ {
bool isFirmlaunch, bool isFirmlaunch,
@ -137,10 +134,12 @@ void main(void)
//Boot options aren't being forced //Boot options aren't being forced
if(needConfig != DONT_CONFIGURE) if(needConfig != DONT_CONFIGURE)
{ {
PINData pin;
bool pinExists = CONFIG(7) && readPin(&pin); bool pinExists = CONFIG(7) && readPin(&pin);
//If we get here we should check the PIN (if it exists) in all cases //If we get here we should check the PIN (if it exists) in all cases
if(pinExists) verifyPin(&pin, true); if(pinExists) verifyPin(&pin);
//If no configuration file exists or SELECT is held, load configuration menu //If no configuration file exists or SELECT is held, load configuration menu
bool shouldLoadConfigurationMenu = needConfig == CREATE_CONFIGURATION || ((pressed & BUTTON_SELECT) && !(pressed & BUTTON_L1)); bool shouldLoadConfigurationMenu = needConfig == CREATE_CONFIGURATION || ((pressed & BUTTON_SELECT) && !(pressed & BUTTON_L1));
@ -149,7 +148,7 @@ void main(void)
{ {
configureCFW(configPath); configureCFW(configPath);
if(!pinExists && CONFIG(7)) pin = newPin(); if(!pinExists && CONFIG(7)) newPin();
chrono(2); chrono(2);

View File

@ -31,7 +31,6 @@
#include "memory.h" #include "memory.h"
#include "buttons.h" #include "buttons.h"
#include "fs.h" #include "fs.h"
#include "i2c.h"
#include "pin.h" #include "pin.h"
#include "crypto.h" #include "crypto.h"
@ -44,6 +43,7 @@ bool readPin(PINData *out)
if(memcmp(out->magic, "PINF", 4) != 0) return false; if(memcmp(out->magic, "PINF", 4) != 0) return false;
computePINHash(tmp, zeroes, 1); computePINHash(tmp, zeroes, 1);
return memcmp(out->testHash, tmp, 32) == 0; //test vector verification (SD card has (or hasn't) been used on another console) return memcmp(out->testHash, tmp, 32) == 0; //test vector verification (SD card has (or hasn't) been used on another console)
} }
@ -57,7 +57,7 @@ static inline char PINKeyToLetter(u32 pressed)
return keys[31 - i]; return keys[31 - i];
} }
PINData newPin(void) void newPin(void)
{ {
clearScreens(); clearScreens();
@ -69,7 +69,7 @@ PINData newPin(void)
u32 cnt = 0; u32 cnt = 0;
int charDrawPos = 20 * SPACING_X; int charDrawPos = 20 * SPACING_X;
while(true) while(cnt < PIN_LENGTH)
{ {
u32 pressed; u32 pressed;
do do
@ -87,10 +87,8 @@ PINData newPin(void)
// visualize character on screen. // visualize character on screen.
drawCharacter(key, 10 + charDrawPos, 10, COLOR_WHITE); drawCharacter(key, 10 + charDrawPos, 10, COLOR_WHITE);
charDrawPos += 2 * SPACING_X; charDrawPos += 2 * SPACING_X;
}
// we leave the rest of the array zeroed out.
if(cnt >= PIN_LENGTH)
{
PINData pin = {0}; PINData pin = {0};
u8 __attribute__((aligned(4))) tmp[32] = {0}; u8 __attribute__((aligned(4))) tmp[32] = {0};
u8 __attribute__((aligned(4))) zeroes[16] = {0}; u8 __attribute__((aligned(4))) zeroes[16] = {0};
@ -106,14 +104,11 @@ PINData newPin(void)
memcpy(pin.hash, tmp, 32); memcpy(pin.hash, tmp, 32);
fileWrite(&pin, "/luma/pin.bin", sizeof(PINData)); fileWrite(&pin, "/luma/pin.bin", sizeof(PINData));
return pin;
}
}
while(HID_PAD & PIN_BUTTONS); while(HID_PAD & PIN_BUTTONS);
} }
void verifyPin(PINData *in, bool allowQuit) void verifyPin(PINData *in)
{ {
initScreens(); initScreens();
@ -124,10 +119,10 @@ void verifyPin(PINData *in, bool allowQuit)
u8 __attribute__((aligned(4))) enteredPassword[16 * ((PIN_LENGTH + 15) / 16)] = {0}; u8 __attribute__((aligned(4))) enteredPassword[16 * ((PIN_LENGTH + 15) / 16)] = {0};
u32 cnt = 0; u32 cnt = 0;
bool unlock; bool unlock = false;
int charDrawPos = 5 * SPACING_X; int charDrawPos = 5 * SPACING_X;
while(true) while(!unlock)
{ {
u32 pressed; u32 pressed;
do do
@ -136,8 +131,8 @@ void verifyPin(PINData *in, bool allowQuit)
} }
while(!(pressed & PIN_BUTTONS)); while(!(pressed & PIN_BUTTONS));
pressed &= PIN_BUTTONS;// & ~BUTTON_START; pressed &= PIN_BUTTONS & ~BUTTON_START;
if(!allowQuit) pressed &= ~BUTTON_START;
if(!pressed) continue; if(!pressed) continue;
if(pressed & BUTTON_START) mcuPowerOff(); if(pressed & BUTTON_START) mcuPowerOff();
@ -167,7 +162,6 @@ void verifyPin(PINData *in, bool allowQuit)
drawString("Pin: ", 10, 10 + 2 * SPACING_Y, COLOR_WHITE); drawString("Pin: ", 10, 10 + 2 * SPACING_Y, COLOR_WHITE);
drawString("Wrong pin! Try again!", 10, 10 + 3 * SPACING_Y, COLOR_RED); drawString("Wrong pin! Try again!", 10, 10 + 3 * SPACING_Y, COLOR_RED);
} }
else break;
} }
} }
} }

View File

@ -30,9 +30,7 @@
#include "types.h" #include "types.h"
#ifndef PIN_LENGTH #define PIN_LENGTH 4
#define PIN_LENGTH 4
#endif
typedef struct __attribute__((packed)) typedef struct __attribute__((packed))
{ {
@ -44,6 +42,5 @@ typedef struct __attribute__((packed))
} PINData; } PINData;
bool readPin(PINData* out); bool readPin(PINData* out);
void newPin(void);
PINData newPin(void); void verifyPin(PINData *in);
void verifyPin(PINData *in, bool allowQuit);