Skip to content

Commit

Permalink
Pin cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraWright committed Aug 16, 2016
1 parent ee3720f commit 40369d4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
7 changes: 3 additions & 4 deletions source/firm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -48,8 +47,6 @@ bool isN3DS, isDevUnit;

FirmwareSource firmSource;

PINData pin;

void main(void)
{
bool isFirmlaunch,
Expand Down Expand Up @@ -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
Expand All @@ -145,7 +144,7 @@ void main(void)
{
configureCFW(configPath);

if(!pinExists && CONFIG(7)) pin = newPin();
if(!pinExists && CONFIG(7)) newPin();

chrono(2);

Expand Down
5 changes: 2 additions & 3 deletions source/pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "memory.h"
#include "buttons.h"
#include "fs.h"
#include "i2c.h"
#include "pin.h"
#include "crypto.h"

Expand All @@ -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)
}

Expand All @@ -57,7 +57,7 @@ static inline char PINKeyToLetter(u32 pressed)
return keys[31 - i];
}

PINData newPin(void)
void newPin(void)
{
clearScreens();

Expand Down Expand Up @@ -106,7 +106,6 @@ PINData newPin(void)
memcpy(pin.hash, tmp, 32);

fileWrite(&pin, "/luma/pin.bin", sizeof(PINData));
return pin;
}
}

Expand Down
7 changes: 2 additions & 5 deletions source/pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@

#include "types.h"

#ifndef PIN_LENGTH
#define PIN_LENGTH 4
#endif
#define PIN_LENGTH 4

typedef struct __attribute__((packed))
{
Expand All @@ -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);

0 comments on commit 40369d4

Please sign in to comment.