diff --git a/firmware/fsm_msg_common.h b/firmware/fsm_msg_common.h index 979acd813..14618ccc2 100644 --- a/firmware/fsm_msg_common.h +++ b/firmware/fsm_msg_common.h @@ -68,6 +68,7 @@ void fsm_msgGetFeatures(const GetFeatures *msg) resp->has_passphrase_cached = true; resp->passphrase_cached = session_isPassphraseCached(); resp->has_needs_backup = true; resp->needs_backup = storage_needsBackup(); resp->has_unfinished_backup = true; resp->unfinished_backup = storage_unfinishedBackup(); + resp->has_no_backup = true; resp->no_backup = storage_noBackup(); resp->has_flags = true; resp->flags = storage_getFlags(); resp->has_model = true; strlcpy(resp->model, "1", sizeof(resp->model)); @@ -220,7 +221,8 @@ void fsm_msgResetDevice(const ResetDevice *msg) msg->has_language ? msg->language : 0, msg->has_label ? msg->label : 0, msg->has_u2f_counter ? msg->u2f_counter : 0, - msg->has_skip_backup ? msg->skip_backup : false + msg->has_skip_backup ? msg->skip_backup : false, + msg->has_no_backup ? msg->no_backup : false ); } diff --git a/firmware/layout2.c b/firmware/layout2.c index 7b62a4423..bc9aefe15 100644 --- a/firmware/layout2.c +++ b/firmware/layout2.c @@ -250,6 +250,10 @@ void layoutHome(void) oledBox(0, 0, 127, 8, false); oledDrawStringCenter(0, "BACKUP FAILED!", FONT_STANDARD); } else + if (storage_noBackup()) { + oledBox(0, 0, 127, 8, false); + oledDrawStringCenter(0, "NO BACKUP!", FONT_STANDARD); + } if (storage_needsBackup()) { oledBox(0, 0, 127, 8, false); oledDrawStringCenter(0, "NEEDS BACKUP!", FONT_STANDARD); diff --git a/firmware/reset.c b/firmware/reset.c index 2f350e8de..542f815cb 100644 --- a/firmware/reset.c +++ b/firmware/reset.c @@ -34,13 +34,15 @@ static uint32_t strength; static uint8_t int_entropy[32]; static bool awaiting_entropy = false; static bool skip_backup = false; +static bool no_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, bool _skip_backup) +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, bool _no_backup) { if (_strength != 128 && _strength != 192 && _strength != 256) return; strength = _strength; skip_backup = _skip_backup; + no_backup = _no_backup; random_buffer(int_entropy, 32); @@ -88,12 +90,17 @@ void reset_entropy(const uint8_t *ext_entropy, uint32_t len) sha256_Update(&ctx, int_entropy, 32); sha256_Update(&ctx, ext_entropy, len); sha256_Final(&ctx, int_entropy); - storage_setNeedsBackup(true); + if (no_backup) { + storage_setNoBackup(true); + } else + if (skip_backup) { + storage_setNeedsBackup(true); + } storage_setMnemonic(mnemonic_from_data(int_entropy, strength / 8)); memset(int_entropy, 0, 32); awaiting_entropy = false; - if (skip_backup) { + if (skip_backup || no_backup) { storage_update(); fsm_sendSuccess(_("Device successfully initialized")); layoutHome(); diff --git a/firmware/reset.h b/firmware/reset.h index a4c54c5a9..f4638ac36 100644 --- a/firmware/reset.h +++ b/firmware/reset.h @@ -23,7 +23,7 @@ #include #include -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_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, bool _no_backup); void reset_entropy(const uint8_t *ext_entropy, uint32_t len); void reset_backup(bool separated); uint32_t reset_get_int_entropy(uint8_t *entropy); diff --git a/firmware/storage.c b/firmware/storage.c index 5533185c9..d088dcded 100644 --- a/firmware/storage.c +++ b/firmware/storage.c @@ -344,6 +344,14 @@ static void storage_commit_locked(bool update) storageUpdate.has_needs_backup = storageRom->has_needs_backup; storageUpdate.needs_backup = storageRom->needs_backup; } + if (!storageUpdate.has_unfinished_backup) { + storageUpdate.has_unfinished_backup = storageRom->has_unfinished_backup; + storageUpdate.unfinished_backup = storageRom->unfinished_backup; + } + if (!storageUpdate.has_no_backup) { + storageUpdate.has_no_backup = storageRom->has_no_backup; + storageUpdate.no_backup = storageRom->no_backup; + } if (!storageUpdate.has_flags) { storageUpdate.has_flags = storageRom->has_flags; storageUpdate.flags = storageRom->flags; @@ -844,6 +852,18 @@ void storage_setUnfinishedBackup(bool unfinished_backup) storageUpdate.unfinished_backup = unfinished_backup; } +bool storage_noBackup(void) +{ + return storageUpdate.has_no_backup ? storageUpdate.no_backup + : storageRom->has_no_backup && storageRom->no_backup; +} + +void storage_setNoBackup(bool no_backup) +{ + storageUpdate.has_no_backup = true; + storageUpdate.no_backup = no_backup; +} + void storage_applyFlags(uint32_t flags) { if ((storageRom->flags | flags) == storageRom->flags) { diff --git a/firmware/storage.h b/firmware/storage.h index 1f325b8c4..16f690591 100644 --- a/firmware/storage.h +++ b/firmware/storage.h @@ -73,6 +73,7 @@ typedef struct _Storage { STORAGE_NODE (u2froot) STORAGE_BOOL (unfinished_backup) STORAGE_UINT32 (auto_lock_delay_ms) + STORAGE_BOOL (no_backup) } Storage; extern Storage storageUpdate; @@ -142,6 +143,9 @@ void storage_setNeedsBackup(bool needs_backup); bool storage_unfinishedBackup(void); void storage_setUnfinishedBackup(bool unfinished_backup); +bool storage_noBackup(void); +void storage_setNoBackup(bool no_backup); + void storage_applyFlags(uint32_t flags); uint32_t storage_getFlags(void); diff --git a/vendor/trezor-common b/vendor/trezor-common index f60b72263..41e4a84b5 160000 --- a/vendor/trezor-common +++ b/vendor/trezor-common @@ -1 +1 @@ -Subproject commit f60b722638116a878d88b9f9393f311f8b45834e +Subproject commit 41e4a84b5b01d03e980f84fab29c8f0b0ec948f5