1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 17:38:39 +00:00

implement ApplySetttings.use_passphrase

This commit is contained in:
Pavol Rusnak 2014-12-13 19:29:27 +01:00
parent 7e27275ec8
commit 961566c9b7
6 changed files with 45 additions and 16 deletions

View File

@ -441,23 +441,34 @@ void fsm_msgClearSession(ClearSession *msg)
void fsm_msgApplySettings(ApplySettings *msg)
{
if (msg->has_label && msg->has_language) {
layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "change label to", msg->label, "and language to", msg->language, "?");
} else
if (msg->has_label) {
layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "change label to", msg->label, "?", NULL, NULL);
} else
if (msg->has_language) {
layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "change language to", msg->language, "?", NULL, NULL);
} else {
fsm_sendFailure(FailureType_Failure_SyntaxError, "No setting provided");
return;
}
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, "Apply settings cancelled");
layoutHome();
return;
}
}
if (msg->has_language) {
layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "change language to", msg->language, "?", NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, "Apply settings cancelled");
layoutHome();
return;
}
}
if (msg->has_use_passphrase) {
layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", msg->use_passphrase ? "enable passphrase" : "disable passphrase", "protection?", NULL, NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, "Apply settings cancelled");
layoutHome();
return;
}
}
if (!msg->has_label && !msg->has_language && !msg->has_use_passphrase) {
fsm_sendFailure(FailureType_Failure_SyntaxError, "No setting provided");
return;
}
if (!protectPin(true)) {
layoutHome();
return;
@ -468,6 +479,9 @@ void fsm_msgApplySettings(ApplySettings *msg)
if (msg->has_language) {
storage_setLanguage(msg->language);
}
if (msg->has_use_passphrase) {
storage_setPassphraseProtection(msg->use_passphrase);
}
storage_commit();
fsm_sendSuccess("Settings applied");
layoutHome();

View File

@ -46,9 +46,10 @@ const pb_field_t ClearSession_fields[1] = {
PB_LAST_FIELD
};
const pb_field_t ApplySettings_fields[3] = {
const pb_field_t ApplySettings_fields[4] = {
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, ApplySettings, language, language, 0),
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, ApplySettings, label, language, 0),
PB_FIELD( 3, BOOL , OPTIONAL, STATIC , OTHER, ApplySettings, use_passphrase, label, 0),
PB_LAST_FIELD
};

View File

@ -123,6 +123,8 @@ typedef struct _ApplySettings {
char language[17];
bool has_label;
char label[33];
bool has_use_passphrase;
bool use_passphrase;
} ApplySettings;
typedef struct _ButtonRequest {
@ -520,7 +522,7 @@ extern const char SimpleSignTx_coin_name_default[17];
#define Initialize_init_default {0}
#define Features_init_default {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, "", false, "", 0, {CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default}, false, 0, false, {0, {0}}, false, {0, {0}}, false, 0}
#define ClearSession_init_default {0}
#define ApplySettings_init_default {false, "", false, ""}
#define ApplySettings_init_default {false, "", false, "", false, 0}
#define ChangePin_init_default {false, 0}
#define Ping_init_default {false, "", false, 0, false, 0, false, 0}
#define Success_init_default {false, ""}
@ -571,7 +573,7 @@ extern const char SimpleSignTx_coin_name_default[17];
#define Initialize_init_zero {0}
#define Features_init_zero {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, "", false, "", 0, {CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero}, false, 0, false, {0, {0}}, false, {0, {0}}, false, 0}
#define ClearSession_init_zero {0}
#define ApplySettings_init_zero {false, "", false, ""}
#define ApplySettings_init_zero {false, "", false, "", false, 0}
#define ChangePin_init_zero {false, 0}
#define Ping_init_zero {false, "", false, 0, false, 0, false, 0}
#define Success_init_zero {false, ""}
@ -624,6 +626,7 @@ extern const char SimpleSignTx_coin_name_default[17];
#define Address_address_tag 1
#define ApplySettings_language_tag 1
#define ApplySettings_label_tag 2
#define ApplySettings_use_passphrase_tag 3
#define ButtonRequest_code_tag 1
#define ButtonRequest_data_tag 2
#define ChangePin_remove_tag 1
@ -746,7 +749,7 @@ extern const char SimpleSignTx_coin_name_default[17];
extern const pb_field_t Initialize_fields[1];
extern const pb_field_t Features_fields[16];
extern const pb_field_t ClearSession_fields[1];
extern const pb_field_t ApplySettings_fields[3];
extern const pb_field_t ApplySettings_fields[4];
extern const pb_field_t ChangePin_fields[2];
extern const pb_field_t Ping_fields[5];
extern const pb_field_t Success_fields[2];
@ -799,7 +802,7 @@ extern const pb_field_t DebugLinkLog_fields[4];
#define Initialize_size 0
#define Features_size (230 + 5*CoinType_size)
#define ClearSession_size 0
#define ApplySettings_size 54
#define ApplySettings_size 56
#define ChangePin_size 2
#define Ping_size 265
#define Success_size 259

View File

@ -205,6 +205,15 @@ void storage_setLanguage(const char *lang)
}
}
void storage_setPassphraseProtection(bool passphrase_protection)
{
sessionRootNodeCached = false;
sessionPassphraseCached = false;
storage.has_passphrase_protection = true;
storage.passphrase_protection = passphrase_protection;
}
void get_root_node_callback(uint32_t iter, uint32_t total)
{
static uint8_t i;

View File

@ -41,6 +41,8 @@ void storage_setLabel(const char *label);
const char *storage_getLanguage(void);
void storage_setLanguage(const char *lang);
void storage_setPassphraseProtection(bool passphrase_protection);
void session_cachePassphrase(const char *passphrase);
bool session_isPassphraseCached(void);

@ -1 +1 @@
Subproject commit 437eff319f0673aae9f3416bd771d52dcc983e37
Subproject commit 40b3cb414864f970d627651f8be0669be95c5efc