1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-21 23:18:13 +00:00

common: add SafetyCheckLevel to Features

This commit is contained in:
Martin Milata 2020-09-02 13:07:56 +02:00 committed by Tomas Susanka
parent 163ccedb39
commit 9f066e877d
3 changed files with 17 additions and 5 deletions

View File

@ -14,6 +14,14 @@ enum BackupType {
Slip39_Advanced = 2; // also called "Super Shamir" or "Shamir with Groups", see SLIP-0039#two-level-scheme
}
/**
* Level of safety checks for unsafe actions like spending from invalid path namespace or setting high transaction fee.
*/
enum SafetyCheckLevel {
Strict = 0; // disallow unsafe actions
Prompt = 1; // ask user before unsafe action
}
/**
* Request: Reset device to default state and ask for device details
* @start
@ -90,6 +98,7 @@ message Features {
optional bool wipe_code_protection = 34; // is wipe code protection enabled
optional bytes session_id = 35;
optional bool passphrase_always_on_device = 36; // device enforces passphrase entry on Trezor
optional SafetyCheckLevel safety_checks = 37; // safety check level, set to Prompt to limit path namespace enforcement
}
/**
@ -126,11 +135,6 @@ message ApplySettings {
optional uint32 display_rotation = 7; // in degrees from North
optional bool passphrase_always_on_device = 8; // do not prompt for passphrase, enforce device entry
optional SafetyCheckLevel safety_checks = 9; // Safety check level, set to Prompt to limit path namespace enforcement
enum SafetyCheckLevel {
Strict = 0;
Prompt = 1;
}
}
/**

View File

@ -8,6 +8,7 @@ if __debug__:
from typing_extensions import Literal # noqa: F401
EnumTypeCapability = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
EnumTypeBackupType = Literal[0, 1, 2]
EnumTypeSafetyCheckLevel = Literal[0, 1]
except ImportError:
pass
@ -51,6 +52,7 @@ class Features(p.MessageType):
wipe_code_protection: bool = None,
session_id: bytes = None,
passphrase_always_on_device: bool = None,
safety_checks: EnumTypeSafetyCheckLevel = None,
) -> None:
self.vendor = vendor
self.major_version = major_version
@ -86,6 +88,7 @@ class Features(p.MessageType):
self.wipe_code_protection = wipe_code_protection
self.session_id = session_id
self.passphrase_always_on_device = passphrase_always_on_device
self.safety_checks = safety_checks
@classmethod
def get_fields(cls) -> Dict:
@ -124,4 +127,5 @@ class Features(p.MessageType):
34: ('wipe_code_protection', p.BoolType, 0),
35: ('session_id', p.BytesType, 0),
36: ('passphrase_always_on_device', p.BoolType, 0),
37: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1)), 0),
}

View File

@ -8,6 +8,7 @@ if __debug__:
from typing_extensions import Literal # noqa: F401
EnumTypeCapability = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
EnumTypeBackupType = Literal[0, 1, 2]
EnumTypeSafetyCheckLevel = Literal[0, 1]
except ImportError:
pass
@ -51,6 +52,7 @@ class Features(p.MessageType):
wipe_code_protection: bool = None,
session_id: bytes = None,
passphrase_always_on_device: bool = None,
safety_checks: EnumTypeSafetyCheckLevel = None,
) -> None:
self.vendor = vendor
self.major_version = major_version
@ -86,6 +88,7 @@ class Features(p.MessageType):
self.wipe_code_protection = wipe_code_protection
self.session_id = session_id
self.passphrase_always_on_device = passphrase_always_on_device
self.safety_checks = safety_checks
@classmethod
def get_fields(cls) -> Dict:
@ -124,4 +127,5 @@ class Features(p.MessageType):
34: ('wipe_code_protection', p.BoolType, 0),
35: ('session_id', p.BytesType, 0),
36: ('passphrase_always_on_device', p.BoolType, 0),
37: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1)), 0),
}