فهرست منبع

Fixed SONAR issues (#14)

Alexander Kopachov 3 سال پیش
والد
کامیت
57d83e77c0

+ 3 - 3
scenes/add_new_token/totp_scene_add_new_token.c

@@ -35,12 +35,12 @@ typedef struct {
     InputTextSceneState* input_state;
     InputTextSceneState* input_state;
     uint32_t input_started_at;
     uint32_t input_started_at;
     int16_t current_token_index;
     int16_t current_token_index;
-    int32_t screen_y_offset;
+    int16_t screen_y_offset;
     TokenHashAlgo algo;
     TokenHashAlgo algo;
     TokenDigitsCount digits_count;
     TokenDigitsCount digits_count;
 } SceneState;
 } SceneState;
 
 
-void totp_scene_add_new_token_init(PluginState* plugin_state) {
+void totp_scene_add_new_token_init(const PluginState* plugin_state) {
     UNUSED(plugin_state);
     UNUSED(plugin_state);
 }
 }
 
 
@@ -311,6 +311,6 @@ void totp_scene_add_new_token_deactivate(PluginState* plugin_state) {
     plugin_state->current_scene_state = NULL;
     plugin_state->current_scene_state = NULL;
 }
 }
 
 
-void totp_scene_add_new_token_free(PluginState* plugin_state) {
+void totp_scene_add_new_token_free(const PluginState* plugin_state) {
     UNUSED(plugin_state);
     UNUSED(plugin_state);
 }
 }

+ 2 - 2
scenes/add_new_token/totp_scene_add_new_token.h

@@ -10,11 +10,11 @@ typedef struct {
     uint8_t current_token_index;
     uint8_t current_token_index;
 } TokenAddEditSceneContext;
 } TokenAddEditSceneContext;
 
 
-void totp_scene_add_new_token_init(PluginState* plugin_state);
+void totp_scene_add_new_token_init(const PluginState* plugin_state);
 void totp_scene_add_new_token_activate(
 void totp_scene_add_new_token_activate(
     PluginState* plugin_state,
     PluginState* plugin_state,
     const TokenAddEditSceneContext* context);
     const TokenAddEditSceneContext* context);
 void totp_scene_add_new_token_render(Canvas* const canvas, PluginState* plugin_state);
 void totp_scene_add_new_token_render(Canvas* const canvas, PluginState* plugin_state);
 bool totp_scene_add_new_token_handle_event(PluginEvent* const event, PluginState* plugin_state);
 bool totp_scene_add_new_token_handle_event(PluginEvent* const event, PluginState* plugin_state);
 void totp_scene_add_new_token_deactivate(PluginState* plugin_state);
 void totp_scene_add_new_token_deactivate(PluginState* plugin_state);
-void totp_scene_add_new_token_free(PluginState* plugin_state);
+void totp_scene_add_new_token_free(const PluginState* plugin_state);

+ 4 - 4
scenes/app_settings/totp_app_settings.c

@@ -16,7 +16,7 @@ typedef struct {
     Control selected_control;
     Control selected_control;
 } SceneState;
 } SceneState;
 
 
-void totp_scene_app_settings_init(PluginState* plugin_state) {
+void totp_scene_app_settings_init(const PluginState* plugin_state) {
     UNUSED(plugin_state);
     UNUSED(plugin_state);
 }
 }
 
 
@@ -53,7 +53,7 @@ static void two_digit_to_str(int8_t num, char* str) {
 }
 }
 
 
 void totp_scene_app_settings_render(Canvas* const canvas, PluginState* plugin_state) {
 void totp_scene_app_settings_render(Canvas* const canvas, PluginState* plugin_state) {
-    SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
+    const SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
 
 
     canvas_set_font(canvas, FontPrimary);
     canvas_set_font(canvas, FontPrimary);
     canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, "Timezone offset");
     canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, "Timezone offset");
@@ -90,7 +90,7 @@ void totp_scene_app_settings_render(Canvas* const canvas, PluginState* plugin_st
         scene_state->selected_control == ConfirmButton);
         scene_state->selected_control == ConfirmButton);
 }
 }
 
 
