Pin cleanup

This commit is contained in:
Aurora 2016-08-16 22:37:57 +02:00
parent ee3720f0b7
commit 40369d44df
3 changed files with 7 additions and 12 deletions

View File

@ -33,7 +33,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
@ -48,8 +47,6 @@ bool isN3DS, isDevUnit;
FirmwareSource firmSource; FirmwareSource firmSource;
PINData pin;
void main(void) void main(void)
{ {
bool isFirmlaunch, bool isFirmlaunch,
@ -133,6 +130,8 @@ 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
@ -145,7 +144,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();
@ -106,7 +106,6 @@ 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;
} }
} }

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, bool allowQuit); void verifyPin(PINData *in, bool allowQuit);