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

common: rename ClearSession to LockDevice, introduce EndSession

This commit is contained in:
matejcik 2020-04-21 15:33:46 +02:00 committed by matejcik
parent 32fcc4ad9c
commit 0600d87c8c
12 changed files with 60 additions and 13 deletions

View File

@ -93,11 +93,21 @@ message Features {
} }
/** /**
* Request: clear session (removes cached PIN, passphrase, etc). * Request: soft-lock the device. Following actions will require PIN. Passphrases remain cached.
* @start * @start
* @next Success * @next Success
*/ */
message ClearSession { message LockDevice {
}
/**
* Request: end the current sesson. Following actions must call Initialize again.
* Cache for the current session is discarded, other sessions remain intact.
* Device is not PIN-locked.
* @start
* @next Success
*/
message EndSession {
} }
/** /**

View File

@ -44,7 +44,7 @@ enum MessageType {
MessageType_PinMatrixRequest = 18 [(wire_out) = true]; MessageType_PinMatrixRequest = 18 [(wire_out) = true];
MessageType_PinMatrixAck = 19 [(wire_in) = true, (wire_tiny) = true, (wire_no_fsm) = true]; MessageType_PinMatrixAck = 19 [(wire_in) = true, (wire_tiny) = true, (wire_no_fsm) = true];
MessageType_Cancel = 20 [(wire_in) = true, (wire_tiny) = true]; MessageType_Cancel = 20 [(wire_in) = true, (wire_tiny) = true];
MessageType_ClearSession = 24 [(wire_in) = true]; MessageType_LockDevice = 24 [(wire_in) = true];
MessageType_ApplySettings = 25 [(wire_in) = true]; MessageType_ApplySettings = 25 [(wire_in) = true];
MessageType_ButtonRequest = 26 [(wire_out) = true]; MessageType_ButtonRequest = 26 [(wire_out) = true];
MessageType_ButtonAck = 27 [(wire_in) = true, (wire_tiny) = true, (wire_no_fsm) = true]; MessageType_ButtonAck = 27 [(wire_in) = true, (wire_tiny) = true, (wire_no_fsm) = true];
@ -63,6 +63,7 @@ enum MessageType {
MessageType_GetNextU2FCounter = 80 [(wire_in) = true]; MessageType_GetNextU2FCounter = 80 [(wire_in) = true];
MessageType_NextU2FCounter = 81 [(wire_out) = true]; MessageType_NextU2FCounter = 81 [(wire_out) = true];
MessageType_ChangeWipeCode = 82 [(wire_in) = true]; MessageType_ChangeWipeCode = 82 [(wire_in) = true];
MessageType_EndSession = 83 [(wire_in) = true];
// Deprecated messages, kept for protobuf compatibility. // Deprecated messages, kept for protobuf compatibility.
// Both are marked wire_out so that we don't need to implement incoming handler for legacy // Both are marked wire_out so that we don't need to implement incoming handler for legacy

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 EndSession(p.MessageType):
MESSAGE_WIRE_TYPE = 83

View File

@ -10,5 +10,5 @@ if __debug__:
pass pass
class ClearSession(p.MessageType): class LockDevice(p.MessageType):
MESSAGE_WIRE_TYPE = 24 MESSAGE_WIRE_TYPE = 24

View File

@ -19,7 +19,7 @@ Features = 17 # type: Literal[17]
PinMatrixRequest = 18 # type: Literal[18] PinMatrixRequest = 18 # type: Literal[18]
PinMatrixAck = 19 # type: Literal[19] PinMatrixAck = 19 # type: Literal[19]
Cancel = 20 # type: Literal[20] Cancel = 20 # type: Literal[20]
ClearSession = 24 # type: Literal[24] LockDevice = 24 # type: Literal[24]
ApplySettings = 25 # type: Literal[25] ApplySettings = 25 # type: Literal[25]
ButtonRequest = 26 # type: Literal[26] ButtonRequest = 26 # type: Literal[26]
ButtonAck = 27 # type: Literal[27] ButtonAck = 27 # type: Literal[27]
@ -38,6 +38,7 @@ SdProtect = 79 # type: Literal[79]
GetNextU2FCounter = 80 # type: Literal[80] GetNextU2FCounter = 80 # type: Literal[80]
NextU2FCounter = 81 # type: Literal[81] NextU2FCounter = 81 # type: Literal[81]
ChangeWipeCode = 82 # type: Literal[82] ChangeWipeCode = 82 # type: Literal[82]
EndSession = 83 # type: Literal[83]
Deprecated_PassphraseStateRequest = 77 # type: Literal[77] Deprecated_PassphraseStateRequest = 77 # type: Literal[77]
Deprecated_PassphraseStateAck = 78 # type: Literal[78] Deprecated_PassphraseStateAck = 78 # type: Literal[78]
FirmwareErase = 6 # type: Literal[6] FirmwareErase = 6 # type: Literal[6]

View File

@ -62,7 +62,8 @@ void fsm_msgResetDevice(const ResetDevice *msg);
void fsm_msgEntropyAck(const EntropyAck *msg); void fsm_msgEntropyAck(const EntropyAck *msg);
void fsm_msgBackupDevice(const BackupDevice *msg); void fsm_msgBackupDevice(const BackupDevice *msg);
void fsm_msgCancel(const Cancel *msg); void fsm_msgCancel(const Cancel *msg);
void fsm_msgClearSession(const ClearSession *msg); void fsm_msgLockDevice(const LockDevice *msg);
void fsm_msgEndSession(const EndSession *msg);
void fsm_msgApplySettings(const ApplySettings *msg); void fsm_msgApplySettings(const ApplySettings *msg);
void fsm_msgApplyFlags(const ApplyFlags *msg); void fsm_msgApplyFlags(const ApplyFlags *msg);
void fsm_msgRecoveryDevice(const RecoveryDevice *msg); void fsm_msgRecoveryDevice(const RecoveryDevice *msg);

View File

@ -345,15 +345,19 @@ void fsm_msgCancel(const Cancel *msg) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
} }
void fsm_msgClearSession(const ClearSession *msg) { void fsm_msgLockDevice(const LockDevice *msg) {
(void)msg; (void)msg;
// we do not actually clear the session, we just lock it
// TODO: the message should be called LockSession see #819
config_lockDevice(); config_lockDevice();
layoutScreensaver(); layoutScreensaver();
fsm_sendSuccess(_("Session cleared")); fsm_sendSuccess(_("Session cleared"));
} }
void fsm_msgEndSession(const EndSession *msg) {
(void)msg;
// TODO
fsm_sendFailure(FailureType_Failure_FirmwareError, "Not implemented");
}
void fsm_msgApplySettings(const ApplySettings *msg) { void fsm_msgApplySettings(const ApplySettings *msg) {
CHECK_PARAM( CHECK_PARAM(
!msg->has_passphrase_always_on_device, !msg->has_passphrase_always_on_device,

View File

@ -285,7 +285,7 @@ class TrezorClient:
@tools.session @tools.session
def clear_session(self): def clear_session(self):
resp = self.call_raw(messages.ClearSession()) resp = self.call_raw(messages.LockDevice()) # TODO fix this
if isinstance(resp, messages.Success): if isinstance(resp, messages.Success):
self.session_id = None self.session_id = None
self.init_device() self.init_device()

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 EndSession(p.MessageType):
MESSAGE_WIRE_TYPE = 83

View File

@ -10,5 +10,5 @@ if __debug__:
pass pass
class ClearSession(p.MessageType): class LockDevice(p.MessageType):
MESSAGE_WIRE_TYPE = 24 MESSAGE_WIRE_TYPE = 24

View File

@ -17,7 +17,7 @@ Features = 17 # type: Literal[17]
PinMatrixRequest = 18 # type: Literal[18] PinMatrixRequest = 18 # type: Literal[18]
PinMatrixAck = 19 # type: Literal[19] PinMatrixAck = 19 # type: Literal[19]
Cancel = 20 # type: Literal[20] Cancel = 20 # type: Literal[20]
ClearSession = 24 # type: Literal[24] LockDevice = 24 # type: Literal[24]
ApplySettings = 25 # type: Literal[25] ApplySettings = 25 # type: Literal[25]
ButtonRequest = 26 # type: Literal[26] ButtonRequest = 26 # type: Literal[26]
ButtonAck = 27 # type: Literal[27] ButtonAck = 27 # type: Literal[27]
@ -36,6 +36,7 @@ SdProtect = 79 # type: Literal[79]
GetNextU2FCounter = 80 # type: Literal[80] GetNextU2FCounter = 80 # type: Literal[80]
NextU2FCounter = 81 # type: Literal[81] NextU2FCounter = 81 # type: Literal[81]
ChangeWipeCode = 82 # type: Literal[82] ChangeWipeCode = 82 # type: Literal[82]
EndSession = 83 # type: Literal[83]
Deprecated_PassphraseStateRequest = 77 # type: Literal[77] Deprecated_PassphraseStateRequest = 77 # type: Literal[77]
Deprecated_PassphraseStateAck = 78 # type: Literal[78] Deprecated_PassphraseStateAck = 78 # type: Literal[78]
FirmwareErase = 6 # type: Literal[6] FirmwareErase = 6 # type: Literal[6]

View File

@ -34,7 +34,6 @@ from .ChangePin import ChangePin
from .ChangeWipeCode import ChangeWipeCode from .ChangeWipeCode import ChangeWipeCode
from .CipherKeyValue import CipherKeyValue from .CipherKeyValue import CipherKeyValue
from .CipheredKeyValue import CipheredKeyValue from .CipheredKeyValue import CipheredKeyValue
from .ClearSession import ClearSession
from .CosiCommit import CosiCommit from .CosiCommit import CosiCommit
from .CosiCommitment import CosiCommitment from .CosiCommitment import CosiCommitment
from .CosiSign import CosiSign from .CosiSign import CosiSign
@ -59,6 +58,7 @@ from .DebugMoneroDiagRequest import DebugMoneroDiagRequest
from .Deprecated_PassphraseStateAck import Deprecated_PassphraseStateAck from .Deprecated_PassphraseStateAck import Deprecated_PassphraseStateAck
from .Deprecated_PassphraseStateRequest import Deprecated_PassphraseStateRequest from .Deprecated_PassphraseStateRequest import Deprecated_PassphraseStateRequest
from .ECDHSessionKey import ECDHSessionKey from .ECDHSessionKey import ECDHSessionKey
from .EndSession import EndSession
from .Entropy import Entropy from .Entropy import Entropy
from .EntropyAck import EntropyAck from .EntropyAck import EntropyAck
from .EntropyRequest import EntropyRequest from .EntropyRequest import EntropyRequest
@ -130,6 +130,7 @@ from .LiskTransactionAsset import LiskTransactionAsset
from .LiskTransactionCommon import LiskTransactionCommon from .LiskTransactionCommon import LiskTransactionCommon
from .LiskVerifyMessage import LiskVerifyMessage from .LiskVerifyMessage import LiskVerifyMessage
from .LoadDevice import LoadDevice from .LoadDevice import LoadDevice
from .LockDevice import LockDevice
from .MessageSignature import MessageSignature from .MessageSignature import MessageSignature
from .MoneroAccountPublicAddress import MoneroAccountPublicAddress from .MoneroAccountPublicAddress import MoneroAccountPublicAddress
from .MoneroAddress import MoneroAddress from .MoneroAddress import MoneroAddress