1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-29 10:58:21 +00:00

fix initialize handling in interactive mode

This commit is contained in:
Pavol Rusnak 2014-05-20 15:36:35 +02:00
parent 0d0a1ab5f2
commit d7169a342c
4 changed files with 13 additions and 4 deletions

View File

@ -57,6 +57,11 @@ void fsm_sendSuccess(const char *text)
void fsm_sendFailure(FailureType code, const char *text) void fsm_sendFailure(FailureType code, const char *text)
{ {
if (protectAbortedByInitialize) {
fsm_msgInitialize((Initialize *)0);
protectAbortedByInitialize = false;
return;
}
RESP_INIT(Failure); RESP_INIT(Failure);
resp->has_code = true; resp->has_code = true;
resp->code = code; resp->code = code;

View File

@ -29,6 +29,8 @@
#include "util.h" #include "util.h"
#include "debug.h" #include "debug.h"
bool protectAbortedByInitialize = false;
bool protectButton(ButtonRequestType type, bool confirm_only) bool protectButton(ButtonRequestType type, bool confirm_only)
{ {
ButtonRequest resp; 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_Cancel || msg_tiny_id == MessageType_MessageType_Initialize) {
if (msg_tiny_id == MessageType_MessageType_Initialize) { if (msg_tiny_id == MessageType_MessageType_Initialize) {
fsm_msgInitialize((Initialize *)msg_tiny); protectAbortedByInitialize = true;
} }
msg_tiny_id = 0xFFFF; msg_tiny_id = 0xFFFF;
result = false; 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) { if (msg_tiny_id == MessageType_MessageType_Cancel || msg_tiny_id == MessageType_MessageType_Initialize) {
pinmatrix_done(0); pinmatrix_done(0);
if (msg_tiny_id == MessageType_MessageType_Initialize) { if (msg_tiny_id == MessageType_MessageType_Initialize) {
fsm_msgInitialize((Initialize *)msg_tiny); protectAbortedByInitialize = true;
} }
msg_tiny_id = 0xFFFF; msg_tiny_id = 0xFFFF;
usbTiny(0); 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_Cancel || msg_tiny_id == MessageType_MessageType_Initialize) {
if (msg_tiny_id == MessageType_MessageType_Initialize) { if (msg_tiny_id == MessageType_MessageType_Initialize) {
fsm_msgInitialize((Initialize *)msg_tiny); protectAbortedByInitialize = true;
} }
msg_tiny_id = 0xFFFF; msg_tiny_id = 0xFFFF;
result = false; result = false;

View File

@ -28,4 +28,6 @@ bool protectPin(bool use_cached);
bool protectChangePin(void); bool protectChangePin(void);
bool protectPassphrase(void); bool protectPassphrase(void);
extern bool protectAbortedByInitialize;
#endif #endif

@ -1 +1 @@
Subproject commit 94d4a3733ed10c6db9225a23edcdfee6c7fcb2b2 Subproject commit 44116b8a7405299be5de8353e9e624538b4dac92