Просмотр исходного кода

* Updated to FuriString

* Build for Unleashed and Official firmware
alex.kopachov 3 лет назад
Родитель
Сommit
99e8cebb40
56 измененных файлов с 81 добавлено и 169 удалено
  1. 4 2
      application.fam
  2. 1 4
      scenes/add_new_token/totp_input_text.h
  3. 5 5
      scenes/add_new_token/totp_scene_add_new_token.c
  4. 1 4
      scenes/add_new_token/totp_scene_add_new_token.h
  5. 3 3
      scenes/authenticate/totp_scene_authenticate.c
  6. 1 4
      scenes/authenticate/totp_scene_authenticate.h
  7. 4 4
      scenes/generate_token/totp_scene_generate_token.c
  8. 1 4
      scenes/generate_token/totp_scene_generate_token.h
  9. 1 4
      scenes/scene_director.h
  10. 4 4
      scenes/token_menu/totp_scene_token_menu.c
  11. 1 4
      scenes/token_menu/totp_scene_token_menu.h
  12. 2 3
      scenes/totp_scenes_enum.h
  13. 0 0
      services/base32/base32.c
  14. 1 4
      services/base32/base32.h
  15. 20 22
      services/config/config.c
  16. 1 4
      services/config/config.h
  17. 1 4
      services/config/constants.h
  18. 2 3
      services/config/migrations/config_migration_v1_to_v2.c
  19. 1 4
      services/config/migrations/config_migration_v1_to_v2.h
  20. 0 0
      services/hmac/byteswap.c
  21. 1 4
      services/hmac/byteswap.h
  22. 0 0
      services/hmac/hmac-common.h
  23. 0 0
      services/hmac/hmac-sha1.c
  24. 1 4
      services/hmac/hmac-sha1.h
  25. 0 0
      services/hmac/hmac-sha256.c
  26. 1 4
      services/hmac/hmac-sha256.h
  27. 0 0
      services/hmac/hmac-sha512.c
  28. 1 4
      services/hmac/hmac-sha512.h
  29. 0 0
      services/hmac/memxor.c
  30. 1 4
      services/hmac/memxor.h
  31. 0 0
      services/hmac/sha1.c
  32. 1 4
      services/hmac/sha1.h
  33. 0 0
      services/hmac/sha256.c
  34. 1 4
      services/hmac/sha256.h
  35. 0 0
      services/hmac/sha512.c
  36. 1 4
      services/hmac/sha512.h
  37. 0 0
      services/hmac/u64.c
  38. 2 0
      services/hmac/u64.h
  39. 0 0
      services/list/list.c
  40. 1 4
      services/list/list.h
  41. 0 0
      services/timezone_utils/timezone_utils.c
  42. 1 4
      services/timezone_utils/timezone_utils.h
  43. 0 0
      services/totp/totp.c
  44. 1 4
      services/totp/totp.h
  45. 1 4
      services/ui/constants.h
  46. 1 4
      services/ui/icons.h
  47. 0 0
      services/ui/ui_controls.c
  48. 1 4
      services/ui/ui_controls.h
  49. 3 3
      totp_app.c
  50. 1 1
      totp_app_cli.c
  51. 1 4
      types/common.h
  52. 1 5
      types/event_type.h
  53. 1 4
      types/plugin_event.h
  54. 2 5
      types/plugin_state.h
  55. 1 1
      types/token_info.c
  56. 1 4
      types/token_info.h

+ 4 - 2
application.fam

@@ -8,13 +8,15 @@ App(
         "gui",
         "cli",
         "dialogs",
-        "storage"
+        "storage",
+        "input", 
+        "notification"
     ],
     provides=["totp_start"],
     stack_size=2 * 1024,
     order=20,
     fap_category="Misc",
