1
1
#include "config.h"
2
2
#include <stdlib.h>
3
3
#include <string.h>
4
+ #include "../list/list.h"
4
5
#include "../../types/common.h"
5
6
#include "../../types/token_info.h"
6
7
#include "migrations/config_migration_v1_to_v2.h"
@@ -39,12 +40,12 @@ char* token_info_get_algo_as_cstr(TokenInfo* token_info) {
39
40
return NULL ;
40
41
}
41
42
42
- void token_info_set_algo_from_str (TokenInfo * token_info , string_t str ) {
43
- if (string_cmpi_str (str , TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME ) == 0 ) {
43
+ void token_info_set_algo_from_str (TokenInfo * token_info , FuriString * str ) {
44
+ if (furi_string_cmpi_str (str , TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME ) == 0 ) {
44
45
token_info -> algo = SHA1 ;
45
- } else if (string_cmpi_str (str , TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME )) {
46
+ } else if (furi_string_cmpi_str (str , TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME )) {
46
47
token_info -> algo = SHA256 ;
47
- } else if (string_cmpi_str (str , TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME )) {
48
+ } else if (furi_string_cmpi_str (str , TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME )) {
48
49
token_info -> algo = SHA512 ;
49
50
}
50
51
}
@@ -88,37 +89,36 @@ FlipperFormat* totp_open_config_file(Storage* storage) {
88
89
flipper_format_write_comment_cstr (fff_data_file , " " );
89
90
flipper_format_write_comment_cstr (fff_data_file , "Timezone offset in hours. Important note: do not put '+' sign for positive values" );
90
91
flipper_format_write_float (fff_data_file , TOTP_CONFIG_KEY_TIMEZONE , & tmp_tz , 1 );
91
- string_t temp_str ;
92
- string_init (temp_str );
92
+ FuriString * temp_str = furi_string_alloc ();
93
93
94
94
flipper_format_write_comment_cstr (fff_data_file , " " );
95
95
flipper_format_write_comment_cstr (fff_data_file , "=== TOKEN SAMPLE BEGIN ===" );
96
96
flipper_format_write_comment_cstr (fff_data_file , " " );
97
97
flipper_format_write_comment_cstr (fff_data_file , "# Token name which will be visible in the UI." );
98
- string_printf (temp_str , "%s: Sample token name" , TOTP_CONFIG_KEY_TOKEN_NAME );
98
+ furi_string_printf (temp_str , "%s: Sample token name" , TOTP_CONFIG_KEY_TOKEN_NAME );
99
99
flipper_format_write_comment (fff_data_file , temp_str );
100
100
flipper_format_write_comment_cstr (fff_data_file , " " );
101
101
102
102
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" );
103
- string_printf (temp_str , "%s: plaintokensecret" , TOTP_CONFIG_KEY_TOKEN_SECRET );
103
+ furi_string_printf (temp_str , "%s: plaintokensecret" , TOTP_CONFIG_KEY_TOKEN_SECRET );
104
104
flipper_format_write_comment (fff_data_file , temp_str );
105
105
flipper_format_write_comment_cstr (fff_data_file , " " );
106
106
107
- 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 );
107
+ 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 );
108
108
flipper_format_write_comment (fff_data_file , temp_str );
109
- string_printf (temp_str , "%s: %s" , TOTP_CONFIG_KEY_TOKEN_ALGO , TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME );
109
+ furi_string_printf (temp_str , "%s: %s" , TOTP_CONFIG_KEY_TOKEN_ALGO , TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME );
110
110
flipper_format_write_comment (fff_data_file , temp_str );
111
111
flipper_format_write_comment_cstr (fff_data_file , " " );
112
112
113
113
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" );
114
- string_printf (temp_str , "%s: 6" , TOTP_CONFIG_KEY_TOKEN_DIGITS );
114
+ furi_string_printf (temp_str , "%s: 6" , TOTP_CONFIG_KEY_TOKEN_DIGITS );
115
115
flipper_format_write_comment (fff_data_file , temp_str );
116
116
flipper_format_write_comment_cstr (fff_data_file , " " );
117
117
118
118
flipper_format_write_comment_cstr (fff_data_file , "=== TOKEN SAMPLE END ===" );
119
119
flipper_format_write_comment_cstr (fff_data_file , " " );
120
120
121
- string_clear (temp_str );
121
+ furi_string_free (temp_str );
122
122
if (!flipper_format_rewind (fff_data_file )) {
123
123
totp_close_config_file (fff_data_file );
124
124
FURI_LOG_E (LOGGING_TAG , "Rewind error" );
@@ -163,13 +163,12 @@ void totp_config_file_load_base(PluginState* const plugin_state) {
163
163
164
164
plugin_state -> timezone_offset = 0 ;
165
165
166
- string_t temp_str ;
167
- string_init (temp_str );
166
+ FuriString * temp_str = furi_string_alloc ();
168
167
169
168
uint32_t file_version ;
170
169
if (!flipper_format_read_header (fff_data_file , temp_str , & file_version )) {
171
170
FURI_LOG_E (LOGGING_TAG , "Missing or incorrect header" );
172
- string_clear (temp_str );
171
+ furi_string_free (temp_str );
173
172
return ;
174
173
}
175
174
@@ -227,7 +226,7 @@ void totp_config_file_load_base(PluginState* const plugin_state) {
227
226
FURI_LOG_D (LOGGING_TAG , "Missing timezone offset information, defaulting to 0" );
228
227
}
229
228
230
- string_clear (temp_str );
229
+ furi_string_free (temp_str );
231
230
totp_close_config_file (fff_data_file );
232
231
totp_close_storage ();
233
232
}
@@ -236,13 +235,12 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
236
235
Storage * storage = totp_open_storage ();
237
236
FlipperFormat * fff_data_file = totp_open_config_file (storage );
238
237
239
- string_t temp_str ;
238
+ FuriString * temp_str = furi_string_alloc () ;
240
239
uint32_t temp_data32 ;
241
- string_init (temp_str );
242
240
243
241
if (!flipper_format_read_header (fff_data_file , temp_str , & temp_data32 )) {
244
242
FURI_LOG_E (LOGGING_TAG , "Missing or incorrect header" );
245
- string_clear (temp_str );
243
+ furi_string_free (temp_str );
246
244
return ;
247
245
}
248
246
@@ -256,7 +254,7 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
256
254
257
255
TokenInfo * tokenInfo = token_info_alloc ();
258
256
259
- const char * temp_cstr = string_get_cstr (temp_str );
257
+ const char * temp_cstr = furi_string_get_cstr (temp_str );
260
258
tokenInfo -> name = (char * )malloc (strlen (temp_cstr ) + 1 );
261
259
strcpy (tokenInfo -> name , temp_cstr );
262
260
@@ -272,7 +270,7 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
272
270
continue ;
273
271
}
274
272
275
- temp_cstr = string_get_cstr (temp_str );
273
+ temp_cstr = furi_string_get_cstr (temp_str );
276
274
token_info_set_secret (tokenInfo , temp_cstr , strlen (temp_cstr ), & plugin_state -> iv [0 ]);
277
275
has_any_plain_secret = true;
278
276
FURI_LOG_W (LOGGING_TAG , "Found token with plain secret" );
@@ -315,7 +313,7 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
315
313
316
314
FURI_LOG_D (LOGGING_TAG , "Found %d tokens" , index );
317
315
318
- string_clear (temp_str );
316
+ furi_string_free (temp_str );
319
317
totp_close_config_file (fff_data_file );
320
318
totp_close_storage ();
321
319
0 commit comments