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

reset: distinguish between separated call and joined call, mark backup as done only when performed completely

This commit is contained in:
Pavol Rusnak 2017-06-28 11:25:47 +02:00
parent b65068c159
commit 8fa3ce7e14
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 18 additions and 10 deletions

View File

@ -453,7 +453,7 @@ void fsm_msgBackupDevice(BackupDevice *msg)
CHECK_INITIALIZED
(void)msg;
reset_backup();
reset_backup(true);
}
void fsm_msgSignTx(SignTx *msg)

View File

@ -101,22 +101,19 @@ void reset_entropy(const uint8_t *ext_entropy, uint32_t len)
fsm_sendSuccess(_("Device successfully initialized"));
layoutHome();
} else {
reset_backup();
reset_backup(false);
}
}
static char current_word[10], current_word_display[11];
void reset_backup(void)
// separated == true if called as a separate workflow via BackupMessage
void reset_backup(bool separated)
{
if (!storage_needsBackup()) {
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Seed already backed up"));
return;
} else {
storage.has_needs_backup = true;
storage.needs_backup = false;
storage_commit();
}
int pass, word_pos, i = 0, j;
@ -166,14 +163,25 @@ void reset_backup(void)
}
}
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmWord, true)) {
storage_reset();
if (!separated) {
storage_reset();
}
layoutHome();
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
return;
}
}
}
fsm_sendSuccess(_("Seed successfully backed up"));
storage.has_needs_backup = true;
storage.needs_backup = false;
storage_commit();
if (separated) {
fsm_sendSuccess(_("Seed successfully backed up"));
} else {
fsm_sendSuccess(_("Device successfully initialized"));
}
layoutHome();
}

View File

@ -25,7 +25,7 @@
void reset_init(bool display_random, uint32_t _strength, bool passphrase_protection, bool pin_protection, const char *language, const char *label, uint32_t u2f_counter, bool skip_backup);
void reset_entropy(const uint8_t *ext_entropy, uint32_t len);
void reset_backup(void);
void reset_backup(bool separated);
uint32_t reset_get_int_entropy(uint8_t *entropy);
const char *reset_get_word(void);