-    fap_icon="totp_10px.png",
+    fap_icon="totp_10px.png"
 )
 
 App(

+ 1 - 4
scenes/add_new_token/totp_input_text.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_INPUT_TEXT_H_
-#define _TOTP_INPUT_TEXT_H_
+#pragma once
 
 #include <gui/gui.h>
 #include <gui/view.h>
@@ -37,5 +36,3 @@ InputTextSceneState* totp_input_text_activate(InputTextSceneContext* context);
 void totp_input_text_render(Canvas* const canvas, InputTextSceneState* text_input_state);
 bool totp_input_text_handle_event(PluginEvent* const event, InputTextSceneState* text_input_state);
 void totp_input_text_free(InputTextSceneState* state);
-
-#endif

+ 5 - 5
scenes/add_new_token/totp_scene_add_new_token.c

@@ -1,13 +1,13 @@
 #include "totp_scene_add_new_token.h"
 #include "../../types/common.h"
-#include "../../lib/ui/constants.h"
+#include "../../services/ui/constants.h"
 #include "../scene_director.h"
 #include "totp_input_text.h"
 #include "../../types/token_info.h"
-#include "../../lib/list/list.h"
-#include "../../lib/base32/base32.h"
-#include "../../lib/config/config.h"
-#include "../../lib/ui/ui_controls.h"
+#include "../../services/list/list.h"
+#include "../../services/base32/base32.h"
+#include "../../services/config/config.h"
+#include "../../services/ui/ui_controls.h"
 #include "../generate_token/totp_scene_generate_token.h"
 
 #define TOKEN_ALGO_LIST_LENGTH 3

+ 1 - 4
scenes/add_new_token/totp_scene_add_new_token.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_SCENE_ADD_NEW_TOKEN_H_
-#define _TOTP_SCENE_ADD_NEW_TOKEN_H_
+#pragma once
 
 #include <gui/gui.h>
 #include <furi.h>
@@ -17,5 +16,3 @@ void totp_scene_add_new_token_render(Canvas* const canvas, PluginState* plugin_s
 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_free(PluginState* plugin_state);
-
-#endif

+ 3 - 3
scenes/authenticate/totp_scene_authenticate.c

@@ -1,9 +1,9 @@
 #include "totp_scene_authenticate.h"
 #include <dialogs/dialogs.h>
 #include "../../types/common.h"
-#include "../../lib/ui/icons.h"
-#include "../../lib/ui/constants.h"
-#include "../../lib/config/config.h"
+#include "../../services/ui/icons.h"
+#include "../../services/ui/constants.h"
+#include "../../services/config/config.h"
 #include "../scene_director.h"
 #include "../totp_scenes_enum.h"
 

+ 1 - 4
scenes/authenticate/totp_scene_authenticate.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_SCENE_AUTHENTICATE_H_
-#define _TOTP_SCENE_AUTHENTICATE_H_
+#pragma once
 
 #include <gui/gui.h>
 #include <furi.h>
@@ -13,5 +12,3 @@ void totp_scene_authenticate_render(Canvas* const canvas, PluginState* plugin_st
 bool totp_scene_authenticate_handle_event(PluginEvent* const event, PluginState* plugin_state);
 void totp_scene_authenticate_deactivate(PluginState* plugin_state);
 void totp_scene_authenticate_free(PluginState* plugin_state);
-
-#endif

+ 4 - 4
scenes/generate_token/totp_scene_generate_token.c

@@ -4,10 +4,10 @@
 #include "totp_scene_generate_token.h"
 #include "../../types/token_info.h"
 #include "../../types/common.h"
-#include "../../lib/ui/icons.h"
-#include "../../lib/ui/constants.h"
-#include "../../lib/totp/totp.h"
-#include "../../lib/config/config.h"
+#include "../../services/ui/icons.h"
+#include "../../services/ui/constants.h"
+#include "../../services/totp/totp.h"
+#include "../../services/config/config.h"
 #include "../scene_director.h"
 #include "../token_menu/totp_scene_token_menu.h"
 

+ 1 - 4
scenes/generate_token/totp_scene_generate_token.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_SCENE_GENERATE_TOKEN_H_
-#define _TOTP_SCENE_GENERATE_TOKEN_H_
+#pragma once
 
 #include <gui/gui.h>
 #include <furi.h>
@@ -17,5 +16,3 @@ void totp_scene_generate_token_render(Canvas* const canvas, PluginState* plugin_
 bool totp_scene_generate_token_handle_event(PluginEvent* const event, PluginState* plugin_state);
 void totp_scene_generate_token_deactivate(PluginState* plugin_state);
 void totp_scene_generate_token_free(PluginState* plugin_state);
-
-#endif

+ 1 - 4
scenes/scene_director.h

@@ -1,5 +1,4 @@
-#ifndef _SCENE_DIRECTOR_H_
-#define _SCENE_DIRECTOR_H_
+#pragma once
 
 #include <gui/gui.h>
 #include "../types/plugin_state.h"
@@ -12,5 +11,3 @@ void totp_scene_director_init_scenes(PluginState* const plugin_state);
 void totp_scene_director_render(Canvas* const canvas, PluginState* const plugin_state);
 void totp_scene_director_dispose(PluginState* const plugin_state);
 bool totp_scene_director_handle_event(PluginEvent* const event, PluginState* const plugin_state);
-
-#endif

+ 4 - 4
scenes/token_menu/totp_scene_token_menu.c

@@ -1,11 +1,11 @@
 #include "totp_scene_token_menu.h"
 #include <gui/gui.h>
 #include <dialogs/dialogs.h>
-#include "../../lib/ui/ui_controls.h"
-#include "../../lib/ui/constants.h"
+#include "../../services/ui/ui_controls.h"
+#include "../../services/ui/constants.h"
 #include "../scene_director.h"
-#include "../../lib/config/config.h"
-#include "../../lib/list/list.h"
+#include "../../services/config/config.h"
+#include "../../services/list/list.h"
 #include "../../types/token_info.h"
 #include "../generate_token/totp_scene_generate_token.h"
 #include "../add_new_token/totp_scene_add_new_token.h"

+ 1 - 4
scenes/token_menu/totp_scene_token_menu.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_SCENE_TOKEN_MENU_H_
-#define _TOTP_SCENE_TOKEN_MENU_H_
+#pragma once
 
 #include <gui/gui.h>
 #include <furi.h>
@@ -17,5 +16,3 @@ 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);
 void totp_scene_token_menu_deactivate(PluginState* plugin_state);
 void totp_scene_token_menu_free(PluginState* plugin_state);
-
-#endif

+ 2 - 3
scenes/totp_scenes_enum.h

@@ -1,9 +1,8 @@
-#ifndef _TOTP_SCENES_ENUM_H_
-#define _TOTP_SCENES_ENUM_H_
+#pragma once
+
 typedef enum {
     TotpSceneAuthentication,
     TotpSceneGenerateToken,
     TotpSceneAddNewToken,
     TotpSceneTokenMenu
 } Scene;
-#endif

+ 0 - 0
lib/base32/base32.c → services/base32/base32.c


+ 1 - 4
lib/base32/base32.h → services/base32/base32.h

@@ -25,8 +25,7 @@
 // All functions return the number of output bytes or -1 on error. If the
 // output buffer is too small, the result will silently be truncated.
 
-#ifndef _BASE32_H_
-#define _BASE32_H_
+#pragma once
 
 #include <stdint.h>
 
@@ -35,5 +34,3 @@ int base32_decode(const uint8_t *encoded, uint8_t *result, int bufSize)
 int base32_encode(const uint8_t *data, int length, uint8_t *result,
                   int bufSize)
     __attribute__((visibility("hidden")));
-
-#endif /* _BASE32_H_ */

+ 20 - 22
lib/config/config.c → services/config/config.c

@@ -1,6 +1,7 @@
 #include "config.h"
 #include <stdlib.h>
 #include <string.h>
+#include "../list/list.h"
 #include "../../types/common.h"
 #include "../../types/token_info.h"
 #include "migrations/config_migration_v1_to_v2.h"
@@ -39,12 +40,12 @@ char* token_info_get_algo_as_cstr(TokenInfo* token_info) {
     return NULL;
 }
 
-void token_info_set_algo_from_str(TokenInfo* token_info, string_t str) {
-    if (string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME) == 0) {
+void token_info_set_algo_from_str(TokenInfo* token_info, FuriString* str) {
+    if (furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME) == 0) {
         token_info->algo = SHA1;
-    } else if (string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME)) {
+    } else if (furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME)) {
         token_info->algo = SHA256;
-    } else if (string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME)) {
+    } else if (furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME)) {
         token_info->algo = SHA512;
     }
 }
