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

legacy: implement EndSession

This commit is contained in:
matejcik 2020-08-25 16:04:36 +02:00 committed by matejcik
parent 4909821f35
commit 58621711d1
3 changed files with 15 additions and 8 deletions

View File

@ -582,9 +582,13 @@ static void get_root_node_callback(uint32_t iter, uint32_t total) {
}
const uint8_t *config_getSeed(void) {
if (activeSessionCache == NULL) {
fsm_sendFailure(FailureType_Failure_ProcessError, "Invalid session");
return NULL;
}
// root node is properly cached
if ((activeSessionCache != NULL) &&
(activeSessionCache->seedCached == sectrue)) {
if (activeSessionCache->seedCached == sectrue) {
return activeSessionCache->seed;
}
@ -608,10 +612,6 @@ const uint8_t *config_getSeed(void) {
}
}
char oldTiny = usbTiny(1);
if (activeSessionCache == NULL) {
// this should not happen if the Host behaves and sends Initialize first
session_startSession(NULL);
}
mnemonic_to_seed(mnemonic, passphrase, activeSessionCache->seed,
get_root_node_callback); // BIP-0039
memzero(mnemonic, sizeof(mnemonic));
@ -858,6 +858,12 @@ uint8_t *session_startSession(const uint8_t *received_session_id) {
return activeSessionCache->id;
}
void session_endCurrentSession(void) {
if (activeSessionCache == NULL) return;
session_clearCache(activeSessionCache);
activeSessionCache = NULL;
}
bool session_isUnlocked(void) { return sectrue == storage_is_unlocked(); }
bool config_isInitialized(void) {

View File

@ -90,6 +90,7 @@ extern Storage configUpdate;
void config_init(void);
void session_clear(bool lock);
void session_endCurrentSession(void);
void config_lockDevice(void);
void config_loadDevice(const LoadDevice *msg);

View File

@ -354,8 +354,8 @@ void fsm_msgLockDevice(const LockDevice *msg) {
void fsm_msgEndSession(const EndSession *msg) {
(void)msg;
// TODO
fsm_sendFailure(FailureType_Failure_FirmwareError, "Not implemented");
session_endCurrentSession();
fsm_sendSuccess(_("Session ended"));
}
void fsm_msgApplySettings(const ApplySettings *msg) {