diff --git a/source/firm.c b/source/firm.c index 386abcc..97faef9 100755 --- a/source/firm.c +++ b/source/firm.c @@ -33,7 +33,6 @@ #include "screen.h" #include "buttons.h" #include "pin.h" -#include "i2c.h" #include "../build/injector.h" extern u16 launchedFirmTIDLow[8]; //defined in start.s @@ -48,8 +47,6 @@ bool isN3DS, isDevUnit; FirmwareSource firmSource; -PINData pin; - void main(void) { bool isFirmlaunch, @@ -133,6 +130,8 @@ void main(void) //Boot options aren't being forced if(needConfig != DONT_CONFIGURE) { + PINData pin; + bool pinExists = CONFIG(7) && readPin(&pin); //If we get here we should check the PIN (if it exists) in all cases @@ -145,7 +144,7 @@ void main(void) { configureCFW(configPath); - if(!pinExists && CONFIG(7)) pin = newPin(); + if(!pinExists && CONFIG(7)) newPin(); chrono(2); diff --git a/source/pin.c b/source/pin.c index 83963d0..4932ad2 100644 --- a/source/pin.c +++ b/source/pin.c @@ -31,7 +31,6 @@ #include "memory.h" #include "buttons.h" #include "fs.h" -#include "i2c.h" #include "pin.h" #include "crypto.h" @@ -44,6 +43,7 @@ bool readPin(PINData *out) if(memcmp(out->magic, "PINF", 4) != 0) return false; 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) } @@ -57,7 +57,7 @@ static inline char PINKeyToLetter(u32 pressed) return keys[31 - i]; } -PINData newPin(void) +void newPin(void) { clearScreens(); @@ -106,7 +106,6 @@ PINData newPin(void) memcpy(pin.hash, tmp, 32); fileWrite(&pin, "/luma/pin.bin", sizeof(PINData)); - return pin; } } diff --git a/source/pin.h b/source/pin.h index 462d73f..c89fbb2 100644 --- a/source/pin.h +++ b/source/pin.h @@ -30,9 +30,7 @@ #include "types.h" -#ifndef PIN_LENGTH - #define PIN_LENGTH 4 -#endif +#define PIN_LENGTH 4 typedef struct __attribute__((packed)) { @@ -44,6 +42,5 @@ typedef struct __attribute__((packed)) } PINData; bool readPin(PINData* out); - -PINData newPin(void); +void newPin(void); void verifyPin(PINData *in, bool allowQuit); \ No newline at end of file