@@ -88,37 +89,36 @@ FlipperFormat* totp_open_config_file(Storage* storage) {
         flipper_format_write_comment_cstr(fff_data_file, " ");
         flipper_format_write_comment_cstr(fff_data_file, "Timezone offset in hours. Important note: do not put '+' sign for positive values");
         flipper_format_write_float(fff_data_file, TOTP_CONFIG_KEY_TIMEZONE, &tmp_tz, 1);
-        string_t temp_str;
-        string_init(temp_str);
+        FuriString* temp_str = furi_string_alloc();
         
         flipper_format_write_comment_cstr(fff_data_file, " ");
         flipper_format_write_comment_cstr(fff_data_file, "=== TOKEN SAMPLE BEGIN ===");
         flipper_format_write_comment_cstr(fff_data_file, " ");
         flipper_format_write_comment_cstr(fff_data_file, "# Token name which will be visible in the UI.");
-        string_printf(temp_str, "%s: Sample token name", TOTP_CONFIG_KEY_TOKEN_NAME);
+        furi_string_printf(temp_str, "%s: Sample token name", TOTP_CONFIG_KEY_TOKEN_NAME);
         flipper_format_write_comment(fff_data_file, temp_str);
         flipper_format_write_comment_cstr(fff_data_file, " ");
 
         flipper_format_write_comment_cstr(fff_data_file, "# Plain token secret without spaces, dashes and etc, just pure alpha-numeric characters. Important note: plain token will be encrypted and replaced by TOTP app");
-        string_printf(temp_str, "%s: plaintokensecret", TOTP_CONFIG_KEY_TOKEN_SECRET);
+        furi_string_printf(temp_str, "%s: plaintokensecret", TOTP_CONFIG_KEY_TOKEN_SECRET);
         flipper_format_write_comment(fff_data_file, temp_str);
         flipper_format_write_comment_cstr(fff_data_file, " ");
 
-        string_printf(temp_str, " # Token hashing algorithm to use during code generation. Supported options are %s, %s and %s. If you are not use which one to use - use %s", TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME);
+        furi_string_printf(temp_str, " # Token hashing algorithm to use during code generation. Supported options are %s, %s and %s. If you are not use which one to use - use %s", TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME);
         flipper_format_write_comment(fff_data_file, temp_str);
-        string_printf(temp_str, "%s: %s", TOTP_CONFIG_KEY_TOKEN_ALGO, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME);
+        furi_string_printf(temp_str, "%s: %s", TOTP_CONFIG_KEY_TOKEN_ALGO, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME);
         flipper_format_write_comment(fff_data_file, temp_str);
         flipper_format_write_comment_cstr(fff_data_file, " ");
 
         flipper_format_write_comment_cstr(fff_data_file, "# How many digits there should be in generated code. Available options are 6 and 8. Majority websites requires 6 digits code, however some rare websites wants to get 8 digits code. If you are not sure which one to use - use 6");
-        string_printf(temp_str, "%s: 6", TOTP_CONFIG_KEY_TOKEN_DIGITS);
+        furi_string_printf(temp_str, "%s: 6", TOTP_CONFIG_KEY_TOKEN_DIGITS);
         flipper_format_write_comment(fff_data_file, temp_str);
         flipper_format_write_comment_cstr(fff_data_file, " ");
 
         flipper_format_write_comment_cstr(fff_data_file, "=== TOKEN SAMPLE END ===");
         flipper_format_write_comment_cstr(fff_data_file, " ");
 
-        string_clear(temp_str);
+        furi_string_free(temp_str);
         if(!flipper_format_rewind(fff_data_file)) {
             totp_close_config_file(fff_data_file);
             FURI_LOG_E(LOGGING_TAG, "Rewind error");
@@ -163,13 +163,12 @@ void totp_config_file_load_base(PluginState* const plugin_state) {
 
     plugin_state->timezone_offset = 0;
 
-    string_t temp_str;
-    string_init(temp_str);
+    FuriString* temp_str = furi_string_alloc();
 
     uint32_t file_version;
     if(!flipper_format_read_header(fff_data_file, temp_str, &file_version)) {
         FURI_LOG_E(LOGGING_TAG, "Missing or incorrect header");
-        string_clear(temp_str);
+        furi_string_free(temp_str);
         return;
     }
 
@@ -227,7 +226,7 @@ void totp_config_file_load_base(PluginState* const plugin_state) {
         FURI_LOG_D(LOGGING_TAG, "Missing timezone offset information, defaulting to 0");
     }
 
-    string_clear(temp_str);
+    furi_string_free(temp_str);
     totp_close_config_file(fff_data_file);
     totp_close_storage();
 }
@@ -236,13 +235,12 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
     Storage* storage = totp_open_storage();
     FlipperFormat* fff_data_file = totp_open_config_file(storage);
 
-    string_t temp_str;
+    FuriString* temp_str = furi_string_alloc();
     uint32_t temp_data32;
-    string_init(temp_str);
 
     if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) {
         FURI_LOG_E(LOGGING_TAG, "Missing or incorrect header");
-        string_clear(temp_str);
+        furi_string_free(temp_str);
         return;
     }
 
@@ -256,7 +254,7 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
         
         TokenInfo* tokenInfo = token_info_alloc();
 
-        const char* temp_cstr = string_get_cstr(temp_str);
+        const char* temp_cstr = furi_string_get_cstr(temp_str);
         tokenInfo->name = (char *)malloc(strlen(temp_cstr) + 1);
         strcpy(tokenInfo->name, temp_cstr);
 
@@ -272,7 +270,7 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
                 continue;
             }
 
