Skip to content

Commit

Permalink
Fix fail
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraWright committed Aug 16, 2016
1 parent 40369d4 commit 4d9cbc4
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions source/pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void newPin(void)
u32 cnt = 0;
int charDrawPos = 20 * SPACING_X;

while(true)
while(cnt < PIN_LENGTH)
{
u32 pressed;
do
Expand All @@ -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);
}
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit 4d9cbc4

Please sign in to comment.