Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nano] remove blind large tx option #297

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 3 additions & 31 deletions app/src/apdu_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ static void handle_data_apdu_blind(void);
static void pass_from_clear_to_summary(void);
#ifdef HAVE_BAGL
static void init_too_many_screens_stream(void);
static void init_blind_warning_stream(void);
#endif
#ifdef HAVE_NBGL
static void continue_blindsign_cb(void);
Expand Down Expand Up @@ -239,7 +238,6 @@ refill_blo_im_full(void)
#ifdef HAVE_BAGL
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 @@ -334,11 +332,7 @@ refill_blo_done(void)

#ifdef HAVE_BAGL
if (global.step == ST_SUMMARY_SIGN) {
if (global.blindsign_reason == REASON_TOO_MANY_SCREENS) {
init_too_many_screens_stream();
} else {
init_blind_warning_stream();
}
init_too_many_screens_stream();
TZ_SUCCEED();
}
tz_ui_stream_push_accept_reject();
Expand Down Expand Up @@ -540,7 +534,9 @@ stream_cb(tz_ui_cb_type_t cb_type)
case TZ_UI_STREAM_CB_BLINDSIGN_REJECT: send_reject(EXC_PARSE_ERROR); break;
case TZ_UI_STREAM_CB_CANCEL: TZ_CHECK(send_cancel()); break;
case TZ_UI_STREAM_CB_BLINDSIGN: TZ_CHECK(pass_from_clear_to_blind()); break;
#ifdef HAVE_NBGL
case TZ_UI_STREAM_CB_SUMMARY: TZ_CHECK(pass_from_clear_to_summary()); break;
#endif
default: TZ_FAIL(EXC_UNKNOWN); break;
}
// clang-format on
Expand Down Expand Up @@ -686,20 +682,6 @@ init_too_many_screens_stream(void)
tz_ui_stream();
}

static void
init_blind_warning_stream(void)
{
tz_ui_stream_init(pass_to_summary_stream_cb);

tz_ui_stream_push_warning_not_trusted(NULL, NULL);
tz_ui_stream_push_risky_accept_reject(TZ_UI_STREAM_CB_VALIDATE,
TZ_UI_STREAM_CB_REJECT);

tz_ui_stream_close();

tz_ui_stream();
}

static void
bs_push_next(void)
{
Expand Down Expand Up @@ -814,16 +796,6 @@ handle_first_apdu_clear(__attribute__((unused)) command_t *cmd)
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
11 changes: 9 additions & 2 deletions app/src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ typedef enum {
} main_step_t;

typedef enum {
#ifdef HAVE_BAGL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use bool. there are only two settings so enum does not make sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I will change it when I will apply my commits in your PR

ST_BLINDSIGN_OFF = 0,
ST_BLINDSIGN_ON
#else
ST_BLINDSIGN_LARGE_TX = 0,
ST_BLINDSIGN_ON = 1,
ST_BLINDSIGN_OFF = 2
#endif
} blindsign_state_t;

#ifdef TARGET_NANOS
Expand All @@ -76,11 +81,13 @@ typedef enum {
#define NB_MAX_SCREEN_ALLOWED 8
#endif

#ifdef HAVE_NBGL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you dont need the reason,
You have to show amount, fees, hash in case of large_tx but only hash in case of parsing error. How do you differenciate the two cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two flow are different, so no need to differentiate the case later:

  • On parsing error the screen are directly displayed then the flow displayed is the blindsigning flow.
  • On too-large-operation the flow is the summary flow (finish the parsing before display warning screen)

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
Expand Down Expand Up @@ -114,9 +121,9 @@ typedef struct {
/// "ON" , "OFF"
#endif

blindsign_reason_t
blindsign_reason; /// Blindsigning flow Summary or parsing error.
#ifdef HAVE_NBGL
blindsign_reason_t
blindsign_reason; /// Blindsigning flow Summary or parsing error.
char error_code[ERROR_CODE_SIZE]; /// Error code for parsing error.
#endif
main_step_t step; /// Current operational state of app.
Expand Down
6 changes: 1 addition & 5 deletions app/src/ui_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,12 @@ ui_settings_init(int16_t page)
}

switch (N_settings.blindsign_status) {
case ST_BLINDSIGN_LARGE_TX:
default:
strncpy(global.blindsign_state_desc, "For Large Tx",
sizeof(global.blindsign_state_desc));
break;
case ST_BLINDSIGN_ON:
strncpy(global.blindsign_state_desc, "ON",
sizeof(global.blindsign_state_desc));
break;
case ST_BLINDSIGN_OFF:
default:
strncpy(global.blindsign_state_desc, "OFF",
sizeof(global.blindsign_state_desc));
break;
Expand Down
13 changes: 6 additions & 7 deletions app/src/ui_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ 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;
global.blindsign_reason = REASON_NONE;
s->cb = cb;
s->full = false;
s->current = 0;
s->pressed_right = false;
s->total = -1;
s->last = 0;

ui_strings_init();

Expand Down
6 changes: 4 additions & 2 deletions app/src/ui_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@
*/

typedef uint8_t tz_ui_cb_type_t;
#define TZ_UI_STREAM_CB_NOCB 0x00u
#define TZ_UI_STREAM_CB_SUMMARY 0x0Du
#define TZ_UI_STREAM_CB_NOCB 0x00u
#ifdef HAVE_NBGL
#define TZ_UI_STREAM_CB_SUMMARY 0x0Du
#endif
#define TZ_UI_STREAM_CB_BLINDSIGN 0x0Eu
#define TZ_UI_STREAM_CB_VALIDATE 0x0Fu
#define TZ_UI_STREAM_CB_REFILL 0xEFu
Expand Down
2 changes: 0 additions & 2 deletions tests/generate/gen_integration.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ let reject ppf () =
Button.(press ppf Both)

let set_expert_mode ppf () = Format.fprintf ppf "set_expert_mode@."
let set_blindsign_off ppf () = Format.fprintf ppf "set_blindsign_off@."

type screen = { title : string; contents : string }

Expand Down Expand Up @@ -535,7 +534,6 @@ let gen_expect_test_sign ?(expert_mode = false) ppf ~watermark bin screens =
start_speculos ppf signer.mnemonic;
expected_home ppf ();
if expert_mode then set_expert_mode ppf ();
set_blindsign_off ppf ();
sign ppf ~signer ~watermark bin;
expected_review_operation ppf ();
Button.(press ppf Right);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def test_nanos_regression_batched_ops(app):
test_name = Path(__file__).stem

app.setup_expert_mode()
app.setup_blindsign_off()

message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c001597c45b11b421bb806a0c56c5da5638bf4b1adbf0e617090006a09c010000bac799dfc7f6af2ff0b95f83d023e68c895020baffff086a65616e5f626f620000009a020000009507070200000000050800c6bab5ccc8d891cd8de4b6f7070707020000004b0704030b070702000000040505030b070705050a0000001503f01167865dc63dfee0e31251329ceab660d9460607070a000000150107b21fca96c5763f67b286752c7aaefc5931d15a030b050800a9df9fc1e7eaa7a9c1f7bd87a9ba9cadf5b5b2cd829deea2b7fef9070707020000000005050509030b6c01ee572f02e5be5d097ba17369789582882e8abb8790d627063202e0d403012b704944f5b5fd30eed2ab4385478488e09fe04a0000")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.
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.
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.
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.
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.
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.
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
Loading