Skip to content

Commit 5aff2f0

Browse files
authored
Refactoring. Dropping useless methods #120 (#121)
1 parent b4e434b commit 5aff2f0

27 files changed

+40
-110
lines changed

features_config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#define TOTP_AUTOMATION_ICONS_ENABLED
66

77
// List of compatible firmwares
8-
#define TOTP_FIRMWARE_OFFICIAL_STABLE 1
9-
#define TOTP_FIRMWARE_OFFICIAL_DEV 2
10-
#define TOTP_FIRMWARE_XTREME 3
8+
#define TOTP_FIRMWARE_OFFICIAL_STABLE (1)
9+
#define TOTP_FIRMWARE_OFFICIAL_DEV (2)
10+
#define TOTP_FIRMWARE_XTREME (3)
1111
// End of list
1212

1313
// Target firmware to build for

lib/base32/base32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#pragma once
2929

30-
#include <stdlib.h>
30+
#include <stddef.h>
3131
#include <stdint.h>
3232

3333
/**

lib/base64/base64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static const uint8_t dtable[] = {0x3e, 0x80, 0x80, 0x80, 0x3f, 0x34, 0x35, 0x36,
2222
0x80, 0x80, 0x80, 0x80, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2323
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
2424
0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33};
25-
// "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
25+
2626
static uint8_t get_dtable_value(uint8_t index) {
2727
return (index < 43 || index > 122) ? 0x80 : dtable[index - 43];
2828
}

services/config/constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#define CONFIG_FILE_HEADER "Flipper TOTP plugin config file"
4-
#define CONFIG_FILE_ACTUAL_VERSION 4
4+
#define CONFIG_FILE_ACTUAL_VERSION (4)
55

66
#define TOTP_CONFIG_KEY_TIMEZONE "Timezone"
77
#define TOTP_CONFIG_KEY_TOKEN_NAME "TokenName"

services/crypto/crypto.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#include "../../types/common.h"
66
#include "memset_s.h"
77

8-
#define CRYPTO_KEY_SLOT 2
8+
#define CRYPTO_KEY_SLOT (2)
99
#define CRYPTO_VERIFY_KEY "FFF_Crypto_pass"
10-
#define CRYPTO_VERIFY_KEY_LENGTH 16
11-
#define CRYPTO_ALIGNMENT_FACTOR 16
10+
#define CRYPTO_VERIFY_KEY_LENGTH (16)
11+
#define CRYPTO_ALIGNMENT_FACTOR (16)
1212

1313
uint8_t* totp_crypto_encrypt(
1414
const uint8_t* plain_data,

services/hmac/hmac_common.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99
#define _GLHMAC_CONCAT_(prefix, suffix) prefix##suffix
1010
#define _GLHMAC_CONCAT(prefix, suffix) _GLHMAC_CONCAT_(prefix, suffix)
1111

12-
#if GL_HMAC_NAME == 5
13-
#define HMAC_ALG md5
14-
#else
1512
#define HMAC_ALG _GLHMAC_CONCAT(sha, GL_HMAC_NAME)
16-
#endif
1713

1814
#define GL_HMAC_CTX _GLHMAC_CONCAT(HMAC_ALG, _ctx)
1915
#define GL_HMAC_FN _GLHMAC_CONCAT(hmac_, HMAC_ALG)

totp_app.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "services/crypto/crypto.h"
2222
#include "cli/cli.h"
2323

24-
#define IDLE_TIMEOUT 60000
24+
#define IDLE_TIMEOUT (60000)
2525

2626
static void render_callback(Canvas* const canvas, void* ctx) {
2727
furi_assert(ctx);
@@ -97,6 +97,7 @@ static bool totp_plugin_state_init(PluginState* const plugin_state) {
9797
plugin_state->gui = furi_record_open(RECORD_GUI);
9898
plugin_state->notification_app = furi_record_open(RECORD_NOTIFICATION);
9999
plugin_state->dialogs_app = furi_record_open(RECORD_DIALOGS);
100+
memset(&plugin_state->iv[0], 0, TOTP_IV_SIZE);
100101

101102
if(totp_config_file_load_base(plugin_state) != TotpConfigFileOpenSuccess) {
102103
totp_dialogs_config_loading_error(plugin_state);
@@ -162,7 +163,7 @@ int32_t totp_app() {
162163
}
163164

164165
TotpCliContext* cli_context = totp_cli_register_command_handler(plugin_state, event_queue);
165-
totp_scene_director_init_scenes(plugin_state);
166+
166167
if(!totp_activate_initial_scene(plugin_state)) {
167168
FURI_LOG_E(LOGGING_TAG, "An error ocurred during activating initial scene\r\n");
168169
totp_plugin_state_free(plugin_state);
@@ -210,7 +211,6 @@ int32_t totp_app() {
210211

211212
totp_cli_unregister_command_handler(cli_context);
212213
totp_scene_director_deactivate_active_scene(plugin_state);
213-
totp_scene_director_dispose(plugin_state);
214214

215215
view_port_enabled_set(view_port, false);
216216
gui_remove_view_port(plugin_state->gui, view_port);

types/plugin_state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "../workers/bt_type_code/bt_type_code.h"
1313
#endif
1414

15-
#define TOTP_IV_SIZE 16
15+
#define TOTP_IV_SIZE (16)
1616

1717
/**
1818
* @brief Application state structure

types/token_info.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
#include <stdbool.h>
55
#include <furi/furi.h>
66

7-
#define TOTP_TOKEN_DURATION_DEFAULT 30
7+
#define TOTP_TOKEN_DURATION_DEFAULT (30)
88

99
#define TOTP_TOKEN_ALGO_SHA1_NAME "sha1"
1010
#define TOTP_TOKEN_ALGO_STEAM_NAME "steam"
1111
#define TOTP_TOKEN_ALGO_SHA256_NAME "sha256"
1212
#define TOTP_TOKEN_ALGO_SHA512_NAME "sha512"
13-
#define TOTP_TOKEN_MAX_LENGTH 255
13+
#define TOTP_TOKEN_MAX_LENGTH (255)
1414

1515
#define PLAIN_TOKEN_ENCODING_BASE32_NAME "base32"
1616
#define PLAIN_TOKEN_ENCODING_BASE64_NAME "base64"
@@ -95,12 +95,23 @@ enum TokenAutomationFeatures {
9595
TOKEN_AUTOMATION_FEATURE_TYPE_SLOWER = 0b100
9696
};
9797

98+
/**
99+
* @brief Plain token secret encodings.
100+
*/
98101
enum PlainTokenSecretEncodings {
102+
103+
/**
104+
* @brief Base32 encoding
105+
*/
99106
PLAIN_TOKEN_ENCODING_BASE32 = 0,
107+
108+
/**
109+
* @brief Base64 encoding
110+
*/
100111
PLAIN_TOKEN_ENCODING_BASE64 = 1
101112
};
102113

103-
#define TOTP_TOKEN_DIGITS_MAX_COUNT 8
114+
#define TOTP_TOKEN_DIGITS_MAX_COUNT (8)
104115

105116
/**
106117
* @brief TOTP token information

ui/constants.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#define SCREEN_WIDTH 128
4-
#define SCREEN_HEIGHT 64
3+
#define SCREEN_WIDTH (128)
4+
#define SCREEN_HEIGHT (64)
55
#define SCREEN_WIDTH_CENTER (SCREEN_WIDTH >> 1)
66
#define SCREEN_HEIGHT_CENTER (SCREEN_HEIGHT >> 1)

0 commit comments

Comments
 (0)