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

common: add {needs,no}_backup flags to LoadDevice, make it debug only

This commit is contained in:
Pavol Rusnak 2019-10-03 15:41:45 +02:00 committed by matejcik
parent 0a0cd797e3
commit 16af7f1353
7 changed files with 45 additions and 13 deletions

View File

@ -223,6 +223,8 @@ message LoadDevice {
optional string label = 6; // device label
optional bool skip_checksum = 7; // do not test mnemonic for valid BIP-39 checksum
optional uint32 u2f_counter = 8; // U2F counter
optional bool needs_backup = 9; // set "needs backup" flag
optional bool no_backup = 10; // indicate that no backup is going to be made
}
/**
@ -232,17 +234,16 @@ message LoadDevice {
* @next Failure
*/
message ResetDevice {
optional bool display_random = 1; // display entropy generated by the device before asking for additional entropy
optional uint32 strength = 2 [default=256]; // strength of seed in bits
optional bool passphrase_protection = 3; // enable master node encryption using passphrase
optional bool pin_protection = 4; // enable PIN protection
optional string language = 5 [default='english']; // device language
optional string label = 6; // device label
optional uint32 u2f_counter = 7; // U2F counter
optional bool skip_backup = 8; // postpone seed backup to BackupDevice workflow
optional bool no_backup = 9; // indicate that no backup is going to be made
// type of the mnemonic backup
optional BackupType backup_type = 10 [default=Bip39];
optional bool display_random = 1; // display entropy generated by the device before asking for additional entropy
optional uint32 strength = 2 [default=256]; // strength of seed in bits
optional bool passphrase_protection = 3; // enable master node encryption using passphrase
optional bool pin_protection = 4; // enable PIN protection
optional string language = 5 [default='english']; // device language
optional string label = 6; // device label
optional uint32 u2f_counter = 7; // U2F counter
optional bool skip_backup = 8; // postpone seed backup to BackupDevice workflow
optional bool no_backup = 9; // indicate that no backup is going to be made
optional BackupType backup_type = 10 [default=Bip39]; // type of the mnemonic backup
}
/**

View File

@ -37,7 +37,10 @@ async def load_device(ctx, msg):
storage.device.set_slip39_iteration_exponent(iteration_exponent)
storage.device.store_mnemonic_secret(
secret, backup_type, needs_backup=True, no_backup=False
secret,
backup_type,
needs_backup=msg.needs_backup is True,
no_backup=msg.no_backup is True,
)
storage.device.load_settings(
use_passphrase=msg.passphrase_protection, label=msg.label

View File

@ -25,6 +25,8 @@ class LoadDevice(p.MessageType):
label: str = None,
skip_checksum: bool = None,
u2f_counter: int = None,
needs_backup: bool = None,
no_backup: bool = None,
) -> None:
self.mnemonics = mnemonics if mnemonics is not None else []
self.node = node
@ -34,6 +36,8 @@ class LoadDevice(p.MessageType):
self.label = label
self.skip_checksum = skip_checksum
self.u2f_counter = u2f_counter
self.needs_backup = needs_backup
self.no_backup = no_backup
@classmethod
def get_fields(cls) -> Dict:
@ -46,4 +50,6 @@ class LoadDevice(p.MessageType):
6: ('label', p.UnicodeType, 0),
7: ('skip_checksum', p.BoolType, 0),
8: ('u2f_counter', p.UVarintType, 0),
9: ('needs_backup', p.BoolType, 0),
10: ('no_backup', p.BoolType, 0),
}

View File

@ -460,6 +460,7 @@ static void config_setNode(const HDNodeType *node) {
}
#if DEBUG_LINK
bool config_dumpNode(HDNodeType *node) {
memzero(node, sizeof(HDNodeType));
@ -488,7 +489,6 @@ bool config_dumpNode(HDNodeType *node) {
memzero(&storageNode, sizeof(storageNode));
return true;
}
#endif
void config_loadDevice(const LoadDevice *msg) {
session_clear(false);
@ -517,8 +517,18 @@ void config_loadDevice(const LoadDevice *msg) {
if (msg->has_u2f_counter) {
config_setU2FCounter(msg->u2f_counter);
}
if (msg->has_needs_backup) {
config_setNeedsBackup(msg->needs_backup);
}
if (msg->has_no_backup && msg->no_backup) {
config_setNoBackup();
}
}
#endif
void config_setLabel(const char *label) {
if (label == NULL || label[0] == '\0') {
storage_delete(KEY_LABEL);

View File

@ -54,7 +54,9 @@ void fsm_msgPing(const Ping *msg);
void fsm_msgChangePin(const ChangePin *msg);
void fsm_msgWipeDevice(const WipeDevice *msg);
void fsm_msgGetEntropy(const GetEntropy *msg);
#if DEBUG_LINK
void fsm_msgLoadDevice(const LoadDevice *msg);
#endif
void fsm_msgResetDevice(const ResetDevice *msg);
void fsm_msgEntropyAck(const EntropyAck *msg);
void fsm_msgBackupDevice(const BackupDevice *msg);

View File

@ -216,6 +216,8 @@ void fsm_msgGetEntropy(const GetEntropy *msg) {
layoutHome();
}
#if DEBUG_LINK
void fsm_msgLoadDevice(const LoadDevice *msg) {
CHECK_PIN
@ -245,6 +247,8 @@ void fsm_msgLoadDevice(const LoadDevice *msg) {
layoutHome();
}
#endif
void fsm_msgResetDevice(const ResetDevice *msg) {
CHECK_PIN

View File

@ -25,6 +25,8 @@ class LoadDevice(p.MessageType):
label: str = None,
skip_checksum: bool = None,
u2f_counter: int = None,
needs_backup: bool = None,
no_backup: bool = None,
) -> None:
self.mnemonics = mnemonics if mnemonics is not None else []
self.node = node
@ -34,6 +36,8 @@ class LoadDevice(p.MessageType):
self.label = label
self.skip_checksum = skip_checksum
self.u2f_counter = u2f_counter
self.needs_backup = needs_backup
self.no_backup = no_backup
@classmethod
def get_fields(cls) -> Dict:
@ -46,4 +50,6 @@ class LoadDevice(p.MessageType):
6: ('label', p.UnicodeType, 0),
7: ('skip_checksum', p.BoolType, 0),
8: ('u2f_counter', p.UVarintType, 0),
9: ('needs_backup', p.BoolType, 0),
10: ('no_backup', p.BoolType, 0),
}