-            temp_cstr = string_get_cstr(temp_str);
+            temp_cstr = furi_string_get_cstr(temp_str);
             token_info_set_secret(tokenInfo, temp_cstr, strlen(temp_cstr), &plugin_state->iv[0]);
             has_any_plain_secret = true;
             FURI_LOG_W(LOGGING_TAG, "Found token with plain secret");
@@ -315,7 +313,7 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
 
     FURI_LOG_D(LOGGING_TAG, "Found %d tokens", index);
 
-    string_clear(temp_str);
+    furi_string_free(temp_str);
     totp_close_config_file(fff_data_file);
     totp_close_storage();
 

+ 1 - 4
lib/config/config.h → services/config/config.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_CONFIG_FILE_H_
-#define _TOTP_CONFIG_FILE_H_
+#pragma once
 
 #include <flipper_format/flipper_format.h>
 #include <furi.h>
@@ -15,5 +14,3 @@ void totp_full_save_config_file(PluginState* const plugin_state);
 void totp_config_file_load_base(PluginState* const plugin_state);
 void totp_config_file_load_tokens(PluginState* const plugin_state);
 void totp_config_file_save_new_token(FlipperFormat* file, TokenInfo* token_info);
-
-#endif

+ 1 - 4
lib/config/constants.h → services/config/constants.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_CONFIG_CONSTANTS_FILE_H_
-#define _TOTP_CONFIG_CONSTANTS_FILE_H_
+#pragma once
 
 #define CONFIG_FILE_HEADER "Flipper TOTP plugin config file"
 #define CONFIG_FILE_ACTUAL_VERSION 2
