diff --git a/firmware/fsm.c b/firmware/fsm.c index d14e86d19..1976a8645 100644 --- a/firmware/fsm.c +++ b/firmware/fsm.c @@ -57,6 +57,11 @@ void fsm_sendSuccess(const char *text) void fsm_sendFailure(FailureType code, const char *text) { + if (protectAbortedByInitialize) { + fsm_msgInitialize((Initialize *)0); + protectAbortedByInitialize = false; + return; + } RESP_INIT(Failure); resp->has_code = true; resp->code = code; diff --git a/firmware/protect.c b/firmware/protect.c index 57684a2ed..a473fd226 100644 --- a/firmware/protect.c +++ b/firmware/protect.c @@ -29,6 +29,8 @@ #include "util.h" #include "debug.h" +bool protectAbortedByInitialize = false; + bool protectButton(ButtonRequestType type, bool confirm_only) { ButtonRequest resp; @@ -66,7 +68,7 @@ bool protectButton(ButtonRequestType type, bool confirm_only) if (msg_tiny_id == MessageType_MessageType_Cancel || msg_tiny_id == MessageType_MessageType_Initialize) { if (msg_tiny_id == MessageType_MessageType_Initialize) { - fsm_msgInitialize((Initialize *)msg_tiny); + protectAbortedByInitialize = true; } msg_tiny_id = 0xFFFF; result = false; @@ -115,7 +117,7 @@ const char *requestPin(PinMatrixRequestType type, const char *text) if (msg_tiny_id == MessageType_MessageType_Cancel || msg_tiny_id == MessageType_MessageType_Initialize) { pinmatrix_done(0); if (msg_tiny_id == MessageType_MessageType_Initialize) { - fsm_msgInitialize((Initialize *)msg_tiny); + protectAbortedByInitialize = true; } msg_tiny_id = 0xFFFF; usbTiny(0); @@ -209,7 +211,7 @@ bool protectPassphrase(void) } if (msg_tiny_id == MessageType_MessageType_Cancel || msg_tiny_id == MessageType_MessageType_Initialize) { if (msg_tiny_id == MessageType_MessageType_Initialize) { - fsm_msgInitialize((Initialize *)msg_tiny); + protectAbortedByInitialize = true; } msg_tiny_id = 0xFFFF; result = false; diff --git a/firmware/protect.h b/firmware/protect.h index 07fdb2532..4a7a36164 100644 --- a/firmware/protect.h +++ b/firmware/protect.h @@ -28,4 +28,6 @@ bool protectPin(bool use_cached); bool protectChangePin(void); bool protectPassphrase(void); +extern bool protectAbortedByInitialize; + #endif diff --git a/trezor-crypto b/trezor-crypto index 94d4a3733..44116b8a7 160000 --- a/trezor-crypto +++ b/trezor-crypto @@ -1 +1 @@ -Subproject commit 94d4a3733ed10c6db9225a23edcdfee6c7fcb2b2 +Subproject commit 44116b8a7405299be5de8353e9e624538b4dac92