mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 14:38:36 -07:00
@@ -11,7 +11,7 @@
|
||||
struct TotpAddContext {
|
||||
FuriString* args;
|
||||
Cli* cli;
|
||||
uint8_t* iv;
|
||||
const CryptoSettings* crypto_settings;
|
||||
};
|
||||
|
||||
enum TotpIteratorUpdateTokenResultsEx {
|
||||
@@ -54,7 +54,7 @@ static TotpIteratorUpdateTokenResult
|
||||
|
||||
// Reading token secret
|
||||
furi_string_reset(temp_str);
|
||||
TOTP_CLI_PRINTF("Enter token secret and confirm with [ENTER]\r\n");
|
||||
TOTP_CLI_PRINTF("Enter token secret and confirm with [ENTER]:\r\n");
|
||||
if(!totp_cli_read_line(context_t->cli, temp_str, mask_user_input)) {
|
||||
totp_cli_delete_last_line();
|
||||
furi_string_secure_free(temp_str);
|
||||
@@ -68,7 +68,7 @@ static TotpIteratorUpdateTokenResult
|
||||
furi_string_get_cstr(temp_str),
|
||||
furi_string_size(temp_str),
|
||||
token_secret_encoding,
|
||||
context_t->iv);
|
||||
context_t->crypto_settings);
|
||||
|
||||
furi_string_secure_free(temp_str);
|
||||
|
||||
@@ -166,7 +166,8 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl
|
||||
|
||||
TOTP_CLI_LOCK_UI(plugin_state);
|
||||
|
||||
struct TotpAddContext add_context = {.args = args, .cli = cli, .iv = &plugin_state->iv[0]};
|
||||
struct TotpAddContext add_context = {
|
||||
.args = args, .cli = cli, .crypto_settings = &plugin_state->crypto_settings};
|
||||
TotpIteratorUpdateTokenResult add_result =
|
||||
totp_token_info_iterator_add_new_token(iterator_context, &add_token_handler, &add_context);
|
||||
|
||||
|
||||
@@ -7,17 +7,23 @@
|
||||
#define TOTP_CLI_COMMAND_AUTOMATION_ARG_METHOD "automation"
|
||||
#define TOTP_CLI_COMMAND_AUTOMATION_METHOD_NONE "none"
|
||||
#define TOTP_CLI_COMMAND_AUTOMATION_METHOD_USB "usb"
|
||||
#ifdef TOTP_BADBT_TYPE_ENABLED
|
||||
#ifdef TOTP_BADBT_AUTOMATION_ENABLED
|
||||
#define TOTP_CLI_COMMAND_AUTOMATION_METHOD_BT "bt"
|
||||
#endif
|
||||
#define TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_QWERTY "QWERTY"
|
||||
#define TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_AZERTY "AZERTY"
|
||||
#define TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT_PREFIX "-k"
|
||||
#define TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT "layout"
|
||||
|
||||
void totp_cli_command_automation_docopt_commands() {
|
||||
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_AUTOMATION " Get or set automation method\r\n");
|
||||
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_AUTOMATION " Get or set automation settings\r\n");
|
||||
}
|
||||
|
||||
void totp_cli_command_automation_docopt_usage() {
|
||||
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " TOTP_CLI_COMMAND_AUTOMATION " " DOCOPT_OPTIONAL(
|
||||
DOCOPT_MULTIPLE(DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_AUTOMATION_ARG_METHOD))) "\r\n");
|
||||
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " TOTP_CLI_COMMAND_AUTOMATION " " DOCOPT_OPTIONAL(DOCOPT_OPTION(
|
||||
TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT_PREFIX,
|
||||
DOCOPT_ARGUMENT(
|
||||
TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT))) " " DOCOPT_OPTIONAL(DOCOPT_MULTIPLE(DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_AUTOMATION_ARG_METHOD))) "\r\n");
|
||||
}
|
||||
|
||||
void totp_cli_command_automation_docopt_arguments() {
|
||||
@@ -25,24 +31,33 @@ void totp_cli_command_automation_docopt_arguments() {
|
||||
" " TOTP_CLI_COMMAND_AUTOMATION_ARG_METHOD
|
||||
" Automation method to be set. Must be one of: " TOTP_CLI_COMMAND_AUTOMATION_METHOD_NONE
|
||||
", " TOTP_CLI_COMMAND_AUTOMATION_METHOD_USB
|
||||
#ifdef TOTP_BADBT_TYPE_ENABLED
|
||||
#ifdef TOTP_BADBT_AUTOMATION_ENABLED
|
||||
", " TOTP_CLI_COMMAND_AUTOMATION_METHOD_BT
|
||||
#endif
|
||||
"\r\n");
|
||||
}
|
||||
|
||||
static void totp_cli_command_automation_print_method(AutomationMethod method, const char* color) {
|
||||
#ifdef TOTP_BADBT_TYPE_ENABLED
|
||||
void totp_cli_command_automation_docopt_options() {
|
||||
TOTP_CLI_PRINTF(" " DOCOPT_OPTION(
|
||||
TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT_PREFIX,
|
||||
DOCOPT_ARGUMENT(
|
||||
TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT)) " Automation keyboard layout. Must be one of: " TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_QWERTY
|
||||
", " TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_AZERTY
|
||||
"\r\n");
|
||||
}
|
||||
|
||||
static void print_method(AutomationMethod method, const char* color) {
|
||||
#ifdef TOTP_BADBT_AUTOMATION_ENABLED
|
||||
bool has_previous_method = false;
|
||||
#endif
|
||||
if(method & AutomationMethodBadUsb) {
|
||||
TOTP_CLI_PRINTF_COLORFUL(color, "\"" TOTP_CLI_COMMAND_AUTOMATION_METHOD_USB "\"");
|
||||
#ifdef TOTP_BADBT_TYPE_ENABLED
|
||||
#ifdef TOTP_BADBT_AUTOMATION_ENABLED
|
||||
has_previous_method = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TOTP_BADBT_TYPE_ENABLED
|
||||
#ifdef TOTP_BADBT_AUTOMATION_ENABLED
|
||||
if(method & AutomationMethodBadBt) {
|
||||
if(has_previous_method) {
|
||||
TOTP_CLI_PRINTF_COLORFUL(color, " and ");
|
||||
@@ -57,6 +72,37 @@ static void totp_cli_command_automation_print_method(AutomationMethod method, co
|
||||
}
|
||||
}
|
||||
|
||||
static void print_kb_layout(AutomationKeyboardLayout layout, const char* color) {
|
||||
char* layoutToPrint;
|
||||
switch(layout) {
|
||||
case AutomationKeyboardLayoutQWERTY:
|
||||
layoutToPrint = TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_QWERTY;
|
||||
break;
|
||||
case AutomationKeyboardLayoutAZERTY:
|
||||
layoutToPrint = TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_AZERTY;
|
||||
break;
|
||||
default:
|
||||
furi_crash("Unknown automation keyboard layout");
|
||||
break;
|
||||
}
|
||||
|
||||
TOTP_CLI_PRINTF_COLORFUL(color, "%s", layoutToPrint);
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_automation_keyboard_layout(const FuriString* str, AutomationKeyboardLayout* out) {
|
||||
bool result = true;
|
||||
if(furi_string_cmpi_str(str, TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_QWERTY) == 0) {
|
||||
*out = AutomationKeyboardLayoutQWERTY;
|
||||
} else if(furi_string_cmpi_str(str, TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_AZERTY) == 0) {
|
||||
*out = AutomationKeyboardLayoutAZERTY;
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void totp_cli_command_automation_handle(PluginState* plugin_state, FuriString* args, Cli* cli) {
|
||||
if(!totp_cli_ensure_authenticated(plugin_state, cli)) {
|
||||
return;
|
||||
@@ -65,6 +111,7 @@ void totp_cli_command_automation_handle(PluginState* plugin_state, FuriString* a
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
bool new_method_provided = false;
|
||||
AutomationMethod new_method = AutomationMethodNone;
|
||||
AutomationKeyboardLayout new_kb_layout = plugin_state->automation_kb_layout;
|
||||
bool args_valid = true;
|
||||
while(args_read_string_and_trim(args, temp_str)) {
|
||||
if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_AUTOMATION_METHOD_NONE) == 0) {
|
||||
@@ -74,13 +121,19 @@ void totp_cli_command_automation_handle(PluginState* plugin_state, FuriString* a
|
||||
new_method_provided = true;
|
||||
new_method |= AutomationMethodBadUsb;
|
||||
}
|
||||
#ifdef TOTP_BADBT_TYPE_ENABLED
|
||||
#ifdef TOTP_BADBT_AUTOMATION_ENABLED
|
||||
else if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_AUTOMATION_METHOD_BT) == 0) {
|
||||
new_method_provided = true;
|
||||
new_method |= AutomationMethodBadBt;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
else if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT_PREFIX) == 0) {
|
||||
if(!args_read_string_and_trim(args, temp_str) ||
|
||||
!parse_automation_keyboard_layout(temp_str, &new_kb_layout)) {
|
||||
args_valid = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
args_valid = false;
|
||||
break;
|
||||
}
|
||||
@@ -96,15 +149,19 @@ void totp_cli_command_automation_handle(PluginState* plugin_state, FuriString* a
|
||||
TOTP_CLI_LOCK_UI(plugin_state);
|
||||
|
||||
plugin_state->automation_method = new_method;
|
||||
plugin_state->automation_kb_layout = new_kb_layout;
|
||||
if(totp_config_file_update_automation_method(plugin_state)) {
|
||||
TOTP_CLI_PRINTF_SUCCESS("Automation method is set to ");
|
||||
totp_cli_command_automation_print_method(new_method, TOTP_CLI_COLOR_SUCCESS);
|
||||
print_method(new_method, TOTP_CLI_COLOR_SUCCESS);
|
||||
TOTP_CLI_PRINTF_SUCCESS(" (");
|
||||
print_kb_layout(plugin_state->automation_kb_layout, TOTP_CLI_COLOR_SUCCESS);
|
||||
TOTP_CLI_PRINTF_SUCCESS(")");
|
||||
cli_nl();
|
||||
} else {
|
||||
totp_cli_print_error_updating_config_file();
|
||||
}
|
||||
|
||||
#ifdef TOTP_BADBT_TYPE_ENABLED
|
||||
#ifdef TOTP_BADBT_AUTOMATION_ENABLED
|
||||
if(!(new_method & AutomationMethodBadBt) &&
|
||||
plugin_state->bt_type_code_worker_context != NULL) {
|
||||
totp_bt_type_code_worker_free(plugin_state->bt_type_code_worker_context);
|
||||
@@ -115,8 +172,10 @@ void totp_cli_command_automation_handle(PluginState* plugin_state, FuriString* a
|
||||
TOTP_CLI_UNLOCK_UI(plugin_state);
|
||||
} else {
|
||||
TOTP_CLI_PRINTF_INFO("Current automation method is ");
|
||||
totp_cli_command_automation_print_method(
|
||||
plugin_state->automation_method, TOTP_CLI_COLOR_INFO);
|
||||
print_method(plugin_state->automation_method, TOTP_CLI_COLOR_INFO);
|
||||
TOTP_CLI_PRINTF_INFO(" (");
|
||||
print_kb_layout(plugin_state->automation_kb_layout, TOTP_CLI_COLOR_INFO);
|
||||
TOTP_CLI_PRINTF_INFO(")");
|
||||
cli_nl();
|
||||
}
|
||||
} while(false);
|
||||
|
||||
@@ -8,4 +8,5 @@
|
||||
void totp_cli_command_automation_handle(PluginState* plugin_state, FuriString* args, Cli* cli);
|
||||
void totp_cli_command_automation_docopt_commands();
|
||||
void totp_cli_command_automation_docopt_usage();
|
||||
void totp_cli_command_automation_docopt_arguments();
|
||||
void totp_cli_command_automation_docopt_arguments();
|
||||
void totp_cli_command_automation_docopt_options();
|
||||
@@ -64,4 +64,6 @@ void totp_cli_command_help_handle() {
|
||||
totp_cli_command_add_docopt_options();
|
||||
totp_cli_command_update_docopt_options();
|
||||
totp_cli_command_delete_docopt_options();
|
||||
totp_cli_command_pin_docopt_options();
|
||||
totp_cli_command_automation_docopt_options();
|
||||
}
|
||||
@@ -7,19 +7,35 @@
|
||||
#include "../../../services/config/config.h"
|
||||
#include "../../cli_helpers.h"
|
||||
#include <memset_s.h>
|
||||
#include "../../../services/crypto/crypto.h"
|
||||
#include "../../../services/crypto/crypto_facade.h"
|
||||
#include "../../../ui/scene_director.h"
|
||||
|
||||
#define TOTP_CLI_COMMAND_PIN_COMMAND_SET "set"
|
||||
#define TOTP_CLI_COMMAND_PIN_COMMAND_REMOVE "remove"
|
||||
#define TOTP_CLI_COMMAND_PIN_ARG_NEW_CRYPTO_KEY_SLOT_PREFIX "-c"
|
||||
#define TOTP_CLI_COMMAND_PIN_ARG_NEW_CRYPTO_KEY_SLOT "slot"
|
||||
|
||||
void totp_cli_command_pin_docopt_commands() {
|
||||
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_PIN " Set\\change\\remove PIN\r\n");
|
||||
}
|
||||
|
||||
void totp_cli_command_pin_docopt_usage() {
|
||||
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " TOTP_CLI_COMMAND_PIN " " DOCOPT_REQUIRED(
|
||||
TOTP_CLI_COMMAND_PIN_COMMAND_SET " | " TOTP_CLI_COMMAND_PIN_COMMAND_REMOVE) "\r\n");
|
||||
TOTP_CLI_PRINTF(
|
||||
" " TOTP_CLI_COMMAND_NAME " " TOTP_CLI_COMMAND_PIN
|
||||
" " DOCOPT_REQUIRED(TOTP_CLI_COMMAND_PIN_COMMAND_SET " | " TOTP_CLI_COMMAND_PIN_COMMAND_REMOVE) " " DOCOPT_OPTIONAL(
|
||||
DOCOPT_OPTION(
|
||||
TOTP_CLI_COMMAND_PIN_ARG_NEW_CRYPTO_KEY_SLOT_PREFIX,
|
||||
DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_PIN_ARG_NEW_CRYPTO_KEY_SLOT))) "\r\n");
|
||||
}
|
||||
|
||||
void totp_cli_command_pin_docopt_options() {
|
||||
TOTP_CLI_PRINTF(
|
||||
" " DOCOPT_OPTION(
|
||||
TOTP_CLI_COMMAND_PIN_ARG_NEW_CRYPTO_KEY_SLOT_PREFIX,
|
||||
DOCOPT_ARGUMENT(
|
||||
TOTP_CLI_COMMAND_PIN_ARG_NEW_CRYPTO_KEY_SLOT)) " New crypto key slot. Must be between %d and %d\r\n",
|
||||
ACCEPTABLE_CRYPTO_KEY_SLOT_START,
|
||||
ACCEPTABLE_CRYPTO_KEY_SLOT_END);
|
||||
}
|
||||
|
||||
static inline uint8_t totp_cli_key_to_pin_code(uint8_t key) {
|
||||
@@ -89,35 +105,49 @@ void totp_cli_command_pin_handle(PluginState* plugin_state, FuriString* args, Cl
|
||||
|
||||
bool do_change = false;
|
||||
bool do_remove = false;
|
||||
UNUSED(do_remove);
|
||||
if(args_read_string_and_trim(args, temp_str)) {
|
||||
uint8_t crypto_key_slot = plugin_state->crypto_settings.crypto_key_slot;
|
||||
|
||||
bool arguments_parsed = true;
|
||||
while(args_read_string_and_trim(args, temp_str)) {
|
||||
if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_PIN_COMMAND_SET) == 0) {
|
||||
do_change = true;
|
||||
} else if(furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_PIN_COMMAND_REMOVE) == 0) {
|
||||
do_remove = true;
|
||||
} else if(
|
||||
furi_string_cmpi_str(temp_str, TOTP_CLI_COMMAND_PIN_ARG_NEW_CRYPTO_KEY_SLOT_PREFIX) ==
|
||||
0) {
|
||||
if(!args_read_uint8_and_trim(args, &crypto_key_slot) ||
|
||||
!totp_crypto_check_key_slot(crypto_key_slot)) {
|
||||
TOTP_CLI_PRINTF_ERROR("Slot \"%" PRIu8 "\" can not be used\r\n", crypto_key_slot);
|
||||
arguments_parsed = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
totp_cli_print_invalid_arguments();
|
||||
arguments_parsed = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
totp_cli_print_invalid_arguments();
|
||||
}
|
||||
|
||||
if((do_change || do_remove) && totp_cli_ensure_authenticated(plugin_state, cli)) {
|
||||
if(!(do_change || do_remove) || (do_change && do_remove)) {
|
||||
totp_cli_print_invalid_arguments();
|
||||
arguments_parsed = false;
|
||||
}
|
||||
|
||||
if(arguments_parsed && totp_cli_ensure_authenticated(plugin_state, cli)) {
|
||||
TOTP_CLI_LOCK_UI(plugin_state);
|
||||
do {
|
||||
uint8_t old_iv[TOTP_IV_SIZE];
|
||||
memcpy(&old_iv[0], &plugin_state->iv[0], TOTP_IV_SIZE);
|
||||
uint8_t new_pin[TOTP_IV_SIZE];
|
||||
memset(&new_pin[0], 0, TOTP_IV_SIZE);
|
||||
uint8_t new_pin[CRYPTO_IV_LENGTH];
|
||||
memset(&new_pin[0], 0, CRYPTO_IV_LENGTH);
|
||||
uint8_t new_pin_length = 0;
|
||||
if(do_change) {
|
||||
if(!totp_cli_read_pin(cli, &new_pin[0], &new_pin_length)) {
|
||||
memset_s(&new_pin[0], TOTP_IV_SIZE, 0, TOTP_IV_SIZE);
|
||||
memset_s(&new_pin[0], CRYPTO_IV_LENGTH, 0, CRYPTO_IV_LENGTH);
|
||||
break;
|
||||
}
|
||||
} else if(do_remove) {
|
||||
new_pin_length = 0;
|
||||
memset(&new_pin[0], 0, TOTP_IV_SIZE);
|
||||
memset(&new_pin[0], 0, CRYPTO_IV_LENGTH);
|
||||
}
|
||||
|
||||
char* backup_path = totp_config_file_backup(plugin_state);
|
||||
@@ -127,7 +157,7 @@ void totp_cli_command_pin_handle(PluginState* plugin_state, FuriString* args, Cl
|
||||
"Once you make sure everything is fine and works as expected, please delete this backup file\r\n");
|
||||
free(backup_path);
|
||||
} else {
|
||||
memset_s(&new_pin[0], TOTP_IV_SIZE, 0, TOTP_IV_SIZE);
|
||||
memset_s(&new_pin[0], CRYPTO_IV_LENGTH, 0, CRYPTO_IV_LENGTH);
|
||||
TOTP_CLI_PRINTF_ERROR(
|
||||
"An error has occurred during taking backup of config file\r\n");
|
||||
break;
|
||||
@@ -135,10 +165,10 @@ void totp_cli_command_pin_handle(PluginState* plugin_state, FuriString* args, Cl
|
||||
|
||||
TOTP_CLI_PRINTF("Encrypting...\r\n");
|
||||
|
||||
bool update_result =
|
||||
totp_config_file_update_encryption(plugin_state, new_pin, new_pin_length);
|
||||
bool update_result = totp_config_file_update_encryption(
|
||||
plugin_state, crypto_key_slot, new_pin, new_pin_length);
|
||||
|
||||
memset_s(&new_pin[0], TOTP_IV_SIZE, 0, TOTP_IV_SIZE);
|
||||
memset_s(&new_pin[0], CRYPTO_IV_LENGTH, 0, CRYPTO_IV_LENGTH);
|
||||
|
||||
totp_cli_delete_last_line();
|
||||
|
||||
|
||||
@@ -7,4 +7,5 @@
|
||||
|
||||
void totp_cli_command_pin_handle(PluginState* plugin_state, FuriString* args, Cli* cli);
|
||||
void totp_cli_command_pin_docopt_commands();
|
||||
void totp_cli_command_pin_docopt_usage();
|
||||
void totp_cli_command_pin_docopt_usage();
|
||||
void totp_cli_command_pin_docopt_options();
|
||||
@@ -17,10 +17,7 @@ void totp_cli_command_reset_docopt_usage() {
|
||||
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " TOTP_CLI_COMMAND_RESET "\r\n");
|
||||
}
|
||||
|
||||
void totp_cli_command_reset_handle(
|
||||
PluginState* plugin_state,
|
||||
Cli* cli,
|
||||
FuriMessageQueue* event_queue) {
|
||||
void totp_cli_command_reset_handle(PluginState* plugin_state, Cli* cli) {
|
||||
TOTP_CLI_LOCK_UI(plugin_state);
|
||||
TOTP_CLI_PRINTF_WARNING(
|
||||
"As a result of reset all the settings and tokens will be permanently lost.\r\n");
|
||||
@@ -35,7 +32,7 @@ void totp_cli_command_reset_handle(
|
||||
totp_config_file_reset(plugin_state);
|
||||
TOTP_CLI_PRINTF_SUCCESS("Application has been successfully reset to default.\r\n");
|
||||
TOTP_CLI_PRINTF_SUCCESS("Now application will be closed to apply all the changes.\r\n");
|
||||
totp_cli_force_close_app(event_queue);
|
||||
totp_cli_force_close_app(plugin_state->event_queue);
|
||||
} else {
|
||||
TOTP_CLI_PRINTF_INFO("Action was not confirmed by user\r\n");
|
||||
TOTP_CLI_UNLOCK_UI(plugin_state);
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
|
||||
#define TOTP_CLI_COMMAND_RESET "reset"
|
||||
|
||||
void totp_cli_command_reset_handle(
|
||||
PluginState* plugin_state,
|
||||
Cli* cli,
|
||||
FuriMessageQueue* event_queue);
|
||||
void totp_cli_command_reset_handle(PluginState* plugin_state, Cli* cli);
|
||||
void totp_cli_command_reset_docopt_commands();
|
||||
void totp_cli_command_reset_docopt_usage();
|
||||
@@ -13,7 +13,7 @@
|
||||
struct TotpUpdateContext {
|
||||
FuriString* args;
|
||||
Cli* cli;
|
||||
uint8_t* iv;
|
||||
const CryptoSettings* crypto_settings;
|
||||
};
|
||||
|
||||
enum TotpIteratorUpdateTokenResultsEx {
|
||||
@@ -83,7 +83,7 @@ static TotpIteratorUpdateTokenResult
|
||||
if(update_token_secret) {
|
||||
// Reading token secret
|
||||
furi_string_reset(temp_str);
|
||||
TOTP_CLI_PRINTF("Enter token secret and confirm with [ENTER]\r\n");
|
||||
TOTP_CLI_PRINTF("Enter token secret and confirm with [ENTER]:\r\n");
|
||||
bool token_secret_read = totp_cli_read_line(context_t->cli, temp_str, mask_user_input);
|
||||
totp_cli_delete_last_line();
|
||||
if(!token_secret_read) {
|
||||
@@ -96,7 +96,7 @@ static TotpIteratorUpdateTokenResult
|
||||
furi_string_get_cstr(temp_str),
|
||||
furi_string_size(temp_str),
|
||||
token_secret_encoding,
|
||||
context_t->iv)) {
|
||||
context_t->crypto_settings)) {
|
||||
furi_string_secure_free(temp_str);
|
||||
return TotpIteratorUpdateTokenResultInvalidSecret;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ void totp_cli_command_update_handle(PluginState* plugin_state, FuriString* args,
|
||||
totp_token_info_iterator_go_to(iterator_context, token_number - 1);
|
||||
|
||||
struct TotpUpdateContext update_context = {
|
||||
.args = args, .cli = cli, .iv = &plugin_state->iv[0]};
|
||||
.args = args, .cli = cli, .crypto_settings = &plugin_state->crypto_settings};
|
||||
TotpIteratorUpdateTokenResult update_result = totp_token_info_iterator_update_current_token(
|
||||
iterator_context, &update_token_handler, &update_context);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user