@@ -15,5 +14,3 @@
 #define TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME "sha1"
 #define TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME "sha256"
 #define TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME "sha512"
-
-#endif

+ 2 - 3
lib/config/migrations/config_migration_v1_to_v2.c → services/config/migrations/config_migration_v1_to_v2.c

@@ -7,8 +7,7 @@
 bool totp_config_migrate_v1_to_v2(FlipperFormat* fff_data_file, FlipperFormat* fff_backup_data_file) {
     flipper_format_write_header_cstr(fff_data_file, CONFIG_FILE_HEADER, NEW_VERSION);
 
-    string_t temp_str;
-    string_init(temp_str);
+    FuriString* temp_str = furi_string_alloc();
 
     if (flipper_format_read_string(fff_backup_data_file, TOTP_CONFIG_KEY_BASE_IV, temp_str)) {
         flipper_format_write_string(fff_data_file, TOTP_CONFIG_KEY_BASE_IV, temp_str);
@@ -37,6 +36,6 @@ bool totp_config_migrate_v1_to_v2(FlipperFormat* fff_data_file, FlipperFormat* f
         flipper_format_write_uint32(fff_data_file, TOTP_CONFIG_KEY_TOKEN_DIGITS, &default_digits, 1);
     }
 
-    string_clear(temp_str);
+    furi_string_free(temp_str);
     return true;
 }

+ 1 - 4
lib/config/migrations/config_migration_v1_to_v2.h → services/config/migrations/config_migration_v1_to_v2.h

@@ -1,8 +1,5 @@
-#ifndef _TOTP_CONFIG_FILE_MIGRATE_V1_TO_V2_H_
-#define _TOTP_CONFIG_FILE_MIGRATE_V1_TO_V2_H_
+#pragma once
 
 #include <flipper_format/flipper_format.h>
 
 bool totp_config_migrate_v1_to_v2(FlipperFormat* fff_data_file, FlipperFormat* fff_backup_data_file);
-
-#endif

+ 0 - 0
lib/hmac/byteswap.c → services/hmac/byteswap.c


+ 1 - 4
lib/hmac/byteswap.h → services/hmac/byteswap.h

@@ -1,9 +1,6 @@
-#ifndef BYTESWAP_H
-#define BYTESWAP_H
+#pragma once
 
 #include <stdint.h>
 
 uint32_t swap_uint32( uint32_t val );
 uint64_t swap_uint64( uint64_t val );
-
-#endif

+ 0 - 0
lib/hmac/hmac-common.h → services/hmac/hmac-common.h


+ 0 - 0
lib/hmac/hmac-sha1.c → services/hmac/hmac-sha1.c


+ 1 - 4
lib/hmac/hmac-sha1.h → services/hmac/hmac-sha1.h

@@ -1,5 +1,4 @@
-#ifndef HMAC_SHA1_H
-#define HMAC_SHA1_H
+#pragma once
 
 #include <stddef.h>
 
@@ -10,5 +9,3 @@
    output to pre-allocated 20 byte minimum RESBUF buffer.  Return 0 on
    success.  */
 int hmac_sha1 (const void *key, size_t keylen, const void *in, size_t inlen, void *restrict resbuf);
-
-#endif /* HMAC_SHA1_H */

+ 0 - 0
lib/hmac/hmac-sha256.c → services/hmac/hmac-sha256.c


+ 1 - 4
lib/hmac/hmac-sha256.h → services/hmac/hmac-sha256.h

@@ -1,5 +1,4 @@
-#ifndef HMAC_SHA256_H
-#define HMAC_SHA256_H
+#pragma once
 
 #include <stddef.h>
 
@@ -10,5 +9,3 @@
    output to pre-allocated 32 byte minimum RESBUF buffer.  Return 0 on
    success.  */
 int hmac_sha256 (const void *key, size_t keylen, const void *in, size_t inlen, void *restrict resbuf);
-
-#endif /* HMAC_SHA256_H */

+ 0 - 0
lib/hmac/hmac-sha512.c → services/hmac/hmac-sha512.c


+ 1 - 4
lib/hmac/hmac-sha512.h → services/hmac/hmac-sha512.h

@@ -1,5 +1,4 @@
-#ifndef HMAC_SHA512_H
-#define HMAC_SHA512_H
+#pragma once
 
 #include <stddef.h>
 
@@ -10,5 +9,3 @@
    output to pre-allocated 64 byte minimum RESBUF buffer.  Return 0 on
    success.  */
 int hmac_sha512 (const void *key, size_t keylen, const void *in, size_t inlen, void *restrict resbuf);
-
-#endif /* HMAC_SHA512_H */

+ 0 - 0
lib/hmac/memxor.c → services/hmac/memxor.c


+ 1 - 4
lib/hmac/memxor.h → services/hmac/memxor.h

@@ -18,8 +18,7 @@
 /* Written by Simon Josefsson.  The interface was inspired by memxor
    in Niels Möller's Nettle. */
 
-#ifndef MEMXOR_H
-# define MEMXOR_H
+#pragma once
 
 #include <stddef.h>
 
@@ -27,5 +26,3 @@
    the result in DEST, of length N bytes.  Returns a pointer to
    DEST. */
 void *memxor (void */*restrict*/ dest, const void */*restrict*/ src, size_t n);
-
-#endif /* MEMXOR_H */

+ 0 - 0
lib/hmac/sha1.c → services/hmac/sha1.c


+ 1 - 4
lib/hmac/sha1.h → services/hmac/sha1.h

@@ -16,8 +16,7 @@
    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
-#ifndef SHA1_H
-# define SHA1_H 1
+#pragma once
 
 # include <stdio.h>
 # include <stdint.h>
@@ -105,8 +104,6 @@ extern int sha1_stream (FILE *stream, void *resblock);
 }
 # endif
 
