1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-26 00:08:10 +00:00

common: return deprecated fields to protobuf, to allow cross-version compatible code

This commit is contained in:
matejcik 2020-02-10 12:33:36 +01:00
parent 56dc952495
commit 4c9689d7a7
16 changed files with 144 additions and 8 deletions

View File

@ -111,19 +111,36 @@ message PinMatrixAck {
* @next PassphraseAck
*/
message PassphraseRequest {
// optional bool on_device = 1; // DEPRECATED
optional bool _on_device = 1 [deprecated=true]; // <2.3.0
}
/**
* Request: Send passphrase back
* @auxend
*/
message PassphraseAck {
message PassphraseAck {
optional string passphrase = 1;
// optional bytes state = 2; // DEPRECATED
optional bytes _state = 2 [deprecated=true]; // <2.3.0
optional bool on_device = 3; // user wants to enter passphrase on the device
}
/**
* Response: Device awaits passphrase state
* Deprecated in 2.3.0
* @next Deprecated_PassphraseStateAck
*/
message Deprecated_PassphraseStateRequest {
optional bytes state = 1; // actual device state
}
/**
* Request: Send passphrase state back
* Deprecated in 2.3.0
* @auxend
*/
message Deprecated_PassphraseStateAck {
}
/**
* Structure representing BIP32 (hierarchical deterministic) node
* Used for imports of private key into the device and exporting public key out of device

View File

@ -20,7 +20,7 @@ enum BackupType {
* @next Features
*/
message Initialize {
optional bytes session_id = 3; // assumed device session id; Trezor clears caches if it is different or empty
optional bytes session_id = 1; // assumed device session id; Trezor clears caches if it is different or empty
}
/**

View File

@ -54,8 +54,6 @@ enum MessageType {
MessageType_EntropyAck = 36 [(wire_in) = true];
MessageType_PassphraseRequest = 41 [(wire_out) = true];
MessageType_PassphraseAck = 42 [(wire_in) = true, (wire_tiny) = true, (wire_no_fsm) = true];
// PassphraseStateRequest = 77 DEPRECATED
// PassphraseStateAck = 78 DEPRECATED
MessageType_RecoveryDevice = 45 [(wire_in) = true];
MessageType_WordRequest = 46 [(wire_out) = true];
MessageType_WordAck = 47 [(wire_in) = true];
@ -66,6 +64,11 @@ enum MessageType {
MessageType_NextU2FCounter = 81 [(wire_out) = true];
MessageType_ChangeWipeCode = 82 [(wire_in) = true];
// Deprecated messages, kept for protobuf compatibility.
// Both are marked wire_out so that we don't need to implement incoming handler for legacy
MessageType_Deprecated_PassphraseStateRequest = 77 [(wire_out) = true];
MessageType_Deprecated_PassphraseStateAck = 78 [(wire_out) = true];
// Bootloader
MessageType_FirmwareErase = 6 [(wire_in) = true, (wire_bootloader) = true];
MessageType_FirmwareUpload = 7 [(wire_in) = true, (wire_bootloader) = true];

View File

@ -0,0 +1,14 @@
# 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 Deprecated_PassphraseStateAck(p.MessageType):
MESSAGE_WIRE_TYPE = 78

View File

@ -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 Deprecated_PassphraseStateRequest(p.MessageType):
MESSAGE_WIRE_TYPE = 77
def __init__(
self,
state: bytes = None,
) -> None:
self.state = state
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('state', p.BytesType, 0),
}

View File

@ -22,5 +22,5 @@ class Initialize(p.MessageType):
@classmethod
def get_fields(cls) -> Dict:
return {
3: ('session_id', p.BytesType, 0),
1: ('session_id', p.BytesType, 0),
}

View File

@ -38,6 +38,8 @@ SdProtect = 79 # type: Literal[79]
GetNextU2FCounter = 80 # type: Literal[80]
NextU2FCounter = 81 # type: Literal[81]
ChangeWipeCode = 82 # type: Literal[82]
Deprecated_PassphraseStateRequest = 77 # type: Literal[77]
Deprecated_PassphraseStateAck = 78 # type: Literal[78]
FirmwareErase = 6 # type: Literal[6]
FirmwareUpload = 7 # type: Literal[7]
FirmwareRequest = 8 # type: Literal[8]

View File

@ -16,14 +16,17 @@ class PassphraseAck(p.MessageType):
def __init__(
self,
passphrase: str = None,
_state: bytes = None,
on_device: bool = None,
) -> None:
self.passphrase = passphrase
self._state = _state
self.on_device = on_device
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('passphrase', p.UnicodeType, 0),
2: ('_state', p.BytesType, 0),
3: ('on_device', p.BoolType, 0),
}

View File

@ -12,3 +12,15 @@ if __debug__:
class PassphraseRequest(p.MessageType):
MESSAGE_WIRE_TYPE = 41
def __init__(
self,
_on_device: bool = None,
) -> None:
self._on_device = _on_device
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('_on_device', p.BoolType, 0),
}

View File

@ -0,0 +1,14 @@
# 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 Deprecated_PassphraseStateAck(p.MessageType):
MESSAGE_WIRE_TYPE = 78

View File

@ -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 Deprecated_PassphraseStateRequest(p.MessageType):
MESSAGE_WIRE_TYPE = 77
def __init__(
self,
state: bytes = None,
) -> None:
self.state = state
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('state', p.BytesType, 0),
}

View File

@ -22,5 +22,5 @@ class Initialize(p.MessageType):
@classmethod
def get_fields(cls) -> Dict:
return {
3: ('session_id', p.BytesType, 0),
1: ('session_id', p.BytesType, 0),
}

View File

@ -36,6 +36,8 @@ SdProtect = 79 # type: Literal[79]
GetNextU2FCounter = 80 # type: Literal[80]
NextU2FCounter = 81 # type: Literal[81]
ChangeWipeCode = 82 # type: Literal[82]
Deprecated_PassphraseStateRequest = 77 # type: Literal[77]
Deprecated_PassphraseStateAck = 78 # type: Literal[78]
FirmwareErase = 6 # type: Literal[6]
FirmwareUpload = 7 # type: Literal[7]
FirmwareRequest = 8 # type: Literal[8]

View File

@ -16,14 +16,17 @@ class PassphraseAck(p.MessageType):
def __init__(
self,
passphrase: str = None,
_state: bytes = None,
on_device: bool = None,
) -> None:
self.passphrase = passphrase
self._state = _state
self.on_device = on_device
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('passphrase', p.UnicodeType, 0),
2: ('_state', p.BytesType, 0),
3: ('on_device', p.BoolType, 0),
}

View File

@ -12,3 +12,15 @@ if __debug__:
class PassphraseRequest(p.MessageType):
MESSAGE_WIRE_TYPE = 41
def __init__(
self,
_on_device: bool = None,
) -> None:
self._on_device = _on_device
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('_on_device', p.BoolType, 0),
}

View File

@ -53,6 +53,8 @@ from .DebugLinkState import DebugLinkState
from .DebugLinkStop import DebugLinkStop
from .DebugMoneroDiagAck import DebugMoneroDiagAck
from .DebugMoneroDiagRequest import DebugMoneroDiagRequest
from .Deprecated_PassphraseStateAck import Deprecated_PassphraseStateAck
from .Deprecated_PassphraseStateRequest import Deprecated_PassphraseStateRequest
from .ECDHSessionKey import ECDHSessionKey
from .Entropy import Entropy
from .EntropyAck import EntropyAck