From 050f58a3bba5e50dcfeec326481a12f9e5e59776 Mon Sep 17 00:00:00 2001 From: Aurora Date: Mon, 12 Sep 2016 18:58:10 +0200 Subject: [PATCH] Don't init screens if the PIN file does not exist or is invalid --- source/config.c | 10 +++++----- source/pin.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/source/config.c b/source/config.c index a522fc2..a0b6855 100644 --- a/source/config.c +++ b/source/config.c @@ -66,11 +66,6 @@ void writeConfig(ConfigurationStatus needConfig, u32 configTemp) void configMenu(bool oldPinStatus) { - initScreens(); - - drawString(CONFIG_TITLE, 10, 10, COLOR_TITLE); - drawString("Press A to select, START to save", 10, 30, COLOR_WHITE); - const char *multiOptionsText[] = { "Default EmuNAND: 1( ) 2( ) 3( ) 4( )", "Screen brightness: 4( ) 3( ) 2( ) 1( )", "PIN lock: Off( ) 4( ) 6( ) 8( ) digits", @@ -122,6 +117,11 @@ void configMenu(bool oldPinStatus) for(u32 i = 0; i < singleOptionsAmount; i++) singleOptions[i].enabled = CONFIG(i); + initScreens(); + + drawString(CONFIG_TITLE, 10, 10, COLOR_TITLE); + drawString("Press A to select, START to save", 10, 30, COLOR_WHITE); + //Character to display a selected option char selected = 'x'; diff --git a/source/pin.c b/source/pin.c index 7823c3c..58c9232 100644 --- a/source/pin.c +++ b/source/pin.c @@ -48,19 +48,19 @@ void newPin(bool allowSkipping) { clearScreens(); + u8 length = 4 + 2 * (MULTICONFIG(PIN) - 1); + char *title = allowSkipping ? "Press START to skip or enter a new PIN" : "Enter a new PIN to proceed"; drawString(title, 10, 10, COLOR_TITLE); drawString("PIN ( digits): ", 10, 10 + 2 * SPACING_Y, COLOR_WHITE); + drawCharacter('0' + length, 10 + 5 * SPACING_X, 10 + 2 * SPACING_Y, COLOR_WHITE); //Pad to AES block length with zeroes u8 __attribute__((aligned(4))) enteredPassword[0x10] = {0}; - u8 length = 4 + 2 * (MULTICONFIG(PIN) - 1), - cnt = 0; + u8 cnt = 0; int charDrawPos = 16 * SPACING_X; - drawCharacter('0' + length, 10 + 5 * SPACING_X, 10 + 2 * SPACING_Y, COLOR_WHITE); - while(cnt < length) { u32 pressed; @@ -106,8 +106,6 @@ void newPin(bool allowSkipping) bool verifyPin(void) { - initScreens(); - PinData pin; if(fileRead(&pin, PIN_PATH) != sizeof(PinData) || @@ -125,11 +123,13 @@ bool verifyPin(void) //Test vector verification (SD card has, or hasn't been used on another console) if(memcmp(pin.testHash, tmp, sizeof(tmp)) != 0) return false; + initScreens(); + //Pad to AES block length with zeroes u8 __attribute__((aligned(4))) enteredPassword[0x10] = {0}; - u8 cnt = 0; bool unlock = false; + u8 cnt = 0; int charDrawPos = 16 * SPACING_X; while(!unlock) @@ -165,7 +165,7 @@ bool verifyPin(void) if(!unlock) { - charDrawPos = 5 * SPACING_X; + charDrawPos = 16 * SPACING_X; cnt = 0; clearScreens();