mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
implement ClearSession
This commit is contained in:
parent
272e10152f
commit
441bb3b513
@ -419,6 +419,13 @@ void fsm_msgCipherKeyValue(CipherKeyValue *msg)
|
||||
layoutHome();
|
||||
}
|
||||
|
||||
void fsm_msgClearSession(ClearSession *msg)
|
||||
{
|
||||
(void)msg;
|
||||
session_clear();
|
||||
fsm_sendSuccess("Session cleared");
|
||||
}
|
||||
|
||||
void fsm_msgApplySettings(ApplySettings *msg)
|
||||
{
|
||||
if (msg->has_label && msg->has_language) {
|
||||
|
@ -42,6 +42,7 @@ void fsm_msgSignTx(SignTx *msg);
|
||||
void fsm_msgCancel(Cancel *msg);
|
||||
void fsm_msgTxAck(TxAck *msg);
|
||||
void fsm_msgCipherKeyValue(CipherKeyValue *msg);
|
||||
void fsm_msgClearSession(ClearSession *msg);
|
||||
void fsm_msgApplySettings(ApplySettings *msg);
|
||||
//void fsm_msgButtonAck(ButtonAck *msg);
|
||||
void fsm_msgGetAddress(GetAddress *msg);
|
||||
|
@ -54,6 +54,7 @@ static const struct MessagesMap_t MessagesMap[] = {
|
||||
{'n', 'i', MessageType_MessageType_Cancel, Cancel_fields, (void (*)(void *))fsm_msgCancel},
|
||||
{'n', 'i', MessageType_MessageType_TxAck, TxAck_fields, (void (*)(void *))fsm_msgTxAck},
|
||||
{'n', 'i', MessageType_MessageType_CipherKeyValue, CipherKeyValue_fields, (void (*)(void *))fsm_msgCipherKeyValue},
|
||||
{'n', 'i', MessageType_MessageType_ClearSession, ClearSession_fields, (void (*)(void *))fsm_msgClearSession},
|
||||
{'n', 'i', MessageType_MessageType_ApplySettings, ApplySettings_fields, (void (*)(void *))fsm_msgApplySettings},
|
||||
// {'n', 'i', MessageType_MessageType_ButtonAck, ButtonAck_fields, (void (*)(void *))fsm_msgButtonAck},
|
||||
{'n', 'i', MessageType_MessageType_GetAddress, GetAddress_fields, (void (*)(void *))fsm_msgGetAddress},
|
||||
|
@ -37,6 +37,10 @@ const pb_field_t Features_fields[16] = {
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t ClearSession_fields[1] = {
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t ApplySettings_fields[3] = {
|
||||
PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, ApplySettings, language, language, 0),
|
||||
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, ApplySettings, label, language, 0),
|
||||
@ -205,6 +209,19 @@ const pb_field_t MessageSignature_fields[3] = {
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t EncryptMessage_fields[4] = {
|
||||
PB_FIELD2( 1, BYTES , OPTIONAL, CALLBACK, FIRST, EncryptMessage, pubkey, pubkey, 0),
|
||||
PB_FIELD2( 2, BYTES , OPTIONAL, CALLBACK, OTHER, EncryptMessage, message, pubkey, 0),
|
||||
PB_FIELD2( 3, BOOL , OPTIONAL, STATIC , OTHER, EncryptMessage, display_only, message, 0),
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t DecryptMessage_fields[3] = {
|
||||
PB_FIELD2( 1, UINT32 , REPEATED, CALLBACK, FIRST, DecryptMessage, address_n, address_n, 0),
|
||||
PB_FIELD2( 2, BYTES , OPTIONAL, CALLBACK, OTHER, DecryptMessage, message, address_n, 0),
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t CipherKeyValue_fields[7] = {
|
||||
PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, CipherKeyValue, address_n, address_n, 0),
|
||||
PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, CipherKeyValue, key, address_n, 0),
|
||||
@ -307,7 +324,7 @@ const pb_field_t DebugLinkLog_fields[4] = {
|
||||
* numbers or field sizes that are larger than what can fit in 8 or 16 bit
|
||||
* field descriptors.
|
||||
*/
|
||||
STATIC_ASSERT((pb_membersize(Features, coins[0]) < 65536 && pb_membersize(PublicKey, node) < 65536 && pb_membersize(LoadDevice, node) < 65536 && pb_membersize(SimpleSignTx, inputs[0]) < 65536 && pb_membersize(SimpleSignTx, outputs[0]) < 65536 && pb_membersize(SimpleSignTx, transactions[0]) < 65536 && pb_membersize(TxRequest, details) < 65536 && pb_membersize(TxRequest, serialized) < 65536 && pb_membersize(TxAck, tx) < 65536 && pb_membersize(DebugLinkState, node) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Initialize_Features_ApplySettings_ChangePin_Ping_Success_Failure_ButtonRequest_ButtonAck_PinMatrixRequest_PinMatrixAck_Cancel_PassphraseRequest_PassphraseAck_GetEntropy_Entropy_GetPublicKey_PublicKey_GetAddress_Address_WipeDevice_LoadDevice_ResetDevice_EntropyRequest_EntropyAck_RecoveryDevice_WordRequest_WordAck_SignMessage_VerifyMessage_MessageSignature_CipherKeyValue_EstimateTxSize_TxSize_SignTx_SimpleSignTx_TxRequest_TxAck_FirmwareErase_FirmwareUpload_DebugLinkDecision_DebugLinkGetState_DebugLinkState_DebugLinkStop_DebugLinkLog)
|
||||
STATIC_ASSERT((pb_membersize(Features, coins[0]) < 65536 && pb_membersize(PublicKey, node) < 65536 && pb_membersize(LoadDevice, node) < 65536 && pb_membersize(SimpleSignTx, inputs[0]) < 65536 && pb_membersize(SimpleSignTx, outputs[0]) < 65536 && pb_membersize(SimpleSignTx, transactions[0]) < 65536 && pb_membersize(TxRequest, details) < 65536 && pb_membersize(TxRequest, serialized) < 65536 && pb_membersize(TxAck, tx) < 65536 && pb_membersize(DebugLinkState, node) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Initialize_Features_ClearSession_ApplySettings_ChangePin_Ping_Success_Failure_ButtonRequest_ButtonAck_PinMatrixRequest_PinMatrixAck_Cancel_PassphraseRequest_PassphraseAck_GetEntropy_Entropy_GetPublicKey_PublicKey_GetAddress_Address_WipeDevice_LoadDevice_ResetDevice_EntropyRequest_EntropyAck_RecoveryDevice_WordRequest_WordAck_SignMessage_VerifyMessage_MessageSignature_EncryptMessage_DecryptMessage_CipherKeyValue_EstimateTxSize_TxSize_SignTx_SimpleSignTx_TxRequest_TxAck_FirmwareErase_FirmwareUpload_DebugLinkDecision_DebugLinkGetState_DebugLinkState_DebugLinkStop_DebugLinkLog)
|
||||
#endif
|
||||
|
||||
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
|
||||
|
@ -35,6 +35,7 @@ typedef enum _MessageType {
|
||||
MessageType_MessageType_TxRequest = 21,
|
||||
MessageType_MessageType_TxAck = 22,
|
||||
MessageType_MessageType_CipherKeyValue = 23,
|
||||
MessageType_MessageType_ClearSession = 24,
|
||||
MessageType_MessageType_ApplySettings = 25,
|
||||
MessageType_MessageType_ButtonRequest = 26,
|
||||
MessageType_MessageType_ButtonAck = 27,
|
||||
@ -45,6 +46,8 @@ typedef enum _MessageType {
|
||||
MessageType_MessageType_SignMessage = 38,
|
||||
MessageType_MessageType_VerifyMessage = 39,
|
||||
MessageType_MessageType_MessageSignature = 40,
|
||||
MessageType_MessageType_EncryptMessage = 48,
|
||||
MessageType_MessageType_DecryptMessage = 49,
|
||||
MessageType_MessageType_PassphraseRequest = 41,
|
||||
MessageType_MessageType_PassphraseAck = 42,
|
||||
MessageType_MessageType_EstimateTxSize = 43,
|
||||
@ -68,6 +71,10 @@ typedef struct _Cancel {
|
||||
uint8_t dummy_field;
|
||||
} Cancel;
|
||||
|
||||
typedef struct _ClearSession {
|
||||
uint8_t dummy_field;
|
||||
} ClearSession;
|
||||
|
||||
typedef struct _DebugLinkGetState {
|
||||
uint8_t dummy_field;
|
||||
} DebugLinkGetState;
|
||||
@ -189,6 +196,18 @@ typedef struct _DebugLinkState {
|
||||
uint32_t recovery_word_pos;
|
||||
} DebugLinkState;
|
||||
|
||||
typedef struct _DecryptMessage {
|
||||
pb_callback_t address_n;
|
||||
pb_callback_t message;
|
||||
} DecryptMessage;
|
||||
|
||||
typedef struct _EncryptMessage {
|
||||
pb_callback_t pubkey;
|
||||
pb_callback_t message;
|
||||
bool has_display_only;
|
||||
bool display_only;
|
||||
} EncryptMessage;
|
||||
|
||||
typedef struct {
|
||||
size_t size;
|
||||
uint8_t bytes[1024];
|
||||
@ -500,6 +519,11 @@ extern const char SimpleSignTx_coin_name_default[17];
|
||||
#define DebugLinkState_reset_entropy_tag 8
|
||||
#define DebugLinkState_recovery_fake_word_tag 9
|
||||
#define DebugLinkState_recovery_word_pos_tag 10
|
||||
#define DecryptMessage_address_n_tag 1
|
||||
#define DecryptMessage_message_tag 2
|
||||
#define EncryptMessage_pubkey_tag 1
|
||||
#define EncryptMessage_message_tag 2
|
||||
#define EncryptMessage_display_only_tag 3
|
||||
#define Entropy_entropy_tag 1
|
||||
#define EntropyAck_entropy_tag 1
|
||||
#define EstimateTxSize_outputs_count_tag 1
|
||||
@ -581,6 +605,7 @@ extern const char SimpleSignTx_coin_name_default[17];
|
||||
/* Struct field encoding specification for nanopb */
|
||||
extern const pb_field_t Initialize_fields[1];
|
||||
extern const pb_field_t Features_fields[16];
|
||||
extern const pb_field_t ClearSession_fields[1];
|
||||
extern const pb_field_t ApplySettings_fields[3];
|
||||
extern const pb_field_t ChangePin_fields[2];
|
||||
extern const pb_field_t Ping_fields[5];
|
||||
@ -610,6 +635,8 @@ extern const pb_field_t WordAck_fields[2];
|
||||
extern const pb_field_t SignMessage_fields[4];
|
||||
extern const pb_field_t VerifyMessage_fields[4];
|
||||
extern const pb_field_t MessageSignature_fields[3];
|
||||
extern const pb_field_t EncryptMessage_fields[4];
|
||||
extern const pb_field_t DecryptMessage_fields[3];
|
||||
extern const pb_field_t CipherKeyValue_fields[7];
|
||||
extern const pb_field_t EstimateTxSize_fields[4];
|
||||
extern const pb_field_t TxSize_fields[2];
|
||||
@ -628,6 +655,7 @@ extern const pb_field_t DebugLinkLog_fields[4];
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define Initialize_size 0
|
||||
#define Features_size (224 + 4*CoinType_size)
|
||||
#define ClearSession_size 0
|
||||
#define ApplySettings_size 54
|
||||
#define ChangePin_size 2
|
||||
#define Ping_size 265
|
||||
|
@ -109,6 +109,11 @@ void storage_reset(void)
|
||||
// reset storage struct
|
||||
memset(&storage, 0, sizeof(storage));
|
||||
storage.version = STORAGE_VERSION;
|
||||
session_clear();
|
||||
}
|
||||
|
||||
void session_clear(void)
|
||||
{
|
||||
sessionRootNodeCached = false; memset(&sessionRootNode, 0, sizeof(sessionRootNode));
|
||||
sessionPassphraseCached = false; memset(&sessionPassphrase, 0, sizeof(sessionPassphrase));
|
||||
sessionPinCached = false; memset(&sessionPin, 0, sizeof(sessionPin));
|
||||
|
@ -29,6 +29,7 @@ void storage_init(void);
|
||||
void storage_reset_uuid(void);
|
||||
void storage_reset(void);
|
||||
void storage_commit(void);
|
||||
void session_clear(void);
|
||||
|
||||
void storage_loadDevice(LoadDevice *msg);
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f264f01314cefed2df4cfac84d7619d713fbc99a
|
||||
Subproject commit bf7b99fd286ae6ff5ada0e1bc7e4d403f5a7dc8e
|
Loading…
Reference in New Issue
Block a user