This commit is contained in:
Aurora 2016-08-16 22:46:41 +02:00
parent 40369d44df
commit 4d9cbc4e19

View File

@ -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};
memcpy(pin.magic, "PINF", 4);
pin.formatVersionMajor = 1;
pin.formatVersionMinor = 0;
computePINHash(tmp, zeroes, 1);
memcpy(pin.testHash, tmp, 32);
computePINHash(tmp, enteredPassword, (PIN_LENGTH + 15) / 16);
memcpy(pin.hash, tmp, 32);
fileWrite(&pin, "/luma/pin.bin", sizeof(PINData));
}
}
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;
computePINHash(tmp, zeroes, 1);
memcpy(pin.testHash, tmp, 32);
computePINHash(tmp, enteredPassword, (PIN_LENGTH + 15) / 16);
memcpy(pin.hash, tmp, 32);
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;
}
}
}