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

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.

This commit is contained in:
andrew 2019-02-08 16:08:55 +01:00 committed by Pavol Rusnak
parent 66ffa4c7dc
commit ae48b528a9
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 4 additions and 8 deletions

View File

@ -767,7 +767,7 @@ bool session_getState(const uint8_t *salt, uint8_t *state, const char *passphras
return true; return true;
} }
bool session_isPinCached(void) bool session_isUnlocked(void)
{ {
return storage_is_unlocked(); return storage_is_unlocked();
} }

View File

@ -125,7 +125,7 @@ bool config_containsPin(const char *pin);
bool config_hasPin(void); bool config_hasPin(void);
void config_setPin(const char *pin); void config_setPin(const char *pin);
bool config_changePin(const char *old_pin, const char *new_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); uint32_t config_nextU2FCounter(void);
void config_setU2FCounter(uint32_t u2fcounter); void config_setU2FCounter(uint32_t u2fcounter);

View File

@ -58,7 +58,7 @@ void fsm_msgGetFeatures(const GetFeatures *msg)
resp->has_label = config_getLabel(resp->label, sizeof(resp->label)); resp->has_label = config_getLabel(resp->label, sizeof(resp->label));
resp->has_initialized = true; resp->initialized = config_isInitialized(); resp->has_initialized = true; resp->initialized = config_isInitialized();
resp->has_imported = config_getImported(&(resp->imported)); 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_passphrase_cached = true; resp->passphrase_cached = session_isPassphraseCached();
resp->has_needs_backup = config_getNeedsBackup(&(resp->needs_backup)); resp->has_needs_backup = config_getNeedsBackup(&(resp->needs_backup));
resp->has_unfinished_backup = config_getUnfinishedBackup(&(resp->unfinished_backup)); resp->has_unfinished_backup = config_getUnfinishedBackup(&(resp->unfinished_backup));

View File

@ -181,13 +181,10 @@ secbool protectPinUiCallback(uint32_t wait, uint32_t progress)
bool protectPin(bool use_cached) bool protectPin(bool use_cached)
{ {
if (use_cached && session_isPinCached()) { if (use_cached && session_isUnlocked()) {
return true; 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 = ""; const char *pin = "";
if (config_hasPin()) { if (config_hasPin()) {
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_Current, _("Please enter current PIN:")); pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_Current, _("Please enter current PIN:"));

View File

@ -91,7 +91,6 @@ int main(void)
{ {
#if EMULATOR #if EMULATOR
memzero(HW_ENTROPY_DATA, HW_ENTROPY_LEN); memzero(HW_ENTROPY_DATA, HW_ENTROPY_LEN);
HW_ENTROPY_DATA[0] = 1;
#else #else
desig_get_unique_id((uint32_t*)HW_ENTROPY_DATA); desig_get_unique_id((uint32_t*)HW_ENTROPY_DATA);
#endif #endif