Skip to content

Commit

Permalink
stax: do not advance 'review request' screen until finger tap
Browse files Browse the repository at this point in the history
  • Loading branch information
emturner committed Oct 31, 2023
1 parent 1287d14 commit 9133501
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/src/ui_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ typedef struct {
#ifdef HAVE_NBGL
tz_ui_stream_display_t current_screen;
char verify_address[TZ_BASE58CHECK_BUFFER_SIZE(20, 3)];
nbgl_callback_t stream_cb;
#endif // HAVE_NBGL
} tz_ui_stream_t;

Expand Down
29 changes: 27 additions & 2 deletions app/src/ui_stream_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,41 @@ tz_ui_continue(void)
}

void
tz_ui_stream(void)
tz_ui_stream_cb(void)
{
FUNC_ENTER(("void"));

nbgl_useCaseForwardOnlyReview("Reject", NULL, tz_ui_nav_cb, tz_choice_ui);

FUNC_LEAVE();
}

void
tz_ui_stream(void)
{
tz_ui_stream_t *s = &global.stream;
FUNC_ENTER(("void"));

if (s->stream_cb)
s->stream_cb();

FUNC_LEAVE();
return;
}

void
tz_ui_review_start()
{
tz_ui_stream_t *s = &global.stream;

FUNC_ENTER(("void"));

s->stream_cb = &tz_ui_stream_cb;
tz_ui_stream();

FUNC_LEAVE();
}

void
tz_ui_stream_init(void (*cb)(uint8_t))
{
Expand All @@ -134,7 +159,7 @@ tz_ui_stream_init(void (*cb)(uint8_t))
s->total = -1;

nbgl_useCaseReviewStart(&C_tezos, "Review request to sign operation",
NULL, "Reject request", tz_ui_stream,
NULL, "Reject request", tz_ui_review_start,
tz_reject_ui);

FUNC_LEAVE();
Expand Down
14 changes: 8 additions & 6 deletions tests/integration/stax/test_parsing_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ def send_second(app, apdu):
send_second(app, "800f81005e0100000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316")

with app.review_parsing_error("invalid_tag"):
pass # FIXME app.review.tap()
app.review.tap()
assert_home_with_code(app, "9405")

# Unknown operation
send_first(app, "800f000011048000002c800006c18000000080000000")
send_second(app, "800f81005e03000000000000000000000000000000000000000000000000000000000000000001016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316")

with app.review_parsing_error("invalid_tag"):
pass # FIXME app.review.tap()
app.review.tap()
assert_home_with_code(app, "9405")

# 1 byte remove inside
send_first(app, "800f000011048000002c800006c18000000080000000")
send_second(app, "800f81005d0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e010000000000000000000000000000000000000000ff02000000020316")

# FIXME: app.review.tap()
app.review.tap()
app.assert_screen("operation_0_transaction")

app.review.tap()
Expand All @@ -84,6 +84,7 @@ def send_second(app, apdu):
send_first(app, "800f000011048000002c800006c18000000080000000")
send_second(app, "800f81005f0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff0200000002031645")

app.review.tap()
app.assert_screen("operation_0_transaction")

app.review.tap()
Expand Down Expand Up @@ -112,6 +113,7 @@ def send_second(app, apdu):
send_first(app, "800f000011048000002c800006c18000000080000000")
send_second(app, "800f81005f0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e0100000000000000000000000000000000000000000000ff02000000020316")

app.review.tap()
app.assert_screen("operation_0_transaction")

app.review.tap()
Expand All @@ -135,22 +137,22 @@ def send_second(app, apdu):
send_second(app, "800f810028050092abf8e3d9e5f8cfd9ae8a9fe5f28ea1d5b5abf1af82dae8a4b68df3d1889eb6f988f5e8d31a")

with app.review_parsing_error("too_large"):
pass # FIXME app.review.tap()
app.review.tap()
assert_home_with_code(app, "9405")

# full output: {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{42}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
send_first(app, "800f000011048000002c800006c18000000080000000")
send_second(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")

with app.review_parsing_error("too_deep"):
pass # FIXME app.review.tap()
app.review.tap()
assert_home_with_code(app, "9405")

# wrong last packet
send_first(app, "800f000011048000002c800006c18000000080000000")
send_second(app, "800f8100eb030000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c63966303966323935326433343532386337333366393436313563666333396263353535363139666335353064643461363762613232303863653865383637616133643133613665663939646662653332633639373461613961323135306432316563613239633333343965353963313362393038316631")

# FIXME: app.review.tap()
app.review.tap()
app.assert_screen("operation_0_sr_outbox")

app.review.tap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

app.send_apdu("800f0100eb030000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c63966303966323935326433343532386337333366393436313563666333396263353535363139666335353064643461363762613232303863653865383637616133643133613665663939646662653332633639373461613961323135306432316563613239633333343965353963313362393038316631");

# FIXME: app.review.tap()
app.review.tap()
app.assert_screen("operation_0_sr_outbox")

app.review_skip_to_signing(with_loading=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/stax/test_sign_transfer_skip.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

app.send_apdu("800f81005e0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316");

# FIXME: app.review.tap()
app.review.tap()
app.assert_screen("operation_0_transaction")

app.review_skip_to_signing()
Expand Down

0 comments on commit 9133501

Please sign in to comment.