-#endif
-
 /*
  * Hey Emacs!
  * Local Variables:

+ 0 - 0
lib/hmac/sha256.c → services/hmac/sha256.c


+ 1 - 4
lib/hmac/sha256.h → services/hmac/sha256.h

@@ -15,8 +15,7 @@
    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
-#ifndef SHA256_H
-# define SHA256_H 1
+#pragma once
 
 # include <stdio.h>
 # include <stdint.h>
@@ -111,8 +110,6 @@ extern int sha224_stream (FILE *stream, void *resblock);
 }
 # endif
 
-#endif
-
 /*
  * Hey Emacs!
  * Local Variables:

+ 0 - 0
lib/hmac/sha512.c → services/hmac/sha512.c


+ 1 - 4
lib/hmac/sha512.h → services/hmac/sha512.h

@@ -15,8 +15,7 @@
    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
-#ifndef SHA512_H
-# define SHA512_H 1
+#pragma once
 
 # include <stdio.h>
 # include "u64.h"
@@ -114,8 +113,6 @@ extern int sha384_stream (FILE *stream, void *resblock);
 }
 # endif
 
-#endif
-
 /*
  * Hey Emacs!
  * Local Variables:

+ 0 - 0
lib/hmac/u64.c → services/hmac/u64.c


+ 2 - 0
lib/hmac/u64.h → services/hmac/u64.h

@@ -17,6 +17,8 @@
 
 /* Written by Paul Eggert.  */
 
