Skip PIN verification after a MCU reboot on A9LH

This commit is contained in:
Aurora 2016-08-29 15:57:32 +02:00
parent 8209433696
commit 18bd4bbcf6
3 changed files with 44 additions and 41 deletions

View File

@ -129,7 +129,7 @@ void main(void)
//Boot options aren't being forced
if(needConfig != DONT_CONFIGURE)
{
bool pinExists = CONFIG(8) && verifyPin();
bool pinExists = CONFIG(8) && verifyPin(isA9lh && CFG_BOOTENV);
//If no configuration file exists or SELECT is held, load configuration menu
bool shouldLoadConfigMenu = needConfig == CREATE_CONFIGURATION || ((pressed & BUTTON_SELECT) && !(pressed & BUTTON_L1));

View File

@ -103,7 +103,7 @@ void newPin(bool allowSkipping)
}
}
bool verifyPin(void)
bool verifyPin(bool skipVerification)
{
initScreens();
@ -123,51 +123,54 @@ bool verifyPin(void)
//Test vector verification (SD card has, or hasn't been used on another console)
if(memcmp(pin.testHash, tmp, 32) != 0) return false;
//Pad to AES block length with zeroes
u8 __attribute__((aligned(4))) enteredPassword[16 * ((PIN_LENGTH + 15) / 16)] = {0};
u32 cnt = 0;
bool unlock = false;
int charDrawPos = 5 * SPACING_X;
while(!unlock)
if(!skipVerification)
{
drawString("Press START to shutdown or enter PIN to proceed", 10, 10, COLOR_TITLE);
drawString("PIN: ", 10, 10 + 2 * SPACING_Y, COLOR_WHITE);
//Pad to AES block length with zeroes
u8 __attribute__((aligned(4))) enteredPassword[16 * ((PIN_LENGTH + 15) / 16)] = {0};
u32 pressed;
do
u32 cnt = 0;
bool unlock = false;
int charDrawPos = 5 * SPACING_X;
while(!unlock)
{
pressed = waitInput();
}
while(!(pressed & PIN_BUTTONS));
drawString("Press START to shutdown or enter PIN to proceed", 10, 10, COLOR_TITLE);
drawString("PIN: ", 10, 10 + 2 * SPACING_Y, COLOR_WHITE);
if(pressed & BUTTON_START) mcuPowerOff();
pressed &= PIN_BUTTONS;
if(!pressed) continue;
char key = pinKeyToLetter(pressed);
enteredPassword[cnt++] = (u8)key; //Add character to password
//Visualize character on screen
drawCharacter(key, 10 + charDrawPos, 10 + 2 * SPACING_Y, COLOR_WHITE);
charDrawPos += 2 * SPACING_X;
if(cnt >= PIN_LENGTH)
{
computePinHash(tmp, enteredPassword, (PIN_LENGTH + 15) / 16);
unlock = memcmp(pin.hash, tmp, 32) == 0;
if(!unlock)
u32 pressed;
do
{
charDrawPos = 5 * SPACING_X;
cnt = 0;
pressed = waitInput();
}
while(!(pressed & PIN_BUTTONS));
clearScreens();
if(pressed & BUTTON_START) mcuPowerOff();
drawString("Wrong PIN, try again", 10, 10 + 4 * SPACING_Y, COLOR_RED);
pressed &= PIN_BUTTONS;
if(!pressed) continue;
char key = pinKeyToLetter(pressed);
enteredPassword[cnt++] = (u8)key; //Add character to password
//Visualize character on screen
drawCharacter(key, 10 + charDrawPos, 10 + 2 * SPACING_Y, COLOR_WHITE);
charDrawPos += 2 * SPACING_X;
if(cnt >= PIN_LENGTH)
{
computePinHash(tmp, enteredPassword, (PIN_LENGTH + 15) / 16);
unlock = memcmp(pin.hash, tmp, 32) == 0;
if(!unlock)
{
charDrawPos = 5 * SPACING_X;
cnt = 0;
clearScreens();
drawString("Wrong PIN, try again", 10, 10 + 4 * SPACING_Y, COLOR_RED);
}
}
}
}

View File

@ -44,4 +44,4 @@ typedef struct __attribute__((packed))
} PINData;
void newPin(bool allowSkipping);
bool verifyPin(void);
bool verifyPin(bool skipVerification);