diff --git a/common/protob/messages-common.proto b/common/protob/messages-common.proto index 1c121ae24..cb89d8a9a 100644 --- a/common/protob/messages-common.proto +++ b/common/protob/messages-common.proto @@ -33,6 +33,7 @@ message Failure { Failure_NotEnoughFunds = 10; Failure_NotInitialized = 11; Failure_PinMismatch = 12; + Failure_WipeCodeMismatch = 13; Failure_FirmwareError = 99; } } @@ -90,6 +91,8 @@ message PinMatrixRequest { PinMatrixRequestType_Current = 1; PinMatrixRequestType_NewFirst = 2; PinMatrixRequestType_NewSecond = 3; + PinMatrixRequestType_WipeCodeFirst = 4; + PinMatrixRequestType_WipeCodeSecond = 5; } } diff --git a/common/protob/messages-management.proto b/common/protob/messages-management.proto index 129493828..2e4caa981 100644 --- a/common/protob/messages-management.proto +++ b/common/protob/messages-management.proto @@ -141,6 +141,16 @@ message ChangePin { optional bool remove = 1; // is PIN removal requested? } +/** + * Request: Starts workflow for setting/removing the wipe code + * @start + * @next Success + * @next Failure + */ +message ChangeWipeCode { + optional bool remove = 1; // is wipe code removal requested? +} + /** * Request: Starts workflow for enabling/regenerating/disabling SD card protection * @start diff --git a/common/protob/messages.proto b/common/protob/messages.proto index 26117c364..9da9a70c6 100644 --- a/common/protob/messages.proto +++ b/common/protob/messages.proto @@ -64,6 +64,7 @@ enum MessageType { MessageType_SdProtect = 79 [(wire_in) = true]; MessageType_GetNextU2FCounter = 80 [(wire_in) = true]; MessageType_NextU2FCounter = 81 [(wire_out) = true]; + MessageType_ChangeWipeCode = 82 [(wire_in) = true]; // Bootloader MessageType_FirmwareErase = 6 [(wire_in) = true, (wire_bootloader) = true]; diff --git a/core/src/trezor/messages/ChangeWipeCode.py b/core/src/trezor/messages/ChangeWipeCode.py new file mode 100644 index 000000000..0d1285fc4 --- /dev/null +++ b/core/src/trezor/messages/ChangeWipeCode.py @@ -0,0 +1,26 @@ +# Automatically generated by pb2py +# fmt: off +import protobuf as p + +if __debug__: + try: + from typing import Dict, List # noqa: F401 + from typing_extensions import Literal # noqa: F401 + except ImportError: + pass + + +class ChangeWipeCode(p.MessageType): + MESSAGE_WIRE_TYPE = 82 + + def __init__( + self, + remove: bool = None, + ) -> None: + self.remove = remove + + @classmethod + def get_fields(cls) -> Dict: + return { + 1: ('remove', p.BoolType, 0), + } diff --git a/core/src/trezor/messages/Failure.py b/core/src/trezor/messages/Failure.py index eeec1d7c7..7c1d37dde 100644 --- a/core/src/trezor/messages/Failure.py +++ b/core/src/trezor/messages/Failure.py @@ -6,7 +6,7 @@ if __debug__: try: from typing import Dict, List # noqa: F401 from typing_extensions import Literal # noqa: F401 - EnumTypeFailureType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 99] + EnumTypeFailureType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 99] except ImportError: pass @@ -25,6 +25,6 @@ class Failure(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('code', p.EnumType("FailureType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 99)), 0), + 1: ('code', p.EnumType("FailureType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 99)), 0), 2: ('message', p.UnicodeType, 0), } diff --git a/core/src/trezor/messages/FailureType.py b/core/src/trezor/messages/FailureType.py index 1e5c8b6e7..f94652b9e 100644 --- a/core/src/trezor/messages/FailureType.py +++ b/core/src/trezor/messages/FailureType.py @@ -15,4 +15,5 @@ ProcessError = 9 # type: Literal[9] NotEnoughFunds = 10 # type: Literal[10] NotInitialized = 11 # type: Literal[11] PinMismatch = 12 # type: Literal[12] +WipeCodeMismatch = 13 # type: Literal[13] FirmwareError = 99 # type: Literal[99] diff --git a/core/src/trezor/messages/MessageType.py b/core/src/trezor/messages/MessageType.py index 6bc5f8533..f9994d83f 100644 --- a/core/src/trezor/messages/MessageType.py +++ b/core/src/trezor/messages/MessageType.py @@ -39,6 +39,7 @@ SetU2FCounter = 63 # type: Literal[63] SdProtect = 79 # type: Literal[79] GetNextU2FCounter = 80 # type: Literal[80] NextU2FCounter = 81 # type: Literal[81] +ChangeWipeCode = 82 # type: Literal[82] FirmwareErase = 6 # type: Literal[6] FirmwareUpload = 7 # type: Literal[7] FirmwareRequest = 8 # type: Literal[8] diff --git a/core/src/trezor/wire/errors.py b/core/src/trezor/wire/errors.py index cc4f490b0..1211536e8 100644 --- a/core/src/trezor/wire/errors.py +++ b/core/src/trezor/wire/errors.py @@ -71,6 +71,11 @@ class PinMismatch(Error): super().__init__(FailureType.PinMismatch, message) +class WipeCodeMismatch(Error): + def __init__(self, message: str) -> None: + super().__init__(FailureType.WipeCodeMismatch, message) + + class FirmwareError(Error): def __init__(self, message: str) -> None: super().__init__(FailureType.FirmwareError, message) diff --git a/python/src/trezorlib/messages/ChangeWipeCode.py b/python/src/trezorlib/messages/ChangeWipeCode.py new file mode 100644 index 000000000..733217c83 --- /dev/null +++ b/python/src/trezorlib/messages/ChangeWipeCode.py @@ -0,0 +1,26 @@ +# Automatically generated by pb2py +# fmt: off +from .. import protobuf as p + +if __debug__: + try: + from typing import Dict, List # noqa: F401 + from typing_extensions import Literal # noqa: F401 + except ImportError: + pass + + +class ChangeWipeCode(p.MessageType): + MESSAGE_WIRE_TYPE = 82 + + def __init__( + self, + remove: bool = None, + ) -> None: + self.remove = remove + + @classmethod + def get_fields(cls) -> Dict: + return { + 1: ('remove', p.BoolType, 0), + } diff --git a/python/src/trezorlib/messages/Failure.py b/python/src/trezorlib/messages/Failure.py index 6157cffa0..c6c2dd066 100644 --- a/python/src/trezorlib/messages/Failure.py +++ b/python/src/trezorlib/messages/Failure.py @@ -6,7 +6,7 @@ if __debug__: try: from typing import Dict, List # noqa: F401 from typing_extensions import Literal # noqa: F401 - EnumTypeFailureType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 99] + EnumTypeFailureType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 99] except ImportError: pass @@ -25,6 +25,6 @@ class Failure(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('code', p.EnumType("FailureType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 99)), 0), + 1: ('code', p.EnumType("FailureType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 99)), 0), 2: ('message', p.UnicodeType, 0), } diff --git a/python/src/trezorlib/messages/FailureType.py b/python/src/trezorlib/messages/FailureType.py index 1e5c8b6e7..f94652b9e 100644 --- a/python/src/trezorlib/messages/FailureType.py +++ b/python/src/trezorlib/messages/FailureType.py @@ -15,4 +15,5 @@ ProcessError = 9 # type: Literal[9] NotEnoughFunds = 10 # type: Literal[10] NotInitialized = 11 # type: Literal[11] PinMismatch = 12 # type: Literal[12] +WipeCodeMismatch = 13 # type: Literal[13] FirmwareError = 99 # type: Literal[99] diff --git a/python/src/trezorlib/messages/MessageType.py b/python/src/trezorlib/messages/MessageType.py index a01db19b5..0d8a6baf9 100644 --- a/python/src/trezorlib/messages/MessageType.py +++ b/python/src/trezorlib/messages/MessageType.py @@ -37,6 +37,7 @@ SetU2FCounter = 63 # type: Literal[63] SdProtect = 79 # type: Literal[79] GetNextU2FCounter = 80 # type: Literal[80] NextU2FCounter = 81 # type: Literal[81] +ChangeWipeCode = 82 # type: Literal[82] FirmwareErase = 6 # type: Literal[6] FirmwareUpload = 7 # type: Literal[7] FirmwareRequest = 8 # type: Literal[8] diff --git a/python/src/trezorlib/messages/PinMatrixRequest.py b/python/src/trezorlib/messages/PinMatrixRequest.py index a37241e67..12882e128 100644 --- a/python/src/trezorlib/messages/PinMatrixRequest.py +++ b/python/src/trezorlib/messages/PinMatrixRequest.py @@ -6,7 +6,7 @@ if __debug__: try: from typing import Dict, List # noqa: F401 from typing_extensions import Literal # noqa: F401 - EnumTypePinMatrixRequestType = Literal[1, 2, 3] + EnumTypePinMatrixRequestType = Literal[1, 2, 3, 4, 5] except ImportError: pass @@ -23,5 +23,5 @@ class PinMatrixRequest(p.MessageType): @classmethod def get_fields(cls) -> Dict: return { - 1: ('type', p.EnumType("PinMatrixRequestType", (1, 2, 3)), 0), + 1: ('type', p.EnumType("PinMatrixRequestType", (1, 2, 3, 4, 5)), 0), } diff --git a/python/src/trezorlib/messages/PinMatrixRequestType.py b/python/src/trezorlib/messages/PinMatrixRequestType.py index ca6535e78..ec3c6a38d 100644 --- a/python/src/trezorlib/messages/PinMatrixRequestType.py +++ b/python/src/trezorlib/messages/PinMatrixRequestType.py @@ -6,3 +6,5 @@ if False: Current = 1 # type: Literal[1] NewFirst = 2 # type: Literal[2] NewSecond = 3 # type: Literal[3] +WipeCodeFirst = 4 # type: Literal[4] +WipeCodeSecond = 5 # type: Literal[5] diff --git a/python/src/trezorlib/messages/__init__.py b/python/src/trezorlib/messages/__init__.py index 2da185bb0..e217ee0ad 100644 --- a/python/src/trezorlib/messages/__init__.py +++ b/python/src/trezorlib/messages/__init__.py @@ -31,6 +31,7 @@ from .CardanoTxInputType import CardanoTxInputType from .CardanoTxOutputType import CardanoTxOutputType from .CardanoTxRequest import CardanoTxRequest from .ChangePin import ChangePin +from .ChangeWipeCode import ChangeWipeCode from .CipherKeyValue import CipherKeyValue from .CipheredKeyValue import CipheredKeyValue from .ClearSession import ClearSession