-bool totp_scene_app_settings_handle_event(PluginEvent* const event, PluginState* plugin_state) {
+bool totp_scene_app_settings_handle_event(const PluginEvent* const event, PluginState* plugin_state) {
     if(event->type == EventTypeKey) {
     if(event->type == EventTypeKey) {
         SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
         SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
         if(event->input.type == InputTypePress) {
         if(event->input.type == InputTypePress) {
@@ -171,6 +171,6 @@ void totp_scene_app_settings_deactivate(PluginState* plugin_state) {
     plugin_state->current_scene_state = NULL;
     plugin_state->current_scene_state = NULL;
 }
 }
 
 
-void totp_scene_app_settings_free(PluginState* plugin_state) {
+void totp_scene_app_settings_free(const PluginState* plugin_state) {
     UNUSED(plugin_state);
     UNUSED(plugin_state);
 }
 }

+ 3 - 3
scenes/app_settings/totp_app_settings.h

@@ -10,11 +10,11 @@ typedef struct {
     uint8_t current_token_index;
     uint8_t current_token_index;
 } AppSettingsSceneContext;
 } AppSettingsSceneContext;
 
 
-void totp_scene_app_settings_init(PluginState* plugin_state);
+void totp_scene_app_settings_init(const PluginState* plugin_state);
 void totp_scene_app_settings_activate(
 void totp_scene_app_settings_activate(
     PluginState* plugin_state,
     PluginState* plugin_state,
     const AppSettingsSceneContext* context);
     const AppSettingsSceneContext* context);
 void totp_scene_app_settings_render(Canvas* const canvas, PluginState* plugin_state);
 void totp_scene_app_settings_render(Canvas* const canvas, PluginState* plugin_state);
-bool totp_scene_app_settings_handle_event(PluginEvent* const event, PluginState* plugin_state);
+bool totp_scene_app_settings_handle_event(const PluginEvent* const event, PluginState* plugin_state);
 void totp_scene_app_settings_deactivate(PluginState* plugin_state);
 void totp_scene_app_settings_deactivate(PluginState* plugin_state);
-void totp_scene_app_settings_free(PluginState* plugin_state);
+void totp_scene_app_settings_free(const PluginState* plugin_state);

+ 3 - 3
scenes/authenticate/totp_scene_authenticate.c

@@ -28,7 +28,7 @@ void totp_scene_authenticate_activate(PluginState* plugin_state) {
 }
 }
 
 
 void totp_scene_authenticate_render(Canvas* const canvas, PluginState* plugin_state) {
 void totp_scene_authenticate_render(Canvas* const canvas, PluginState* plugin_state) {
-    SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
+    const SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
 
 
     int v_shift = 0;
     int v_shift = 0;
     if(scene_state->code_length > 0) {
     if(scene_state->code_length > 0) {
@@ -73,7 +73,7 @@ void totp_scene_authenticate_render(Canvas* const canvas, PluginState* plugin_st
     }
     }
 }
 }
 
 
-bool totp_scene_authenticate_handle_event(PluginEvent* const event, PluginState* plugin_state) {
+bool totp_scene_authenticate_handle_event(const PluginEvent* const event, PluginState* plugin_state) {
     if(event->type == EventTypeKey) {
     if(event->type == EventTypeKey) {
         if(event->input.type == InputTypeLong && event->input.key == InputKeyBack) {
         if(event->input.type == InputTypeLong && event->input.key == InputKeyBack) {
             return false;
             return false;
@@ -156,6 +156,6 @@ void totp_scene_authenticate_deactivate(PluginState* plugin_state) {
     plugin_state->current_scene_state = NULL;
     plugin_state->current_scene_state = NULL;
 }
 }
 
 
-void totp_scene_authenticate_free(PluginState* plugin_state) {
+void totp_scene_authenticate_free(const PluginState* plugin_state) {
     UNUSED(plugin_state);
     UNUSED(plugin_state);
 }
 }

+ 2 - 2
scenes/authenticate/totp_scene_authenticate.h

@@ -9,6 +9,6 @@
 void totp_scene_authenticate_init(PluginState* plugin_state);
 void totp_scene_authenticate_init(PluginState* plugin_state);
 void totp_scene_authenticate_activate(PluginState* plugin_state);
 void totp_scene_authenticate_activate(PluginState* plugin_state);
 void totp_scene_authenticate_render(Canvas* const canvas, PluginState* plugin_state);
 void totp_scene_authenticate_render(Canvas* const canvas, PluginState* plugin_state);
-bool totp_scene_authenticate_handle_event(PluginEvent* const event, PluginState* plugin_state);
+bool totp_scene_authenticate_handle_event(const PluginEvent* const event, PluginState* plugin_state);
 void totp_scene_authenticate_deactivate(PluginState* plugin_state);
 void totp_scene_authenticate_deactivate(PluginState* plugin_state);
-void totp_scene_authenticate_free(PluginState* plugin_state);
+void totp_scene_authenticate_free(const PluginState* plugin_state);

+ 4 - 4
scenes/token_menu/totp_scene_token_menu.c

@@ -21,7 +21,7 @@ typedef struct {
     int16_t current_token_index;
     int16_t current_token_index;
 } SceneState;
 } SceneState;
 
 
-void totp_scene_token_menu_init(PluginState* plugin_state) {
+void totp_scene_token_menu_init(const PluginState* plugin_state) {
     UNUSED(plugin_state);
     UNUSED(plugin_state);
 }
 }
 
 
@@ -38,7 +38,7 @@ void totp_scene_token_menu_activate(
 }
 }
 
 
 void totp_scene_token_menu_render(Canvas* const canvas, PluginState* plugin_state) {
 void totp_scene_token_menu_render(Canvas* const canvas, PluginState* plugin_state) {
-    SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
+    const SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
     if(scene_state->current_token_index < 0) {
     if(scene_state->current_token_index < 0) {
         ui_control_button_render(
         ui_control_button_render(
             canvas,
             canvas,
@@ -84,7 +84,7 @@ void totp_scene_token_menu_render(Canvas* const canvas, PluginState* plugin_stat
     }
     }
 }
 }
 
 
-bool totp_scene_token_menu_handle_event(PluginEvent* const event, PluginState* plugin_state) {
+bool totp_scene_token_menu_handle_event(const PluginEvent* const event, PluginState* plugin_state) {
     if(event->type == EventTypeKey) {
     if(event->type == EventTypeKey) {
         SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
         SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
         if(event->input.type == InputTypePress) {
         if(event->input.type == InputTypePress) {
@@ -192,6 +192,6 @@ void totp_scene_token_menu_deactivate(PluginState* plugin_state) {
     plugin_state->current_scene_state = NULL;
     plugin_state->current_scene_state = NULL;
 }
 }
 
 
-void totp_scene_token_menu_free(PluginState* plugin_state) {
+void totp_scene_token_menu_free(const PluginState* plugin_state) {
     UNUSED(plugin_state);
     UNUSED(plugin_state);
 }
 }

+ 3 - 3
scenes/token_menu/totp_scene_token_menu.h

@@ -10,11 +10,11 @@ typedef struct {
     uint8_t current_token_index;
     uint8_t current_token_index;
 } TokenMenuSceneContext;
 } TokenMenuSceneContext;
 
 
-void totp_scene_token_menu_init(PluginState* plugin_state);
+void totp_scene_token_menu_init(const PluginState* plugin_state);
 void totp_scene_token_menu_activate(
 void totp_scene_token_menu_activate(
     PluginState* plugin_state,
     PluginState* plugin_state,
     const TokenMenuSceneContext* context);
     const TokenMenuSceneContext* context);
 void totp_scene_token_menu_render(Canvas* const canvas, PluginState* plugin_state);
 void totp_scene_token_menu_render(Canvas* const canvas, PluginState* plugin_state);
-bool totp_scene_token_menu_handle_event(PluginEvent* const event, PluginState* plugin_state);
+bool totp_scene_token_menu_handle_event(const PluginEvent* const event, PluginState* plugin_state);
 void totp_scene_token_menu_deactivate(PluginState* plugin_state);
 void totp_scene_token_menu_deactivate(PluginState* plugin_state);
-void totp_scene_token_menu_free(PluginState* plugin_state);
+void totp_scene_token_menu_free(const PluginState* plugin_state);

+ 1 - 1
services/cli/cli.c

@@ -9,7 +9,7 @@
 #include "commands/timezone/timezone.h"
 #include "commands/timezone/timezone.h"
 #include "commands/help/help.h"
 #include "commands/help/help.h"
 
 
-static void totp_cli_print_unknown_command(FuriString* unknown_command) {
+static void totp_cli_print_unknown_command(const FuriString* unknown_command) {
     TOTP_CLI_PRINTF(
     TOTP_CLI_PRINTF(
         "Command \"%s\" is unknown. Use \"" TOTP_CLI_COMMAND_HELP
         "Command \"%s\" is unknown. Use \"" TOTP_CLI_COMMAND_HELP
         "\" command to get list of available commands.",
         "\" command to get list of available commands.",

+ 1 - 1
services/cli/cli_helpers.c

@@ -1,7 +1,7 @@
 #include "cli_helpers.h"
 #include "cli_helpers.h"
 #include <cli/cli.h>
 #include <cli/cli.h>
 
 
-bool totp_cli_ensure_authenticated(PluginState* plugin_state, Cli* cli) {
+bool totp_cli_ensure_authenticated(const PluginState* plugin_state, Cli* cli) {
     if(plugin_state->current_scene == TotpSceneAuthentication) {
     if(plugin_state->current_scene == TotpSceneAuthentication) {
         TOTP_CLI_PRINTF("Pleases enter PIN on your flipper device\r\n");
         TOTP_CLI_PRINTF("Pleases enter PIN on your flipper device\r\n");
 
 

+ 1 - 1
services/cli/cli_helpers.h

@@ -37,4 +37,4 @@
     TOTP_CLI_PRINTF(                       \
     TOTP_CLI_PRINTF(                       \
         "Invalid command arguments. use \"help\" command to get list of available commands")
         "Invalid command arguments. use \"help\" command to get list of available commands")
 
 
-bool totp_cli_ensure_authenticated(PluginState* plugin_state, Cli* cli);
+bool totp_cli_ensure_authenticated(const PluginState* plugin_state, Cli* cli);

+ 2 - 2
services/cli/commands/add/add.c

@@ -14,7 +14,7 @@
 #define TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX "-d"
 #define TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX "-d"
 #define TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX "-u"
 #define TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX "-u"
 
 
-static bool token_info_set_digits_from_str(TokenInfo* token_info, FuriString* str) {
+static bool token_info_set_digits_from_str(TokenInfo* token_info, const FuriString* str) {
     switch(furi_string_get_char(str, 0)) {
     switch(furi_string_get_char(str, 0)) {
     case '6':
     case '6':
         token_info->digits = TOTP_6_DIGITS;
         token_info->digits = TOTP_6_DIGITS;
@@ -27,7 +27,7 @@ static bool token_info_set_digits_from_str(TokenInfo* token_info, FuriString* st
     return false;
     return false;
 }
 }
 
 
-static bool token_info_set_algo_from_str(TokenInfo* token_info, FuriString* str) {
+static bool token_info_set_algo_from_str(TokenInfo* token_info, const FuriString* str) {
     if(furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME) == 0) {
     if(furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME) == 0) {
         token_info->algo = SHA1;
         token_info->algo = SHA1;
         return true;
         return true;

+ 7 - 7
services/config/config.c

@@ -10,7 +10,7 @@
 #define CONFIG_FILE_PATH CONFIG_FILE_DIRECTORY_PATH "/totp.conf"
 #define CONFIG_FILE_PATH CONFIG_FILE_DIRECTORY_PATH "/totp.conf"
 #define CONFIG_FILE_BACKUP_PATH CONFIG_FILE_PATH ".backup"
 #define CONFIG_FILE_BACKUP_PATH CONFIG_FILE_PATH ".backup"
 
 
-static uint8_t token_info_get_digits_as_int(TokenInfo* token_info) {
+static uint8_t token_info_get_digits_as_int(const TokenInfo* token_info) {
     switch(token_info->digits) {
     switch(token_info->digits) {
     case TOTP_6_DIGITS:
     case TOTP_6_DIGITS:
         return 6;
         return 6;
@@ -32,7 +32,7 @@ static void token_info_set_digits_from_int(TokenInfo* token_info, uint8_t digits
     }
     }
 }
 }
 
 
-static char* token_info_get_algo_as_cstr(TokenInfo* token_info) {
+static char* token_info_get_algo_as_cstr(const TokenInfo* token_info) {
     switch(token_info->algo) {
     switch(token_info->algo) {
     case SHA1:
     case SHA1:
         return TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME;
         return TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME;
@@ -45,7 +45,7 @@ static char* token_info_get_algo_as_cstr(TokenInfo* token_info) {
     return NULL;
     return NULL;
 }
 }
 
 
-static void token_info_set_algo_from_str(TokenInfo* token_info, FuriString* str) {
+static void token_info_set_algo_from_str(TokenInfo* token_info, const FuriString* str) {
     if(furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME) == 0) {
     if(furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME) == 0) {
         token_info->algo = SHA1;
         token_info->algo = SHA1;
     } else if(furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME) == 0) {
     } else if(furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME) == 0) {
@@ -152,7 +152,7 @@ FlipperFormat* totp_open_config_file(Storage* storage) {
     return fff_data_file;
     return fff_data_file;
 }
 }
 
 
-void totp_config_file_save_new_token_i(FlipperFormat* file, TokenInfo* token_info) {
+void totp_config_file_save_new_token_i(FlipperFormat* file, const TokenInfo* token_info) {
     flipper_format_seek_to_end(file);
     flipper_format_seek_to_end(file);
     flipper_format_write_string_cstr(file, TOTP_CONFIG_KEY_TOKEN_NAME, token_info->name);
     flipper_format_write_string_cstr(file, TOTP_CONFIG_KEY_TOKEN_NAME, token_info->name);
     bool token_is_valid = token_info->token != NULL && token_info->token_length > 0;
     bool token_is_valid = token_info->token != NULL && token_info->token_length > 0;
@@ -170,7 +170,7 @@ void totp_config_file_save_new_token_i(FlipperFormat* file, TokenInfo* token_inf
     flipper_format_write_uint32(file, TOTP_CONFIG_KEY_TOKEN_DIGITS, &digits_count_as_uint32, 1);
     flipper_format_write_uint32(file, TOTP_CONFIG_KEY_TOKEN_DIGITS, &digits_count_as_uint32, 1);
 }
 }
 
 
-void totp_config_file_save_new_token(TokenInfo* token_info) {
+void totp_config_file_save_new_token(const TokenInfo* token_info) {
     Storage* cfg_storage = totp_open_storage();
     Storage* cfg_storage = totp_open_storage();
     FlipperFormat* file = totp_open_config_file(cfg_storage);
     FlipperFormat* file = totp_open_config_file(cfg_storage);
 
 
@@ -190,7 +190,7 @@ void totp_config_file_update_timezone_offset(float new_timezone_offset) {
     totp_close_storage();
     totp_close_storage();
 }
 }
 
 
-void totp_full_save_config_file(PluginState* const plugin_state) {
+void totp_full_save_config_file(const PluginState* const plugin_state) {
     Storage* storage = totp_open_storage();
     Storage* storage = totp_open_storage();
     FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
     FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
 
 
@@ -209,7 +209,7 @@ void totp_full_save_config_file(PluginState* const plugin_state) {
     flipper_format_write_bool(fff_data_file, TOTP_CONFIG_KEY_PINSET, &plugin_state->pin_set, 1);
     flipper_format_write_bool(fff_data_file, TOTP_CONFIG_KEY_PINSET, &plugin_state->pin_set, 1);
     ListNode* node = plugin_state->tokens_list;
     ListNode* node = plugin_state->tokens_list;
     while(node != NULL) {
     while(node != NULL) {
-        TokenInfo* token_info = node->data;
+        const TokenInfo* token_info = node->data;
         totp_config_file_save_new_token_i(fff_data_file, token_info);
         totp_config_file_save_new_token_i(fff_data_file, token_info);
         node = node->next;
         node = node->next;
     }
     }

+ 2 - 2
services/config/config.h

@@ -16,8 +16,8 @@ Storage* totp_open_storage();
 void totp_close_storage();
 void totp_close_storage();
 FlipperFormat* totp_open_config_file(Storage* storage);
 FlipperFormat* totp_open_config_file(Storage* storage);
 void totp_close_config_file(FlipperFormat* file);
 void totp_close_config_file(FlipperFormat* file);
-void totp_full_save_config_file(PluginState* const plugin_state);
+void totp_full_save_config_file(const PluginState* const plugin_state);
 void totp_config_file_load_base(PluginState* const plugin_state);
 void totp_config_file_load_base(PluginState* const plugin_state);
 TokenLoadingResult totp_config_file_load_tokens(PluginState* const plugin_state);
 TokenLoadingResult totp_config_file_load_tokens(PluginState* const plugin_state);
-void totp_config_file_save_new_token(TokenInfo* token_info);
+void totp_config_file_save_new_token(const TokenInfo* token_info);
 void totp_config_file_update_timezone_offset(float new_timezone_offset);
 void totp_config_file_update_timezone_offset(float new_timezone_offset);

+ 2 - 2
services/crypto/crypto.c

@@ -57,7 +57,7 @@ uint8_t* totp_crypto_decrypt(
     return decrypted_data;
     return decrypted_data;
 }
 }
 
 
-void totp_crypto_seed_iv(PluginState* plugin_state, uint8_t* pin, uint8_t pin_length) {
+void totp_crypto_seed_iv(PluginState* plugin_state, const uint8_t* pin, uint8_t pin_length) {
     if(plugin_state->crypto_verify_data == NULL) {
     if(plugin_state->crypto_verify_data == NULL) {
         FURI_LOG_D(LOGGING_TAG, "Generating new IV");
         FURI_LOG_D(LOGGING_TAG, "Generating new IV");
         furi_hal_random_fill_buf(&plugin_state->base_iv[0], TOTP_IV_SIZE);
         furi_hal_random_fill_buf(&plugin_state->base_iv[0], TOTP_IV_SIZE);
@@ -120,7 +120,7 @@ void totp_crypto_seed_iv(PluginState* plugin_state, uint8_t* pin, uint8_t pin_le
 
 
 bool totp_crypto_verify_key(const PluginState* plugin_state) {
 bool totp_crypto_verify_key(const PluginState* plugin_state) {
     size_t decrypted_key_length;
     size_t decrypted_key_length;
-    uint8_t* decrypted_key = totp_crypto_decrypt(
+    const uint8_t* decrypted_key = totp_crypto_decrypt(
         plugin_state->crypto_verify_data,
         plugin_state->crypto_verify_data,
         plugin_state->crypto_verify_data_length,
         plugin_state->crypto_verify_data_length,
         &plugin_state->iv[0],
         &plugin_state->iv[0],

+ 1 - 1
services/crypto/crypto.h

@@ -12,5 +12,5 @@ uint8_t* totp_crypto_decrypt(
     const size_t encrypted_data_length,
     const size_t encrypted_data_length,
     const uint8_t* iv,
     const uint8_t* iv,
     size_t* decrypted_data_length);
     size_t* decrypted_data_length);
-void totp_crypto_seed_iv(PluginState* plugin_state, uint8_t* pin, uint8_t pin_length);
+void totp_crypto_seed_iv(PluginState* plugin_state, const uint8_t* pin, uint8_t pin_length);
 bool totp_crypto_verify_key(const PluginState* plugin_state);
 bool totp_crypto_verify_key(const PluginState* plugin_state);

+ 1 - 1
services/totp/totp.c

@@ -49,7 +49,7 @@ uint32_t otp_generate(
 
 
     uint64_t input_swapped = swap_uint64(input);
     uint64_t input_swapped = swap_uint64(input);
 
 
-    int hmac_len = (*(algo))(plain_secret, plain_secret_length, (uint8_t*)&input_swapped, 8, hmac);
+    int hmac_len = (*algo)(plain_secret, plain_secret_length, (uint8_t*)&input_swapped, 8, hmac);
     if(hmac_len == 0) {
     if(hmac_len == 0) {
         free(hmac);
         free(hmac);
         return OTP_ERROR;
         return OTP_ERROR;

+ 3 - 3
services/ui/ui_controls.c

@@ -5,7 +5,7 @@
 #define TEXT_BOX_HEIGHT 13
 #define TEXT_BOX_HEIGHT 13
 #define TEXT_BOX_MARGIN 4
 #define TEXT_BOX_MARGIN 4
 
 
-void ui_control_text_box_render(Canvas* const canvas, int8_t y, char* text, bool is_selected) {
+void ui_control_text_box_render(Canvas* const canvas, int16_t y, const char* text, bool is_selected) {
     if(y < -TEXT_BOX_HEIGHT) {
     if(y < -TEXT_BOX_HEIGHT) {
         return;
         return;
     }
     }
@@ -44,7 +44,7 @@ void ui_control_select_render(
     int16_t x,
     int16_t x,
     int16_t y,
     int16_t y,
     uint8_t width,
     uint8_t width,
-    char* text,
+    const char* text,
     bool is_selected) {
     bool is_selected) {
     if(y < -TEXT_BOX_HEIGHT) {
     if(y < -TEXT_BOX_HEIGHT) {
         return;
         return;
@@ -99,7 +99,7 @@ void ui_control_button_render(
     int16_t y,
     int16_t y,
     uint8_t width,
     uint8_t width,
     uint8_t height,
     uint8_t height,
-    char* text,
+    const char* text,
     bool is_selected) {
     bool is_selected) {
     if(y < -height) {
     if(y < -height) {
         return;
         return;

+ 3 - 3
services/ui/ui_controls.h

@@ -3,19 +3,19 @@
 #include <inttypes.h>
 #include <inttypes.h>
 #include <gui/gui.h>
 #include <gui/gui.h>
 
 
-void ui_control_text_box_render(Canvas* const canvas, int8_t y, char* text, bool is_selected);
+void ui_control_text_box_render(Canvas* const canvas, int16_t y, const char* text, bool is_selected);
 void ui_control_button_render(
 void ui_control_button_render(
     Canvas* const canvas,
     Canvas* const canvas,
     int16_t x,
     int16_t x,
     int16_t y,
     int16_t y,
     uint8_t width,
     uint8_t width,
     uint8_t height,
     uint8_t height,
-    char* text,
+    const char* text,
     bool is_selected);
     bool is_selected);
 void ui_control_select_render(
 void ui_control_select_render(
     Canvas* const canvas,
     Canvas* const canvas,
     int16_t x,
     int16_t x,
     int16_t y,
     int16_t y,
     uint8_t width,
     uint8_t width,
-    char* text,
+    const char* text,
     bool is_selected);
     bool is_selected);

+ 5 - 5
totp_app.c

@@ -140,20 +140,20 @@ int32_t totp_app() {
         if (plugin_state->changing_scene) continue;
         if (plugin_state->changing_scene) continue;
         FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
         FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
 
 
-        PluginState* plugin_state = acquire_mutex_block(&state_mutex);
+        PluginState* plugin_state_m = acquire_mutex_block(&state_mutex);
 
 
         if(event_status == FuriStatusOk) {
         if(event_status == FuriStatusOk) {
             if (event.type == EventTypeKey) {
             if (event.type == EventTypeKey) {
                 last_user_interaction_time = furi_get_tick();
                 last_user_interaction_time = furi_get_tick();
             }
             }
 
 
-            processing = totp_scene_director_handle_event(&event, plugin_state);
-        } else if (plugin_state->pin_set && plugin_state->current_scene != TotpSceneAuthentication && furi_get_tick() - last_user_interaction_time > IDLE_TIMEOUT) {
-            totp_scene_director_activate_scene(plugin_state, TotpSceneAuthentication, NULL);
+            processing = totp_scene_director_handle_event(&event, plugin_state_m);
+        } else if (plugin_state_m->pin_set && plugin_state_m->current_scene != TotpSceneAuthentication && furi_get_tick() - last_user_interaction_time > IDLE_TIMEOUT) {
+            totp_scene_director_activate_scene(plugin_state_m, TotpSceneAuthentication, NULL);
         }
         }
 
 
         view_port_update(view_port);
         view_port_update(view_port);
-        release_mutex(&state_mutex, plugin_state);
+        release_mutex(&state_mutex, plugin_state_m);
     }
     }
 
 
     view_port_enabled_set(view_port, false);
     view_port_enabled_set(view_port, false);