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 //Boot options aren't being forced
if(needConfig != DONT_CONFIGURE) 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 //If no configuration file exists or SELECT is held, load configuration menu
bool shouldLoadConfigMenu = needConfig == CREATE_CONFIGURATION || ((pressed & BUTTON_SELECT) && !(pressed & BUTTON_L1)); 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(); initScreens();
@ -123,51 +123,54 @@ bool verifyPin(void)
//Test vector verification (SD card has, or hasn't been used on another console) //Test vector verification (SD card has, or hasn't been used on another console)
if(memcmp(pin.testHash, tmp, 32) != 0) return false; if(memcmp(pin.testHash, tmp, 32) != 0) return false;
//Pad to AES block length with zeroes if(!skipVerification)
u8 __attribute__((aligned(4))) enteredPassword[16 * ((PIN_LENGTH + 15) / 16)] = {0};
u32 cnt = 0;
bool unlock = false;
int charDrawPos = 5 * SPACING_X;
while(!unlock)
{ {
drawString("Press START to shutdown or enter PIN to proceed", 10, 10, COLOR_TITLE); //Pad to AES block length with zeroes
drawString("PIN: ", 10, 10 + 2 * SPACING_Y, COLOR_WHITE); u8 __attribute__((aligned(4))) enteredPassword[16 * ((PIN_LENGTH + 15) / 16)] = {0};
u32 pressed; u32 cnt = 0;
do bool unlock = false;
int charDrawPos = 5 * SPACING_X;
while(!unlock)
{ {
pressed = waitInput(); drawString("Press START to shutdown or enter PIN to proceed", 10, 10, COLOR_TITLE);
} drawString("PIN: ", 10, 10 + 2 * SPACING_Y, COLOR_WHITE);
while(!(pressed & PIN_BUTTONS));
if(pressed & BUTTON_START) mcuPowerOff(); u32 pressed;
do
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; pressed = waitInput();
cnt = 0; }
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; } PINData;
void newPin(bool allowSkipping); void newPin(bool allowSkipping);
bool verifyPin(void); bool verifyPin(bool skipVerification);