1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 06:48:16 +00:00

firmware: introduce protectAbortedByCancel

This commit is contained in:
Pavol Rusnak 2018-06-05 22:38:39 +02:00
parent 49d9fe4d13
commit df0bad4f09
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 13 additions and 10 deletions

View File

@ -114,6 +114,9 @@ void fsm_sendFailureDebug(FailureType code, const char *text, const char *source
void fsm_sendFailure(FailureType code, const char *text)
#endif
{
if (protectAbortedByCancel) {
protectAbortedByCancel = false;
}
if (protectAbortedByInitialize) {
fsm_msgInitialize((Initialize *)0);
protectAbortedByInitialize = false;
@ -230,7 +233,7 @@ static bool fsm_layoutAddress(const char *address, const char *desc, bool ignore
if (protectButton(ButtonRequestType_ButtonRequest_Address, false)) {
return true;
}
if (protectAbortedByInitialize) {
if (protectAbortedByCancel || protectAbortedByInitialize) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return false;

View File

@ -34,6 +34,7 @@
#define MAX_WRONG_PINS 15
bool protectAbortedByCancel = false;
bool protectAbortedByInitialize = false;
bool protectButton(ButtonRequestType type, bool confirm_only)
@ -77,9 +78,8 @@ bool protectButton(ButtonRequestType type, bool confirm_only)
// check for Cancel / Initialize
if (msg_tiny_id == MessageType_MessageType_Cancel || msg_tiny_id == MessageType_MessageType_Initialize) {
if (msg_tiny_id == MessageType_MessageType_Initialize) {
protectAbortedByInitialize = true;
}
protectAbortedByCancel = (msg_tiny_id == MessageType_MessageType_Cancel);
protectAbortedByInitialize = (msg_tiny_id == MessageType_MessageType_Initialize);
msg_tiny_id = 0xFFFF;
result = false;
break;
@ -130,9 +130,8 @@ 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) {
protectAbortedByInitialize = true;
}
protectAbortedByCancel = (msg_tiny_id == MessageType_MessageType_Cancel);
protectAbortedByInitialize = (msg_tiny_id == MessageType_MessageType_Initialize);
msg_tiny_id = 0xFFFF;
usbTiny(0);
return 0;
@ -182,6 +181,7 @@ bool protectPin(bool use_cached)
// wait one second
usbSleep(1000);
if (msg_tiny_id == MessageType_MessageType_Initialize) {
protectAbortedByCancel = false;
protectAbortedByInitialize = true;
msg_tiny_id = 0xFFFF;
usbTiny(0);
@ -263,9 +263,8 @@ bool protectPassphrase(void)
break;
}
if (msg_tiny_id == MessageType_MessageType_Cancel || msg_tiny_id == MessageType_MessageType_Initialize) {
if (msg_tiny_id == MessageType_MessageType_Initialize) {
protectAbortedByInitialize = true;
}
protectAbortedByCancel = (msg_tiny_id == MessageType_MessageType_Cancel);
protectAbortedByInitialize = (msg_tiny_id == MessageType_MessageType_Initialize);
msg_tiny_id = 0xFFFF;
result = false;
break;

View File

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