From d76806bbea983900af6978b5a1abbe2ec68c7a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Mon, 16 Oct 2023 15:14:05 +0200 Subject: [PATCH] Return to home after a refill error --- app/src/ui_stream.c | 5 +++ app/src/ui_stream_nbgl.c | 6 +++- .../integration/nanos/test_parsing_errors.sh | 36 +++++++++++++++++++ .../integration/nanosp/test_parsing_errors.sh | 18 ++++++++++ .../integration/nanox/test_parsing_errors.sh | 18 ++++++++++ tests/integration/stax/test_parsing_errors.py | 27 ++++++++++++++ 6 files changed, 109 insertions(+), 1 deletion(-) diff --git a/app/src/ui_stream.c b/app/src/ui_stream.c index d1cb95aed..54c490cc0 100644 --- a/app/src/ui_stream.c +++ b/app/src/ui_stream.c @@ -392,6 +392,11 @@ change_screen_right(void) if (s->current == s->total) { if (!s->full) s->cb(TZ_UI_STREAM_CB_REFILL); + if (global.step == ST_ERROR) { + global.step = ST_IDLE; + ui_home_init(); + return; + } } // go back to the data screen succ(); diff --git a/app/src/ui_stream_nbgl.c b/app/src/ui_stream_nbgl.c index 144cac37e..9ad4c54cf 100644 --- a/app/src/ui_stream_nbgl.c +++ b/app/src/ui_stream_nbgl.c @@ -196,7 +196,11 @@ tz_ui_nav_cb(uint8_t page, nbgl_pageContent_t *content) tz_ui_continue(); } - if (global.step != ST_CLEAR_SIGN && global.step != ST_BLIND_SIGN) { + if (global.step == ST_ERROR) { + global.step = ST_IDLE; + ui_home_init(); + return false; + } else if (global.step != ST_CLEAR_SIGN && global.step != ST_BLIND_SIGN) { return false; } else if (s->full) { content->type = INFO_LONG_PRESS; diff --git a/tests/integration/nanos/test_parsing_errors.sh b/tests/integration/nanos/test_parsing_errors.sh index 83c158c1a..740737580 100644 --- a/tests/integration/nanos/test_parsing_errors.sh +++ b/tests/integration/nanos/test_parsing_errors.sh @@ -77,6 +77,42 @@ press_button right expect_full_text 'Parsing error' press_button both expect_apdu_return 9405 + +# 1 byte introduce inside +send_apdu 800f000011048000002c800006c18000000080000000 +expect_apdu_return 9000 +send_apdu 800f81005f0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e0100000000000000000000000000000000000000000000ff02000000020316 +expect_full_text 'Operation (0)' 'Transaction' +press_button right +expect_full_text 'Fee' '0.05 tz' +press_button right +expect_full_text 'Storage limit' '45' +press_button right +expect_full_text 'Amount' '0.24 tz' +press_button right +expect_section_content nanos 'Destination' 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT' +press_button right +expect_full_text 'Parsing error' +press_button both +expect_apdu_return 9405 + +# wrong last packet +send_async_apdus \ + 800f000011048000002c800006c18000000080000000 "expect_apdu_return 9000" \ + 800f8100eb030000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c63966303966323935326433343532386337333366393436313563666333396263353535363139666335353064643461363762613232303863653865383637616133643133613665663939646662653332633639373461613961323135306432316563613239633333343965353963313362393038316631 "expect_apdu_return 9002" +expect_section_content nanos 'Operation (0)' 'SR: execute outbox message' +press_button right +expect_section_content nanos 'Fee' '0.01 tz' +press_button right +expect_section_content nanos 'Storage limit' '4' +press_button right +expect_section_content nanos 'Rollup' 'sr163Lv22CdE8QagCwf48PWDTquk6isQwv57' +press_button right +expect_section_content nanos 'Commitment' 'src12UJzB8mg7yU6nWPzicH7ofJbFjyJEbHvwtZdfRXi8DQHNp1LY8' +press_button right +expect_full_text 'ready for' 'safe signing' +expect_async_apdus_sent + press_button right press_button right press_button both diff --git a/tests/integration/nanosp/test_parsing_errors.sh b/tests/integration/nanosp/test_parsing_errors.sh index be43377f4..78154aa8b 100644 --- a/tests/integration/nanosp/test_parsing_errors.sh +++ b/tests/integration/nanosp/test_parsing_errors.sh @@ -77,6 +77,24 @@ press_button right expect_full_text 'Parsing error' 'ERR_INVALID_TAG' press_button both expect_apdu_return 9405 + +# wrong last packet +send_async_apdus \ + 800f000011048000002c800006c18000000080000000 "expect_apdu_return 9000" \ + 800f8100eb030000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c63966303966323935326433343532386337333366393436313563666333396263353535363139666335353064643461363762613232303863653865383637616133643133613665663939646662653332633639373461613961323135306432316563613239633333343965353963313362393038316631 "expect_apdu_return 9002" +expect_section_content nanosp 'Operation (0)' 'SR: execute outbox message' +press_button right +expect_section_content nanosp 'Fee' '0.01 tz' +press_button right +expect_section_content nanosp 'Storage limit' '4' +press_button right +expect_section_content nanosp 'Rollup' 'sr163Lv22CdE8QagCwf48PWDTquk6isQwv57' +press_button right +expect_section_content nanosp 'Commitment' 'src12UJzB8mg7yU6nWPzicH7ofJbFjyJEbHvwtZdfRXi8DQHNp1LY8' +press_button right +expect_full_text 'Tezos Wallet' 'ready for' 'safe signing' +expect_async_apdus_sent + press_button right press_button right press_button both diff --git a/tests/integration/nanox/test_parsing_errors.sh b/tests/integration/nanox/test_parsing_errors.sh index 2034b376e..78997a702 100644 --- a/tests/integration/nanox/test_parsing_errors.sh +++ b/tests/integration/nanox/test_parsing_errors.sh @@ -77,6 +77,24 @@ press_button right expect_full_text 'Parsing error' 'ERR_INVALID_TAG' press_button both expect_apdu_return 9405 + +# wrong last packet +send_async_apdus \ + 800f000011048000002c800006c18000000080000000 "expect_apdu_return 9000" \ + 800f8100eb030000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c63966303966323935326433343532386337333366393436313563666333396263353535363139666335353064643461363762613232303863653865383637616133643133613665663939646662653332633639373461613961323135306432316563613239633333343965353963313362393038316631 "expect_apdu_return 9002" +expect_section_content nanox 'Operation (0)' 'SR: execute outbox message' +press_button right +expect_section_content nanox 'Fee' '0.01 tz' +press_button right +expect_section_content nanox 'Storage limit' '4' +press_button right +expect_section_content nanox 'Rollup' 'sr163Lv22CdE8QagCwf48PWDTquk6isQwv57' +press_button right +expect_section_content nanox 'Commitment' 'src12UJzB8mg7yU6nWPzicH7ofJbFjyJEbHvwtZdfRXi8DQHNp1LY8' +press_button right +expect_full_text 'Tezos Wallet' 'ready for' 'safe signing' +expect_async_apdus_sent + press_button right press_button right press_button both diff --git a/tests/integration/stax/test_parsing_errors.py b/tests/integration/stax/test_parsing_errors.py index 3522b5023..3770d2ce5 100644 --- a/tests/integration/stax/test_parsing_errors.py +++ b/tests/integration/stax/test_parsing_errors.py @@ -135,5 +135,32 @@ app.send_apdu("800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000") app.expect_apdu_failure("9405") + + # wrong last packet + app.send_apdu("800f000011048000002c800006c18000000080000000") + app.expect_apdu_return("9000") + + app.assert_screen("review_request_sign_operation") + + app.send_apdu("800f8100eb030000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c63966303966323935326433343532386337333366393436313563666333396263353535363139666335353064643461363762613232303863653865383637616133643133613665663939646662653332633639373461613961323135306432316563613239633333343965353963313362393038316631") + + app.review.tap() + app.assert_screen("operation_0_sr_outbox") + + app.review.tap() + app.assert_screen("operation_fee_0.01") + + app.review.tap() + app.assert_screen("operation_storage_limit_4") + + app.review.tap() + app.assert_screen("operation_rollup_sr163L...v57") + + app.review.tap() + app.assert_screen("operation_commitment_src12UJ...LY8") + + app.review.tap() + app.expect_apdu_failure("9002") + app.assert_screen(SCREEN_HOME_DEFAULT) app.welcome.quit()