|
|
|
@ -33,12 +33,14 @@
|
|
|
|
|
static uint32_t strength;
|
|
|
|
|
static uint8_t int_entropy[32];
|
|
|
|
|
static bool awaiting_entropy = false;
|
|
|
|
|
static bool skip_backup = false;
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (_strength != 128 && _strength != 192 && _strength != 256) return;
|
|
|
|
|
|
|
|
|
|
strength = _strength;
|
|
|
|
|
skip_backup = _skip_backup;
|
|
|
|
|
|
|
|
|
|
random_buffer(int_entropy, 32);
|
|
|
|
|
|
|
|
|
@ -75,8 +77,6 @@ void reset_init(bool display_random, uint32_t _strength, bool passphrase_protect
|
|
|
|
|
awaiting_entropy = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char current_word[10], current_word_display[11];
|
|
|
|
|
|
|
|
|
|
void reset_entropy(const uint8_t *ext_entropy, uint32_t len)
|
|
|
|
|
{
|
|
|
|
|
if (!awaiting_entropy) {
|
|
|
|
@ -92,6 +92,33 @@ void reset_entropy(const uint8_t *ext_entropy, uint32_t len)
|
|
|
|
|
memset(int_entropy, 0, 32);
|
|
|
|
|
awaiting_entropy = false;
|
|
|
|
|
|
|
|
|
|
storage.has_mnemonic = true;
|
|
|
|
|
storage.has_needs_backup = true;
|
|
|
|
|
storage.needs_backup = true;
|
|
|
|
|
|
|
|
|
|
if (skip_backup) {
|
|
|
|
|
storage_commit();
|
|
|
|
|
fsm_sendSuccess(_("Device successfully initialized"));
|
|
|
|
|
layoutHome();
|
|
|
|
|
} else {
|
|
|
|
|
reset_backup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char current_word[10], current_word_display[11];
|
|
|
|
|
|
|
|
|
|
void reset_backup(void)
|
|
|
|
|
{
|
|
|
|
|
if (!storage.has_needs_backup || !storage.needs_backup) {
|
|
|
|
|
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Seed already backed up"));
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
storage.has_needs_backup = false;
|
|
|
|
|
storage.needs_backup = false;
|
|
|
|
|
storage_commit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int pass, word_pos, i = 0, j;
|
|
|
|
|
|
|
|
|
|
for (pass = 0; pass < 2; pass++) {
|
|
|
|
@ -146,10 +173,7 @@ void reset_entropy(const uint8_t *ext_entropy, uint32_t len)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
storage.has_mnemonic = true;
|
|
|
|
|
storage_commit();
|
|
|
|
|
fsm_sendSuccess(_("Device reset"));
|
|
|
|
|
fsm_sendSuccess(_("Seed successfully backed up"));
|
|
|
|
|
layoutHome();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|