From 4d9cbc4e19e311a75e2dace4338d40fad41b048c Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 16 Aug 2016 22:46:41 +0200 Subject: [PATCH] Fix fail --- source/pin.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/source/pin.c b/source/pin.c index 4932ad29f..ff3fe0880 100644 --- a/source/pin.c +++ b/source/pin.c @@ -69,7 +69,7 @@ void newPin(void) u32 cnt = 0; int charDrawPos = 20 * SPACING_X; - while(true) + while(cnt < PIN_LENGTH) { u32 pressed; do @@ -87,27 +87,23 @@ void newPin(void) // visualize character on screen. drawCharacter(key, 10 + charDrawPos, 10, COLOR_WHITE); charDrawPos += 2 * SPACING_X; + } - // we leave the rest of the array zeroed out. - if(cnt >= PIN_LENGTH) - { - PINData pin = {0}; - u8 __attribute__((aligned(4))) tmp[32] = {0}; - u8 __attribute__((aligned(4))) zeroes[16] = {0}; + PINData pin = {0}; + u8 __attribute__((aligned(4))) tmp[32] = {0}; + u8 __attribute__((aligned(4))) zeroes[16] = {0}; - memcpy(pin.magic, "PINF", 4); - pin.formatVersionMajor = 1; - pin.formatVersionMinor = 0; + memcpy(pin.magic, "PINF", 4); + pin.formatVersionMajor = 1; + pin.formatVersionMinor = 0; - computePINHash(tmp, zeroes, 1); - memcpy(pin.testHash, tmp, 32); + computePINHash(tmp, zeroes, 1); + memcpy(pin.testHash, tmp, 32); - computePINHash(tmp, enteredPassword, (PIN_LENGTH + 15) / 16); - memcpy(pin.hash, tmp, 32); + computePINHash(tmp, enteredPassword, (PIN_LENGTH + 15) / 16); + memcpy(pin.hash, tmp, 32); - fileWrite(&pin, "/luma/pin.bin", sizeof(PINData)); - } - } + fileWrite(&pin, "/luma/pin.bin", sizeof(PINData)); while(HID_PAD & PIN_BUTTONS); } @@ -123,10 +119,10 @@ void verifyPin(PINData *in, bool allowQuit) u8 __attribute__((aligned(4))) enteredPassword[16 * ((PIN_LENGTH + 15) / 16)] = {0}; u32 cnt = 0; - bool unlock; + bool unlock = false; int charDrawPos = 5 * SPACING_X; - while(true) + while(!unlock) { u32 pressed; do @@ -166,7 +162,6 @@ void verifyPin(PINData *in, bool allowQuit) drawString("Pin: ", 10, 10 + 2 * SPACING_Y, COLOR_WHITE); drawString("Wrong pin! Try again!", 10, 10 + 3 * SPACING_Y, COLOR_RED); } - else break; } } } \ No newline at end of file