From d96d3e705bbd9f6d2e706326820df78e1992e263 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Tue, 6 Sep 2022 16:05:39 +0200 Subject: [PATCH] fix(legacy): Clear CoSi nonce when device is wiped to fix CI. [no changelog] --- legacy/firmware/config.c | 2 ++ legacy/firmware/fsm.h | 1 + legacy/firmware/fsm_msg_crypto.h | 7 ++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/legacy/firmware/config.c b/legacy/firmware/config.c index 12a511070..cc1e5c759 100644 --- a/legacy/firmware/config.c +++ b/legacy/firmware/config.c @@ -976,6 +976,8 @@ void config_wipe(void) { storage_set(KEY_UUID, config_uuid, sizeof(config_uuid)); storage_set(KEY_VERSION, &CONFIG_VERSION, sizeof(CONFIG_VERSION)); session_clear(false); + fsm_abortWorkflows(); + fsm_clearCosiNonce(); #if USE_BIP32_CACHE bip32_cache_clear(); diff --git a/legacy/firmware/fsm.h b/legacy/firmware/fsm.h index 74387b1fa..eb8518fb8 100644 --- a/legacy/firmware/fsm.h +++ b/legacy/firmware/fsm.h @@ -87,6 +87,7 @@ void fsm_msgSignIdentity(const SignIdentity *msg); void fsm_msgGetECDHSessionKey(const GetECDHSessionKey *msg); void fsm_msgCosiCommit(const CosiCommit *msg); void fsm_msgCosiSign(const CosiSign *msg); +void fsm_clearCosiNonce(void); // debug #if DEBUG_LINK diff --git a/legacy/firmware/fsm_msg_crypto.h b/legacy/firmware/fsm_msg_crypto.h index 1cdd6d541..72f2cdb28 100644 --- a/legacy/firmware/fsm_msg_crypto.h +++ b/legacy/firmware/fsm_msg_crypto.h @@ -334,6 +334,11 @@ void fsm_msgCosiSign(const CosiSign *msg) { } else { fsm_sendFailure(FailureType_Failure_FirmwareError, NULL); } - memzero(cosi_nonce, sizeof(cosi_nonce)); + fsm_clearCosiNonce(); layoutHome(); } + +void fsm_clearCosiNonce(void) { + cosi_nonce_is_set = false; + memzero(cosi_nonce, sizeof(cosi_nonce)); +}