+#pragma once
+
 #include <stdint.h>
 
 #ifndef _GL_U64_INLINE

+ 0 - 0
lib/list/list.c → services/list/list.c


+ 1 - 4
lib/list/list.h → services/list/list.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_LIST_H_
-#define _TOTP_LIST_H_
+#pragma once
 
 #include <stdlib.h>
 #include <inttypes.h>
@@ -15,5 +14,3 @@ ListNode *list_find(ListNode *head, void* data); /* returns pointer of element w
 ListNode *list_element_at(ListNode *head, uint16_t index); /* returns pointer of element with specified index in list. */
 ListNode *list_remove(ListNode *head, ListNode *ep); /* removes element from the list and returns new head node. */
 void list_free(ListNode *head); /* deletes all elements of the list. */
-
-#endif

+ 0 - 0
lib/timezone_utils/timezone_utils.c → services/timezone_utils/timezone_utils.c


+ 1 - 4
lib/timezone_utils/timezone_utils.h → services/timezone_utils/timezone_utils.h

@@ -1,9 +1,6 @@
-#ifndef _TIMEZONE_UTILS_H_
-#define _TIMEZONE_UTILS_H_
+#pragma once
 
 #include <inttypes.h>
 
 int32_t timezone_offset_from_hours(float hours);
 uint64_t timezone_offset_apply(uint64_t time, int32_t offset);
-
-#endif

+ 0 - 0
lib/totp/totp.c → services/totp/totp.c


+ 1 - 4
lib/totp/totp.h → services/totp/totp.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_H_
-#define _TOTP_H_
+#pragma once
 
 #include <stdlib.h>
 #include <stdint.h>
@@ -40,5 +39,3 @@ extern const TOTP_ALGO TOTP_ALGO_SHA512;
         0 otherwise
 */
 uint32_t totp_at(TOTP_ALGO algo, uint8_t digits, const uint8_t* plain_secret, uint8_t plain_secret_length, uint64_t for_time, float timezone, uint8_t interval);
-
-#endif

+ 1 - 4
lib/ui/constants.h → services/ui/constants.h

@@ -1,9 +1,6 @@
-#ifndef _TOTP_UI_CONSTANTS_H_
-#define _TOTP_UI_CONSTANTS_H_
+#pragma once
 
 #define SCREEN_WIDTH 128
 #define SCREEN_HEIGHT 64
 #define SCREEN_WIDTH_CENTER (SCREEN_WIDTH >> 1)
 #define SCREEN_HEIGHT_CENTER (SCREEN_HEIGHT >> 1)
-
-#endif

+ 1 - 4
lib/ui/icons.h → services/ui/icons.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_ICONS_H_
-#define _TOTP_ICONS_H_
+#pragma once
 
 #include <inttypes.h>
 
