From ae48b528a9497f6b5e877720ae5f68438bd1dfaf Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 8 Feb 2019 16:08:55 +0100 Subject: [PATCH] config: Rename session_isPinCached() to session_isUnlocked(). Change GetFeatures to always return pin_cached=false if PIN is not set, in order to maintain the same behavior as before. --- firmware/config.c | 2 +- firmware/config.h | 2 +- firmware/fsm_msg_common.h | 2 +- firmware/protect.c | 5 +---- firmware/trezor.c | 1 - 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/firmware/config.c b/firmware/config.c index af55fccf1..8e52a2918 100644 --- a/firmware/config.c +++ b/firmware/config.c @@ -767,7 +767,7 @@ bool session_getState(const uint8_t *salt, uint8_t *state, const char *passphras return true; } -bool session_isPinCached(void) +bool session_isUnlocked(void) { return storage_is_unlocked(); } diff --git a/firmware/config.h b/firmware/config.h index b015ca78f..df7bd58f5 100644 --- a/firmware/config.h +++ b/firmware/config.h @@ -125,7 +125,7 @@ bool config_containsPin(const char *pin); bool config_hasPin(void); void config_setPin(const char *pin); bool config_changePin(const char *old_pin, const char *new_pin); -bool session_isPinCached(void); +bool session_isUnlocked(void); uint32_t config_nextU2FCounter(void); void config_setU2FCounter(uint32_t u2fcounter); diff --git a/firmware/fsm_msg_common.h b/firmware/fsm_msg_common.h index aa906423f..9cafd4d30 100644 --- a/firmware/fsm_msg_common.h +++ b/firmware/fsm_msg_common.h @@ -58,7 +58,7 @@ void fsm_msgGetFeatures(const GetFeatures *msg) resp->has_label = config_getLabel(resp->label, sizeof(resp->label)); resp->has_initialized = true; resp->initialized = config_isInitialized(); resp->has_imported = config_getImported(&(resp->imported)); - resp->has_pin_cached = true; resp->pin_cached = session_isPinCached(); + resp->has_pin_cached = true; resp->pin_cached = session_isUnlocked() && config_hasPin(); resp->has_passphrase_cached = true; resp->passphrase_cached = session_isPassphraseCached(); resp->has_needs_backup = config_getNeedsBackup(&(resp->needs_backup)); resp->has_unfinished_backup = config_getUnfinishedBackup(&(resp->unfinished_backup)); diff --git a/firmware/protect.c b/firmware/protect.c index 2f961bb8c..796997d1f 100644 --- a/firmware/protect.c +++ b/firmware/protect.c @@ -181,13 +181,10 @@ secbool protectPinUiCallback(uint32_t wait, uint32_t progress) bool protectPin(bool use_cached) { - if (use_cached && session_isPinCached()) { + if (use_cached && session_isUnlocked()) { return true; } - // TODO If maximum number of PIN attempts: - // error_shutdown("Too many wrong PIN", "attempts. Storage has", "been wiped.", NULL, "Please unplug", "the device."); - const char *pin = ""; if (config_hasPin()) { pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_Current, _("Please enter current PIN:")); diff --git a/firmware/trezor.c b/firmware/trezor.c index fd5957802..50b7b60ee 100644 --- a/firmware/trezor.c +++ b/firmware/trezor.c @@ -91,7 +91,6 @@ int main(void) { #if EMULATOR memzero(HW_ENTROPY_DATA, HW_ENTROPY_LEN); - HW_ENTROPY_DATA[0] = 1; #else desig_get_unique_id((uint32_t*)HW_ENTROPY_DATA); #endif