From f21c13f0bd6c0e113dc7044021e6c63753353de9 Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Tue, 28 Jan 2020 14:18:00 +0000 Subject: [PATCH] legacy: remove redundant failure response --- legacy/firmware/config.c | 12 ++++++++++-- legacy/firmware/fsm.c | 3 --- legacy/firmware/protect.c | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/legacy/firmware/config.c b/legacy/firmware/config.c index 45900beb5f..bddff3d51b 100644 --- a/legacy/firmware/config.c +++ b/legacy/firmware/config.c @@ -31,6 +31,7 @@ #include "config.h" #include "curves.h" #include "debug.h" +#include "fsm.h" #include "gettext.h" #include "hmac.h" #include "layout2.h" @@ -581,6 +582,9 @@ const uint8_t *config_getSeed(void) { usbTiny(oldTiny); sessionSeedCached = sectrue; return sessionSeed; + } else { + fsm_sendFailure(FailureType_Failure_NotInitialized, + _("Device not initialized")); } return NULL; @@ -610,8 +614,12 @@ bool config_getRootNode(HDNode *node, const char *curve) { if (seed == NULL) { return false; } - - return hdnode_from_seed(seed, 64, curve, node); + int result; + result = hdnode_from_seed(seed, 64, curve, node); + if (result == 0) { + fsm_sendFailure(FailureType_Failure_NotInitialized, _("Unsupported curve")); + } + return result; } bool config_getLabel(char *dest, uint16_t dest_size) { diff --git a/legacy/firmware/fsm.c b/legacy/firmware/fsm.c index 0d12c31f7e..efc4a88ef8 100644 --- a/legacy/firmware/fsm.c +++ b/legacy/firmware/fsm.c @@ -213,9 +213,6 @@ static HDNode *fsm_getDerivedNode(const char *curve, const uint32_t *address_n, *fingerprint = 0; } if (!config_getRootNode(&node, curve)) { - fsm_sendFailure(FailureType_Failure_NotInitialized, - _("Device not initialized or passphrase request cancelled " - "or unsupported curve")); layoutHome(); return 0; } diff --git a/legacy/firmware/protect.c b/legacy/firmware/protect.c index fdd8fb9c01..26675fd85b 100644 --- a/legacy/firmware/protect.c +++ b/legacy/firmware/protect.c @@ -397,8 +397,9 @@ bool protectPassphrase(char *passphrase) { protectAbortedByInitialize = (msg_tiny_id == MessageType_MessageType_Initialize); if (protectAbortedByCancel || protectAbortedByInitialize) { - msg_tiny_id = 0xFFFF; + fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); result = false; + msg_tiny_id = 0xFFFF; break; } }