diff --git a/app/ui/view_nano.c b/app/ui/view_nano.c index fec2c83..211f60c 100644 --- a/app/ui/view_nano.c +++ b/app/ui/view_nano.c @@ -45,7 +45,7 @@ uint8_t getIntroPages() { } #endif #ifdef APP_BLINDSIGN_MODE_ENABLED - if (!app_mode_blindsign()) { + if (!app_mode_blindsign() || !app_mode_blindsign_required()) { return 0; } #endif @@ -183,7 +183,7 @@ zxerr_t h_review_update_data() { snprintf(viewdata.value, MAX_CHARS_PER_VALUE1_LINE, "Ok"); } else { #if defined(APP_BLINDSIGN_MODE_ENABLED) - if (app_mode_blindsign()) { + if (app_mode_blindsign() && app_mode_blindsign_required()) { snprintf(viewdata.value, MAX_CHARS_PER_VALUE1_LINE, "%s %s", APPROVE_LABEL_1, APPROVE_LABEL_2); } else { snprintf(viewdata.value, MAX_CHARS_PER_VALUE1_LINE, "%s", APPROVE_LABEL); @@ -248,7 +248,7 @@ zxerr_t h_review_update_data() { intro_key = PIC(shortcut_key); intro_value = PIC(shortcut_value); #elif defined(APP_BLINDSIGN_MODE_ENABLED) - if (app_mode_blindsign()) { + if (app_mode_blindsign() && app_mode_blindsign_required()) { switch (viewdata.itemIdx) { case 0: intro_key = PIC(review_skip_key); diff --git a/app/ui/view_nbgl.c b/app/ui/view_nbgl.c index 2123bc2..f4cf31d 100644 --- a/app/ui/view_nbgl.c +++ b/app/ui/view_nbgl.c @@ -168,10 +168,8 @@ void view_custom_error_show(const char *upper, const char *lower) { } void view_blindsign_error_show() { - nbgl_useCaseChoice(&C_Warning_64px, - "This message cannot\nbe clear-signed", - "Enable blind-signing in\nthe settings to sign\nthis transaction.", - "Exit", "", confirm_error); + nbgl_useCaseChoice(&C_Warning_64px, "This message cannot\nbe clear-signed", + "Enable blind-signing in\nthe settings to sign\nthis transaction.", "Exit", "", confirm_error); } void view_error_show_impl() { @@ -306,7 +304,7 @@ static void settings_screen_callback(uint8_t index, nbgl_content_t *content) { switches[ACCOUNT_MODE].subText = ""; switches[ACCOUNT_MODE].tuneId = TUNE_TAP_CASUAL; switches[ACCOUNT_MODE].token = ACCOUNT_MODE_TOKEN; - } + } #endif #ifdef APP_SECRET_MODE_ENABLED @@ -347,7 +345,8 @@ void view_idle_show_impl(__Z_UNUSED uint8_t item_idx, const char *statusString) infoList.infoContents = INFO_VALUES_PAGE; infoList.infoTypes = INFO_KEYS_PAGE; - nbgl_useCaseHomeAndSettings(MENU_MAIN_APP_LINE1, &C_icon_stax_64, home_text, INIT_HOME_PAGE, &settingContents, &infoList, NULL, app_quit); + nbgl_useCaseHomeAndSettings(MENU_MAIN_APP_LINE1, &C_icon_stax_64, home_text, INIT_HOME_PAGE, &settingContents, + &infoList, NULL, app_quit); } void view_message_impl(const char *title, const char *message) { @@ -441,14 +440,15 @@ static void config_useCaseReview(nbgl_operationType_t type) { pairList.pairs = NULL; // to indicate that callback should be used pairList.callback = update_item_callback; pairList.startIndex = 0; - if (app_mode_blindsign()) { - nbgl_useCaseReviewBlindSigning(type, &pairList, &C_icon_stax_64, (intro_message == NULL ? "Review transaction" : intro_message), NULL, - "Accept risk and sign transaction ?", NULL, reviewTransactionChoice); + if (app_mode_blindsign() && app_mode_blindsign_required()) { + nbgl_useCaseReviewBlindSigning(type, &pairList, &C_icon_stax_64, + (intro_message == NULL ? "Review transaction" : intro_message), NULL, + "Accept risk and sign transaction ?", NULL, reviewTransactionChoice); } else { - nbgl_useCaseReview(type, &pairList, &C_icon_stax_64, (intro_message == NULL ? "Review transaction" : intro_message), - NULL, APPROVE_LABEL_NBGL, reviewTransactionChoice); + nbgl_useCaseReview(type, &pairList, &C_icon_stax_64, + (intro_message == NULL ? "Review transaction" : intro_message), NULL, APPROVE_LABEL_NBGL, + reviewTransactionChoice); } - } static void config_useCaseReviewLight(const char *title, const char *validate) { diff --git a/app/ui/view_x.c b/app/ui/view_x.c index 38b2170..04beac4 100644 --- a/app/ui/view_x.c +++ b/app/ui/view_x.c @@ -531,7 +531,7 @@ void run_ux_review_flow(review_type_e reviewType, const ux_flow_step_t *const st case REVIEW_TXN: default: #ifdef APP_BLINDSIGN_MODE_ENABLED - if (app_mode_blindsign()) { + if (app_mode_blindsign() && app_mode_blindsign_required()) { ux_review_flow[index++] = &ux_approval_blind_signing_warning_step; ux_review_flow[index++] = &ux_approval_blind_signing_message_step; } @@ -550,7 +550,7 @@ void run_ux_review_flow(review_type_e reviewType, const ux_flow_step_t *const st ux_review_flow[index++] = &ux_review_flow_6_step; } else { #ifdef APP_BLINDSIGN_MODE_ENABLED - if (app_mode_blindsign()) { + if (app_mode_blindsign() && app_mode_blindsign_required()) { ux_review_flow[index++] = &ux_review_flow_3_step_blindsign; } else { ux_review_flow[index++] = &ux_review_flow_3_step; diff --git a/include/app_mode.h b/include/app_mode.h index 4ea4b54..b2a0df5 100644 --- a/include/app_mode.h +++ b/include/app_mode.h @@ -1,22 +1,22 @@ /******************************************************************************* -* (c) 2016 Ledger -* (c) 2018 Zondax GmbH -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -********************************************************************************/ + * (c) 2016 Ledger + * (c) 2018 Zondax GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ********************************************************************************/ #pragma once -#include "zxmacros.h" #include "stdbool.h" +#include "zxmacros.h" #ifdef __cplusplus extern "C" { @@ -44,6 +44,9 @@ bool app_mode_blindsign(); void app_mode_set_blindsign(uint8_t val); +bool app_mode_blindsign_required(); + +void app_mode_set_blindsign_required(uint8_t val); #ifdef __cplusplus } #endif diff --git a/include/zxversion.h b/include/zxversion.h index 00e9a4e..f5ce999 100644 --- a/include/zxversion.h +++ b/include/zxversion.h @@ -17,4 +17,4 @@ #define ZXLIB_MAJOR 29 #define ZXLIB_MINOR 5 -#define ZXLIB_PATCH 1 +#define ZXLIB_PATCH 2 diff --git a/src/app_mode.c b/src/app_mode.c index e996964..7fd8724 100644 --- a/src/app_mode.c +++ b/src/app_mode.c @@ -20,6 +20,7 @@ typedef struct { uint8_t expert; uint8_t account; uint8_t blindsign; + uint8_t blindsign_required; } app_mode_persistent_t; typedef struct { @@ -52,6 +53,7 @@ void app_mode_set_expert(uint8_t val) { mode.expert = val; mode.account = N_appmode.account; mode.blindsign = N_appmode.blindsign; + mode.blindsign_required = N_appmode.blindsign_required; MEMCPY_NV((void *)PIC(&N_appmode_impl), (void *)&mode, sizeof(app_mode_persistent_t)); } @@ -60,6 +62,7 @@ void app_mode_set_account(uint8_t val) { mode.expert = N_appmode.expert; mode.account = val; mode.blindsign = N_appmode.blindsign; + mode.blindsign_required = N_appmode.blindsign_required; MEMCPY_NV((void *)PIC(&N_appmode_impl), (void *)&mode, sizeof(app_mode_persistent_t)); } @@ -70,9 +73,20 @@ void app_mode_set_blindsign(uint8_t val) { mode.expert = N_appmode.expert; mode.account = N_appmode.account; mode.blindsign = val; + mode.blindsign_required = N_appmode.blindsign_required; MEMCPY_NV((void *)PIC(&N_appmode_impl), (void *)&mode, sizeof(app_mode_persistent_t)); } +bool app_mode_blindsign_required() { return N_appmode.blindsign_required; } + +void app_mode_set_blindsign_required(uint8_t val) { + app_mode_persistent_t mode; + mode.expert = N_appmode.expert; + mode.account = N_appmode.account; + mode.blindsign = N_appmode.blindsign; + mode.blindsign_required = val; + MEMCPY_NV((void *)PIC(&N_appmode_impl), (void *)&mode, sizeof(app_mode_persistent_t)); +} #else ////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////// @@ -85,6 +99,7 @@ void app_mode_reset() { app_mode.expert = 0; app_mode.account = 0; app_mode.blindsign = 0; + app_mode.blindsign_required = 0; app_mode_temporary.secret = 0; app_mode_temporary.shortcut = 0; } @@ -101,6 +116,10 @@ bool app_mode_blindsign() { return app_mode.blindsign; } void app_mode_set_blindsign(uint8_t val) { app_mode.blindsign = val; } +bool app_mode_blindsign_required() { return app_mode.blindsign_required; } + +void app_mode_set_blindsign_required(uint8_t val) { app_mode.blindsign_required = val; } + ////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////