mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 17:38:39 +00:00
firmware: introduce seedless setup (aka no_backup)
This commit is contained in:
parent
fcb6b1713c
commit
4a0f0259d1
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
2
vendor/trezor-common
vendored
2
vendor/trezor-common
vendored
@ -1 +1 @@
|
||||
Subproject commit f60b722638116a878d88b9f9393f311f8b45834e
|
||||
Subproject commit 41e4a84b5b01d03e980f84fab29c8f0b0ec948f5
|
Loading…
Reference in New Issue
Block a user