@@ -10,5 +9,3 @@ static const uint8_t ICON_ARROW_LEFT_8x9[] = { 0x80,0xe0,0xf8,0xfe,0xff,0xfe,0xf
 #define ICON_ARROW_RIGHT_8x9_WIDTH 8
 #define ICON_ARROW_RIGHT_8x9_HEIGHT 9
 static const uint8_t ICON_ARROW_RIGHT_8x9[] = { 0x01,0x07,0x1f,0x7f,0xff,0x7f,0x1f,0x07,0x01 };
-
-#endif

+ 0 - 0
lib/ui/ui_controls.c → services/ui/ui_controls.c


+ 1 - 4
lib/ui/ui_controls.h → services/ui/ui_controls.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_UI_CONTROLS_H_
-#define _TOTP_UI_CONTROLS_H_
+#pragma once
 
 #include <inttypes.h>
 #include <gui/gui.h>
@@ -7,5 +6,3 @@
 void ui_control_text_box_render(Canvas* const canvas, int8_t y, char* text, bool is_selected);
 void ui_control_button_render(Canvas* const canvas, uint8_t x, int8_t y, uint8_t width, uint8_t height, char* text, bool is_selected);
 void ui_control_select_render(Canvas* const canvas, int8_t y, char* text, bool is_selected);
-
-#endif

+ 3 - 3
totp_app.c

@@ -7,9 +7,9 @@
 #include <flipper_format/flipper_format.h>
 #include <notification/notification.h>
 #include <notification/notification_messages.h>
-#include "lib/base32/base32.h"
-#include "lib/list/list.h"
-#include "lib/config/config.h"
+#include "services/base32/base32.h"
+#include "services/list/list.h"
+#include "services/config/config.h"
 #include "types/plugin_state.h"
 #include "types/token_info.h"
 #include "types/plugin_event.h"

+ 1 - 1
totp_app_cli.c

@@ -11,7 +11,7 @@ void totp_cli_print_usage() {
     printf("\reset\t - Reset app to default (reset PIN and removes all tokens)\r\n");
 };
 
-static void totp_cli(Cli* cli, string_t args, void* context) {
+static void totp_cli(Cli* cli, FuriString* args, void* context) {
     UNUSED(cli);
     UNUSED(args);
     UNUSED(context);

+ 1 - 4
types/common.h

@@ -1,7 +1,4 @@
-#ifndef _TOTP_COMMON_TYPES_H_
-#define _TOTP_COMMON_TYPES_H_
+#pragma once
 
 #define LOGGING_TAG "TOTP APP"
 #define CRYPTO_KEY_SLOT 2
-
-#endif

+ 1 - 5
types/event_type.h

@@ -1,11 +1,7 @@
-#ifndef _TOTP_EVENT_TYPE_H_
-#define _TOTP_EVENT_TYPE_H_
-
+#pragma once
 #include <inttypes.h>
 
 typedef enum {
     EventTypeTick,
     EventTypeKey,
 } EventType;
-
-#endif

+ 1 - 4
types/plugin_event.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_PLUGIN_EVENT_H_
-#define _TOTP_PLUGIN_EVENT_H_
+#pragma once
 
 #include <inttypes.h>
 #include <input/input.h>
@@ -9,5 +8,3 @@ typedef struct {
     EventType type;
     InputEvent input;
 } PluginEvent;
-
-#endif

+ 2 - 5
types/plugin_state.h

@@ -1,10 +1,9 @@
-#ifndef _TOTP_PLUGIN_STATE_H_
-#define _TOTP_PLUGIN_STATE_H_
+#pragma once
 
 #include <notification/notification.h>
 #include <gui/gui.h>
 #include <dialogs/dialogs.h>
-#include "../lib/list/list.h"
+#include "../services/list/list.h"
 #include "../scenes/totp_scenes_enum.h"
 
 #define TOTP_IV_SIZE 16
@@ -27,5 +26,3 @@ typedef struct {
     uint8_t iv[TOTP_IV_SIZE];
     uint8_t base_iv[TOTP_IV_SIZE];
 } PluginState;
-
-#endif

+ 1 - 1
types/token_info.c

@@ -3,7 +3,7 @@
 #include "token_info.h"
 #include "stdlib.h"
 #include "common.h"
-#include "../lib/base32/base32.h"
+#include "../services/base32/base32.h"
 
 TokenInfo* token_info_alloc() {
     TokenInfo* tokenInfo = malloc(sizeof(TokenInfo));

+ 1 - 4
types/token_info.h

@@ -1,5 +1,4 @@
-#ifndef _TOTP_TOKEN_INFO_H_
-#define _TOTP_TOKEN_INFO_H_
+#pragma once
 
 #include <inttypes.h>
 
@@ -26,5 +25,3 @@ TokenInfo* token_info_alloc();
 void token_info_free(TokenInfo* token_info);
 void token_info_set_secret(TokenInfo* token_info, const char* base32_token_secret, uint8_t token_secret_length, uint8_t* iv);
 uint8_t token_info_get_digits_count(TokenInfo* token_info);
-
-#endif