1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 17:38:39 +00:00

firmware/storage: cache PIN after set

This commit is contained in:
Pavol Rusnak 2018-12-12 17:37:08 +01:00
parent 0cf5ef837f
commit fa3481e37d
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 8 additions and 5 deletions

View File

@ -246,7 +246,7 @@ void session_clear(bool clear_pin)
sessionPassphraseCached = false;
memzero(&sessionPassphrase, sizeof(sessionPassphrase));
if (clear_pin) {
sessionPinCached = false;
session_uncachePin();
}
}
@ -290,9 +290,6 @@ static void storage_commit_locked(bool update)
sessionSeedCached = false;
sessionPassphraseCached = false;
}
if (storageUpdate.has_pin) {
sessionPinCached = false;
}
storageUpdate.version = STORAGE_VERSION;
if (!storageUpdate.has_node && !storageUpdate.has_mnemonic) {
@ -678,7 +675,7 @@ void storage_setPin(const char *pin)
{
storageUpdate.has_pin = true;
strlcpy(storageUpdate.pin, pin, sizeof(storageUpdate.pin));
sessionPinCached = false;
session_cachePin();
}
const char *storage_getPin(void)
@ -729,6 +726,11 @@ void session_cachePin(void)
sessionPinCached = true;
}
void session_uncachePin(void)
{
sessionPinCached = false;
}
bool session_isPinCached(void)
{
return sessionPinCached;

View File

@ -122,6 +122,7 @@ bool storage_hasPin(void);
const char *storage_getPin(void);
void storage_setPin(const char *pin);
void session_cachePin(void);
void session_uncachePin(void);
bool session_isPinCached(void);
void storage_clearPinArea(void);
void storage_resetPinFails(uint32_t flash_pinfails);