Skip to content

Commit

Permalink
[blindsign] Ask to blindsign at review in nano (#292)
Browse files Browse the repository at this point in the history
* [blind] add blindsign question to jump to blindsign with blind ON

Otherwise, use the clearsign flow as the option was Large Tx

* [too_many_screen] reduce number of screen for NanoS+ and NanoX to 12
  • Loading branch information
spalmer25 authored Sep 25, 2024
1 parent 5da3881 commit 77583f7
Show file tree
Hide file tree
Showing 416 changed files with 67 additions and 27 deletions.
30 changes: 18 additions & 12 deletions app/src/apdu_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@ refill_blo_im_full(void)

global.keys.apdu.sign.step = SIGN_ST_WAIT_USER_INPUT;
#ifdef HAVE_BAGL
if ((N_settings.blindsign_status == ST_BLINDSIGN_LARGE_TX)
if ((N_settings.blindsign_status != ST_BLINDSIGN_OFF)
&& (SCREEN_DISPLAYED >= NB_MAX_SCREEN_ALLOWED)) {
global.blindsign_reason = REASON_TOO_MANY_SCREENS;
pass_from_clear_to_summary();
TZ_SUCCEED();
}
Expand Down Expand Up @@ -333,7 +334,7 @@ refill_blo_done(void)

#ifdef HAVE_BAGL
if (global.step == ST_SUMMARY_SIGN) {
if (N_settings.blindsign_status == ST_BLINDSIGN_LARGE_TX) {
if (global.blindsign_reason == REASON_TOO_MANY_SCREENS) {
init_too_many_screens_stream();
} else {
init_summary_stream();
Expand Down Expand Up @@ -793,12 +794,24 @@ handle_first_apdu_clear(__attribute__((unused)) command_t *cmd)
tz_ui_stream_init(stream_cb);
global.step = ST_CLEAR_SIGN;

#ifdef HAVE_BAGL
#ifdef TARGET_NANOS
tz_ui_stream_push(TZ_UI_STREAM_CB_NOCB, "Review operation", "",
TZ_UI_LAYOUT_HOME_PB, TZ_UI_ICON_EYE);
#elif defined(HAVE_BAGL)
tz_ui_stream_push(TZ_UI_STREAM_CB_NOCB, "Review", "operation",
TZ_UI_LAYOUT_HOME_PB, TZ_UI_ICON_EYE);
#else
tz_ui_stream_push(TZ_UI_STREAM_CB_NOCB, "Review", "operation",
TZ_UI_LAYOUT_HOME_PB, TZ_UI_ICON_EYE);
#endif
if (N_settings.blindsign_status == ST_BLINDSIGN_ON) {
#ifdef TARGET_NANOS
tz_ui_stream_push(TZ_UI_STREAM_CB_SUMMARY, "Blindsign?", "",
TZ_UI_LAYOUT_HOME_PB, TZ_UI_ICON_WARNING);
#else
tz_ui_stream_push(TZ_UI_STREAM_CB_SUMMARY, "Switch to",
"blindsign?", TZ_UI_LAYOUT_HOME_PB,
TZ_UI_ICON_WARNING);
#endif
}
#endif
#ifdef HAVE_SWAP
} else {
Expand Down Expand Up @@ -846,13 +859,6 @@ handle_data_apdu(command_t *cmd)
global.keys.apdu.sign.tag = cmd->data[0];
}

#ifdef HAVE_BAGL
if ((N_settings.blindsign_status == ST_BLINDSIGN_ON)
&& (global.step == ST_CLEAR_SIGN)) {
global.step = ST_SUMMARY_SIGN;
}
#endif

// clang-format off
switch (global.step) {
case ST_CLEAR_SIGN:
Expand Down
15 changes: 8 additions & 7 deletions app/src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,20 @@ typedef enum {
ST_BLINDSIGN_OFF = 2
} blindsign_state_t;

#ifdef HAVE_BAGL
#ifdef TARGET_NANOS
#define NB_MAX_SCREEN_ALLOWED 20
#endif
#ifdef HAVE_NBGL
#elif defined(HAVE_BAGL)
#define NB_MAX_SCREEN_ALLOWED 12
#else
#define NB_MAX_SCREEN_ALLOWED 8
#endif

typedef enum {
REASON_NONE = 0,
REASON_PARSING_ERROR = 1,
REASON_TOO_MANY_SCREENS = 2
} blindsign_reason_t;

#endif

/**
* @brief Global structure holding state of operations and buffer of the data
* to be processed.
Expand Down Expand Up @@ -113,9 +114,9 @@ typedef struct {
/// "ON" , "OFF"
#endif

#ifdef HAVE_NBGL
blindsign_reason_t
blindsign_reason; /// Blindsigning flow Summary or parsing error.
blindsign_reason; /// Blindsigning flow Summary or parsing error.
#ifdef HAVE_NBGL
char error_code[ERROR_CODE_SIZE]; /// Error code for parsing error.
#endif
main_step_t step; /// Current operational state of app.
Expand Down
13 changes: 7 additions & 6 deletions app/src/ui_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ tz_ui_stream_init(void (*cb)(tz_ui_cb_type_t cb_type))

FUNC_ENTER(("cb=%p", cb));
memset(s, 0x0, sizeof(*s));
s->cb = cb;
s->full = false;
s->current = 0;
s->pressed_right = false;
s->total = -1;
s->last = 0;
s->cb = cb;
s->full = false;
s->current = 0;
s->pressed_right = false;
s->total = -1;
s->last = 0;
global.blindsign_reason = REASON_NONE;

ui_strings_init();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def test_nanox_regression_batched_ops(app):
test_name = Path(__file__).stem

app.setup_expert_mode()
app.setup_blindsign_off()

message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c001597c45b11b421bb806a0c56c5da5638bf4b1adbf0e617090006a09c010000bac799dfc7f6af2ff0b95f83d023e68c895020baffff086a65616e5f626f620000009a020000009507070200000000050800c6bab5ccc8d891cd8de4b6f7070707020000004b0704030b070702000000040505030b070705050a0000001503f01167865dc63dfee0e31251329ceab660d9460607070a000000150107b21fca96c5763f67b286752c7aaefc5931d15a030b050800a9df9fc1e7eaa7a9c1f7bd87a9ba9cadf5b5b2cd829deea2b7fef9070707020000000005050509030b6c01ee572f02e5be5d097ba17369789582882e8abb8790d627063202e0d403012b704944f5b5fd30eed2ab4385478488e09fe04a0000")

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Loading

0 comments on commit 77583f7

Please sign in to comment.