Merge branch 'UNLEASHED' into 420
@@ -9,5 +9,5 @@ App(
|
||||
order=180,
|
||||
fap_icon="rfid_10px.png",
|
||||
fap_category="Tools",
|
||||
fap_icon_assets="icons",
|
||||
fap_icon_assets="images",
|
||||
)
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <toolbox/stream/file_stream.h>
|
||||
#include <toolbox/stream/buffered_file_stream.h>
|
||||
|
||||
#include <RFID_Fuzzer_icons.h>
|
||||
|
||||
#include <lib/lfrfid/lfrfid_worker.h>
|
||||
#include <lfrfid/protocols/lfrfid_protocols.h>
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 308 B |
@@ -9,5 +9,5 @@ App(
|
||||
order=175,
|
||||
fap_icon="i2ctools.png",
|
||||
fap_category="GPIO",
|
||||
fap_icon_assets="icons",
|
||||
fap_icon_assets="images",
|
||||
)
|
||||
|
After Width: | Height: | Size: 102 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 102 B |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
@@ -1,5 +1,4 @@
|
||||
#include "main_view.h"
|
||||
#include "i2cTools_icons.h"
|
||||
|
||||
void draw_main_view(Canvas* canvas, i2cMainView* main_view) {
|
||||
canvas_clear(canvas);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include <gui/gui.h>
|
||||
#include <i2cTools_icons.h>
|
||||
|
||||
#define APP_NAME "I2C Tools"
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "scanner_view.h"
|
||||
#include "i2cTools_icons.h"
|
||||
|
||||
void draw_scanner_view(Canvas* canvas, i2cScanner* i2c_scanner) {
|
||||
canvas_clear(canvas);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <furi_hal.h>
|
||||
#include <gui/gui.h>
|
||||
|
||||
#include <i2cTools_icons.h>
|
||||
|
||||
#include "../i2cscanner.h"
|
||||
|
||||
#define SCAN_MENU_TEXT "Scan"
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <furi_hal.h>
|
||||
#include <gui/gui.h>
|
||||
|
||||
#include <i2cTools_icons.h>
|
||||
|
||||
#include "../i2csender.h"
|
||||
|
||||
#define SEND_MENU_TEXT "Send"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "sniffer_view.h"
|
||||
#include "i2cTools_icons.h"
|
||||
|
||||
void draw_sniffer_view(Canvas* canvas, i2cSniffer* i2c_sniffer) {
|
||||
canvas_clear(canvas);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <furi_hal.h>
|
||||
#include <gui/gui.h>
|
||||
|
||||
#include <i2cTools_icons.h>
|
||||
|
||||
#include "../i2csniffer.h"
|
||||
|
||||
#define SNIFF_MENU_TEXT "Sniff"
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
@@ -3,6 +3,8 @@
|
||||
A simple Flipper Zero application for NMEA 0183 serial GPS modules, such as the
|
||||
[Adafruit Ultimate GPS Breakout].
|
||||
|
||||
[Original link](https://github.com/ezod/flipperzero-gps)
|
||||
|
||||

|
||||
|
||||
Heavy lifting (NMEA parsing) provided by [minmea], which is included in this
|
||||
@@ -15,14 +17,6 @@ Connect the GPS module to power and the USART using GPIO pins 9 (3.3V), 11
|
||||
|
||||

|
||||
|
||||
## Building the FAP
|
||||
|
||||
1. Clone the [flipperzero-firmware] repository.
|
||||
2. Create a symbolic link in `applications_user` named `gps`, pointing to this
|
||||
repository.
|
||||
3. Compile with `./fbt fap_gps`.
|
||||
4. Copy `build/f7-firmware-D/.extapps/gps.fap` to `apps/Tools` on the SD card
|
||||
(directly or using [qFlipper]).
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ App(
|
||||
],
|
||||
fap_icon="metronome_icon.png",
|
||||
fap_category="Music",
|
||||
fap_icon_assets="images",
|
||||
stack_size=2 * 1024,
|
||||
fap_icon_assets="icons",
|
||||
order=20,
|
||||
|
||||
|
After Width: | Height: | Size: 102 B |
@@ -12,5 +12,5 @@ App(
|
||||
order=50,
|
||||
fap_icon="mouse_10px.png",
|
||||
fap_category="GPIO",
|
||||
fap_icon_assets="icons",
|
||||
fap_icon_assets="images",
|
||||
)
|
||||
|
||||
|
After Width: | Height: | Size: 576 B |
|
After Width: | Height: | Size: 299 B |
@@ -12,8 +12,8 @@ App(
|
||||
stack_size=2 * 1024,
|
||||
order=45,
|
||||
fap_icon="icons/music_10px.png",
|
||||
fap_category="Music",
|
||||
fap_icon_assets="icons",
|
||||
fap_category="Music",
|
||||
)
|
||||
|
||||
App(
|
||||
|
||||
@@ -9,4 +9,5 @@ App(
|
||||
order=200,
|
||||
fap_icon="playlist_10px.png",
|
||||
fap_category="Tools",
|
||||
fap_icon_assets="images",
|
||||
)
|
||||
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 299 B |
@@ -6,7 +6,7 @@
|
||||
#include <storage/storage.h>
|
||||
|
||||
#include <lib/toolbox/path.h>
|
||||
#include <assets_icons.h>
|
||||
#include <SubGHz_Playlist_icons.h>
|
||||
|
||||
#include <lib/subghz/protocols/protocol_items.h>
|
||||
#include <flipper_format/flipper_format_i.h>
|
||||
|
||||
@@ -15,6 +15,6 @@ App(
|
||||
stack_size=2 * 1024,
|
||||
order=20,
|
||||
fap_category="Misc",
|
||||
fap_icon="totp_10px.png",
|
||||
fap_icon_assets="icons",
|
||||
fap_icon_assets="images",
|
||||
fap_icon="totp_10px.png"
|
||||
)
|
||||
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -2,6 +2,16 @@
|
||||
#include <gui/view_i.h>
|
||||
#include "../../types/common.h"
|
||||
|
||||
size_t strnlen(const char* s, size_t maxlen) {
|
||||
size_t len;
|
||||
|
||||
for(len = 0; len < maxlen; len++, s++) {
|
||||
if(!*s) break;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void view_draw(View* view, Canvas* canvas) {
|
||||
furi_assert(view);
|
||||
if(view->draw_callback) {
|
||||
@@ -32,10 +42,14 @@ static void commit_text_input_callback(void* context) {
|
||||
InputTextSceneState* text_input_state = (InputTextSceneState*)context;
|
||||
if(text_input_state->callback != 0) {
|
||||
InputTextSceneCallbackResult* result = malloc(sizeof(InputTextSceneCallbackResult));
|
||||
result->user_input_length = strlen(text_input_state->text_input_buffer);
|
||||
result->user_input_length =
|
||||
strnlen(text_input_state->text_input_buffer, INPUT_BUFFER_SIZE);
|
||||
result->user_input = malloc(result->user_input_length + 1);
|
||||
result->callback_data = text_input_state->callback_data;
|
||||
strcpy(result->user_input, text_input_state->text_input_buffer);
|
||||
strlcpy(
|
||||
result->user_input,
|
||||
text_input_state->text_input_buffer,
|
||||
result->user_input_length + 1);
|
||||
text_input_state->callback(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
typedef struct {
|
||||
char* user_input;
|
||||
uint8_t user_input_length;
|
||||
size_t user_input_length;
|
||||
void* callback_data;
|
||||
} InputTextSceneCallbackResult;
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
char* token_name;
|
||||
uint8_t token_name_length;
|
||||
size_t token_name_length;
|
||||
char* token_secret;
|
||||
uint8_t token_secret_length;
|
||||
size_t token_secret_length;
|
||||
bool saved;
|
||||
Control selected_control;
|
||||
InputTextSceneContext* token_name_input_context;
|
||||
@@ -35,12 +35,12 @@ typedef struct {
|
||||
InputTextSceneState* input_state;
|
||||
uint32_t input_started_at;
|
||||
int16_t current_token_index;
|
||||
int32_t screen_y_offset;
|
||||
int16_t screen_y_offset;
|
||||
TokenHashAlgo algo;
|
||||
TokenDigitsCount digits_count;
|
||||
} 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);
|
||||
}
|
||||
|
||||
@@ -235,7 +235,10 @@ bool totp_scene_add_new_token_handle_event(PluginEvent* const event, PluginState
|
||||
|
||||
if(token_secret_set) {
|
||||
tokenInfo->name = malloc(scene_state->token_name_length + 1);
|
||||
strcpy(tokenInfo->name, scene_state->token_name);
|
||||
strlcpy(
|
||||
tokenInfo->name,
|
||||
scene_state->token_name,
|
||||
scene_state->token_name_length + 1);
|
||||
tokenInfo->algo = scene_state->algo;
|
||||
tokenInfo->digits = scene_state->digits_count;
|
||||
|
||||
@@ -308,6 +311,6 @@ void totp_scene_add_new_token_deactivate(PluginState* plugin_state) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ typedef struct {
|
||||
uint8_t current_token_index;
|
||||
} 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(
|
||||
PluginState* plugin_state,
|
||||
const TokenAddEditSceneContext* context);
|
||||
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);
|
||||
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);
|
||||
|
||||
@@ -16,7 +16,7 @@ typedef struct {
|
||||
Control selected_control;
|
||||
} SceneState;
|
||||
|
||||
void totp_scene_app_settings_init(PluginState* plugin_state) {
|
||||
void totp_scene_app_settings_init(const PluginState* 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) {
|
||||
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_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, "Timezone offset");
|
||||
@@ -90,7 +90,9 @@ void totp_scene_app_settings_render(Canvas* const canvas, PluginState* plugin_st
|
||||
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) {
|
||||
SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
|
||||
if(event->input.type == InputTypePress) {
|
||||
@@ -171,6 +173,6 @@ void totp_scene_app_settings_deactivate(PluginState* plugin_state) {
|
||||
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);
|
||||
}
|
||||
@@ -10,11 +10,13 @@ typedef struct {
|
||||
uint8_t current_token_index;
|
||||
} 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(
|
||||
PluginState* plugin_state,
|
||||
const AppSettingsSceneContext* context);
|
||||
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_free(PluginState* plugin_state);
|
||||
void totp_scene_app_settings_free(const PluginState* plugin_state);
|
||||
@@ -29,7 +29,7 @@ void totp_scene_authenticate_activate(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;
|
||||
if(scene_state->code_length > 0) {
|
||||
@@ -74,7 +74,9 @@ 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->input.type == InputTypeLong && event->input.key == InputKeyBack) {
|
||||
return false;
|
||||
@@ -157,6 +159,6 @@ void totp_scene_authenticate_deactivate(PluginState* plugin_state) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
void totp_scene_authenticate_init(PluginState* plugin_state);
|
||||
void totp_scene_authenticate_activate(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_free(PluginState* plugin_state);
|
||||
void totp_scene_authenticate_free(const PluginState* plugin_state);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "../../services/totp/totp.h"
|
||||
#include "../../services/config/config.h"
|
||||
#include "../../services/crypto/crypto.h"
|
||||
#include "../../services/crypto/memset_s.h"
|
||||
#include "../scene_director.h"
|
||||
#include "../token_menu/totp_scene_token_menu.h"
|
||||
|
||||
@@ -95,7 +96,7 @@ void update_totp_params(PluginState* const plugin_state) {
|
||||
}
|
||||
}
|
||||
|
||||
void totp_scene_generate_token_init(PluginState* plugin_state) {
|
||||
void totp_scene_generate_token_init(const PluginState* plugin_state) {
|
||||
UNUSED(plugin_state);
|
||||
}
|
||||
|
||||
@@ -180,7 +181,7 @@ void totp_scene_generate_token_render(Canvas* const canvas, PluginState* plugin_
|
||||
->data);
|
||||
|
||||
if(tokenInfo->token != NULL && tokenInfo->token_length > 0) {
|
||||
uint8_t key_length;
|
||||
size_t key_length;
|
||||
uint8_t* key = totp_crypto_decrypt(
|
||||
tokenInfo->token, tokenInfo->token_length, &plugin_state->iv[0], &key_length);
|
||||
|
||||
@@ -195,7 +196,7 @@ void totp_scene_generate_token_render(Canvas* const canvas, PluginState* plugin_
|
||||
TOKEN_LIFETIME),
|
||||
scene_state->last_code,
|
||||
tokenInfo->digits);
|
||||
memset(key, 0, key_length);
|
||||
memset_s(key, sizeof(key), 0, key_length);
|
||||
free(key);
|
||||
} else {
|
||||
i_token_to_str(0, scene_state->last_code, tokenInfo->digits);
|
||||
@@ -265,7 +266,9 @@ void totp_scene_generate_token_render(Canvas* const canvas, PluginState* plugin_
|
||||
}
|
||||
}
|
||||
|
||||
bool totp_scene_generate_token_handle_event(PluginEvent* const event, PluginState* plugin_state) {
|
||||
bool totp_scene_generate_token_handle_event(
|
||||
const PluginEvent* const event,
|
||||
PluginState* plugin_state) {
|
||||
if(event->type == EventTypeKey) {
|
||||
if(event->input.type == InputTypeLong && event->input.key == InputKeyBack) {
|
||||
return false;
|
||||
@@ -314,11 +317,10 @@ void totp_scene_generate_token_deactivate(PluginState* plugin_state) {
|
||||
if(plugin_state->current_scene_state == NULL) return;
|
||||
SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
|
||||
|
||||
free(scene_state->last_code);
|
||||
free(scene_state);
|
||||
plugin_state->current_scene_state = NULL;
|
||||
}
|
||||
|
||||
void totp_scene_generate_token_free(PluginState* plugin_state) {
|
||||
void totp_scene_generate_token_free(const PluginState* plugin_state) {
|
||||
UNUSED(plugin_state);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,13 @@ typedef struct {
|
||||
uint8_t current_token_index;
|
||||
} GenerateTokenSceneContext;
|
||||
|
||||
void totp_scene_generate_token_init(PluginState* plugin_state);
|
||||
void totp_scene_generate_token_init(const PluginState* plugin_state);
|
||||
void totp_scene_generate_token_activate(
|
||||
PluginState* plugin_state,
|
||||
const GenerateTokenSceneContext* context);
|
||||
void totp_scene_generate_token_render(Canvas* const canvas, PluginState* plugin_state);
|
||||
bool totp_scene_generate_token_handle_event(PluginEvent* const event, PluginState* plugin_state);
|
||||
bool totp_scene_generate_token_handle_event(
|
||||
const PluginEvent* const event,
|
||||
PluginState* plugin_state);
|
||||
void totp_scene_generate_token_deactivate(PluginState* plugin_state);
|
||||
void totp_scene_generate_token_free(PluginState* plugin_state);
|
||||
void totp_scene_generate_token_free(const PluginState* plugin_state);
|
||||
|
||||
@@ -88,7 +88,7 @@ void totp_scene_director_render(Canvas* const canvas, PluginState* const plugin_
|
||||
}
|
||||
}
|
||||
|
||||
void totp_scene_director_dispose(PluginState* const plugin_state) {
|
||||
void totp_scene_director_dispose(const PluginState* const plugin_state) {
|
||||
totp_scene_generate_token_free(plugin_state);
|
||||
totp_scene_authenticate_free(plugin_state);
|
||||
totp_scene_add_new_token_free(plugin_state);
|
||||
|
||||
@@ -12,5 +12,5 @@ void totp_scene_director_activate_scene(
|
||||
void totp_scene_director_deactivate_active_scene(PluginState* const plugin_state);
|
||||
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);
|
||||
void totp_scene_director_dispose(const PluginState* const plugin_state);
|
||||
bool totp_scene_director_handle_event(PluginEvent* const event, PluginState* const plugin_state);
|
||||
|
||||
@@ -21,7 +21,7 @@ typedef struct {
|
||||
int16_t current_token_index;
|
||||
} SceneState;
|
||||
|
||||
void totp_scene_token_menu_init(PluginState* plugin_state) {
|
||||
void totp_scene_token_menu_init(const PluginState* 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) {
|
||||
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) {
|
||||
ui_control_button_render(
|
||||
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) {
|
||||
SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
|
||||
if(event->input.type == InputTypePress) {
|
||||
@@ -192,6 +192,6 @@ void totp_scene_token_menu_deactivate(PluginState* plugin_state) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ typedef struct {
|
||||
uint8_t current_token_index;
|
||||
} 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(
|
||||
PluginState* plugin_state,
|
||||
const TokenMenuSceneContext* context);
|
||||
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_free(PluginState* plugin_state);
|
||||
void totp_scene_token_menu_free(const PluginState* plugin_state);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "commands/timezone/timezone.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(
|
||||
"Command \"%s\" is unknown. Use \"" TOTP_CLI_COMMAND_HELP
|
||||
"\" command to get list of available commands.",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "cli_helpers.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) {
|
||||
TOTP_CLI_PRINTF("Pleases enter PIN on your flipper device\r\n");
|
||||
|
||||
@@ -11,7 +11,6 @@ bool totp_cli_ensure_authenticated(PluginState* plugin_state, Cli* cli) {
|
||||
}
|
||||
|
||||
TOTP_CLI_DELETE_LAST_LINE();
|
||||
fflush(stdout);
|
||||
|
||||
if(plugin_state->current_scene == TotpSceneAuthentication) {
|
||||
return false;
|
||||
|
||||
@@ -13,16 +13,28 @@
|
||||
#define DOCOPT_OPTIONS "[options]"
|
||||
#define DOCOPT_DEFAULT(val) "[default: " val "]"
|
||||
|
||||
#define TOTP_CLI_PRINTF(format, ...) \
|
||||
_Pragma(STRINGIFY(GCC diagnostic push)); \
|
||||
_Pragma(STRINGIFY(GCC diagnostic ignored "-Wdouble-promotion")); \
|
||||
printf(format, ##__VA_ARGS__); \
|
||||
_Pragma(STRINGIFY(GCC diagnostic pop));
|
||||
#define TOTP_CLI_PRINTF(format, ...) \
|
||||
do { \
|
||||
_Pragma(STRINGIFY(GCC diagnostic push)) \
|
||||
_Pragma(STRINGIFY(GCC diagnostic ignored "-Wdouble-promotion")) \
|
||||
printf(format, ##__VA_ARGS__); \
|
||||
_Pragma(STRINGIFY(GCC diagnostic pop)) \
|
||||
} while(false)
|
||||
|
||||
#define TOTP_CLI_DELETE_LAST_LINE() \
|
||||
TOTP_CLI_PRINTF("\033[A\33[2K\r"); \
|
||||
fflush(stdout)
|
||||
|
||||
#define TOTP_CLI_DELETE_CURRENT_LINE() \
|
||||
TOTP_CLI_PRINTF("\33[2K\r"); \
|
||||
fflush(stdout)
|
||||
|
||||
#define TOTP_CLI_DELETE_LAST_CHAR() \
|
||||
TOTP_CLI_PRINTF("\b \b"); \
|
||||
fflush(stdout)
|
||||
|
||||
#define TOTP_CLI_DELETE_LAST_LINE() TOTP_CLI_PRINTF("\033[A\33[2K\r")
|
||||
#define TOTP_CLI_DELETE_CURRENT_LINE() TOTP_CLI_PRINTF("\33[2K\r")
|
||||
#define TOTP_CLI_PRINT_INVALID_ARGUMENTS() \
|
||||
TOTP_CLI_PRINTF( \
|
||||
"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);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX "-d"
|
||||
#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)) {
|
||||
case '6':
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
token_info->algo = SHA1;
|
||||
return true;
|
||||
@@ -79,10 +79,16 @@ void totp_cli_command_add_docopt_options() {
|
||||
TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX) " Show console user input as-is without masking\r\n");
|
||||
}
|
||||
|
||||
static void furi_string_secure_free(FuriString* str) {
|
||||
for(long i = furi_string_size(str) - 1; i >= 0; i--) {
|
||||
furi_string_set_char(str, i, '\0');
|
||||
}
|
||||
|
||||
furi_string_free(str);
|
||||
}
|
||||
|
||||
void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cli* cli) {
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
const char* temp_cstr;
|
||||
|
||||
TokenInfo* token_info = token_info_alloc();
|
||||
|
||||
// Reading token name
|
||||
@@ -93,9 +99,9 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl
|
||||
return;
|
||||
}
|
||||
|
||||
temp_cstr = furi_string_get_cstr(temp_str);
|
||||
token_info->name = malloc(strlen(temp_cstr) + 1);
|
||||
strcpy(token_info->name, temp_cstr);
|
||||
size_t temp_cstr_len = furi_string_size(temp_str);
|
||||
token_info->name = malloc(temp_cstr_len + 1);
|
||||
strlcpy(token_info->name, furi_string_get_cstr(temp_str), temp_cstr_len + 1);
|
||||
|
||||
// Read optional arguments
|
||||
bool mask_user_input = true;
|
||||
@@ -146,13 +152,15 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl
|
||||
uint8_t c;
|
||||
while(cli_read(cli, &c, 1) == 1) {
|
||||
if(c == CliSymbolAsciiEsc) {
|
||||
// Some keys generating escape-sequences
|
||||
// We need to ignore them as we case about alpha-numerics only
|
||||
uint8_t c2;
|
||||
cli_read_timeout(cli, &c2, 1, 0);
|
||||
cli_read_timeout(cli, &c2, 1, 0);
|
||||
} else if(c == CliSymbolAsciiETX) {
|
||||
TOTP_CLI_DELETE_CURRENT_LINE();
|
||||
TOTP_CLI_PRINTF("Cancelled by user");
|
||||
furi_string_free(temp_str);
|
||||
TOTP_CLI_PRINTF("Cancelled by user\r\n");
|
||||
furi_string_secure_free(temp_str);
|
||||
token_info_free(token_info);
|
||||
return;
|
||||
} else if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
|
||||
@@ -166,8 +174,7 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl
|
||||
} else if(c == CliSymbolAsciiBackspace || c == CliSymbolAsciiDel) {
|
||||
size_t temp_str_size = furi_string_size(temp_str);
|
||||
if(temp_str_size > 0) {
|
||||
TOTP_CLI_PRINTF("\b \b");
|
||||
fflush(stdout);
|
||||
TOTP_CLI_DELETE_LAST_CHAR();
|
||||
furi_string_left(temp_str, temp_str_size - 1);
|
||||
}
|
||||
} else if(c == CliSymbolAsciiCR) {
|
||||
@@ -176,25 +183,26 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl
|
||||
}
|
||||
}
|
||||
|
||||
temp_cstr = furi_string_get_cstr(temp_str);
|
||||
|
||||
TOTP_CLI_DELETE_LAST_LINE();
|
||||
|
||||
if(!totp_cli_ensure_authenticated(plugin_state, cli)) {
|
||||
furi_string_free(temp_str);
|
||||
furi_string_secure_free(temp_str);
|
||||
token_info_free(token_info);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!token_info_set_secret(token_info, temp_cstr, strlen(temp_cstr), plugin_state->iv)) {
|
||||
if(!token_info_set_secret(
|
||||
token_info,
|
||||
furi_string_get_cstr(temp_str),
|
||||
furi_string_size(temp_str),
|
||||
plugin_state->iv)) {
|
||||
TOTP_CLI_PRINTF("Token secret seems to be invalid and can not be parsed\r\n");
|
||||
furi_string_free(temp_str);
|
||||
furi_string_secure_free(temp_str);
|
||||
token_info_free(token_info);
|
||||
return;
|
||||
}
|
||||
|
||||
furi_string_reset(temp_str);
|
||||
furi_string_free(temp_str);
|
||||
furi_string_secure_free(temp_str);
|
||||
|
||||
bool load_generate_token_scene = false;
|
||||
if(plugin_state->current_scene == TotpSceneGenerateToken) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define CONFIG_FILE_PATH CONFIG_FILE_DIRECTORY_PATH "/totp.conf"
|
||||
#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) {
|
||||
case TOTP_6_DIGITS:
|
||||
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) {
|
||||
case SHA1:
|
||||
return TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME;
|
||||
@@ -45,7 +45,7 @@ static char* token_info_get_algo_as_cstr(TokenInfo* token_info) {
|
||||
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) {
|
||||
token_info->algo = SHA1;
|
||||
} 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;
|
||||
}
|
||||
|
||||
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_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;
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
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);
|
||||
ListNode* node = plugin_state->tokens_list;
|
||||
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);
|
||||
node = node->next;
|
||||
}
|
||||
@@ -343,9 +343,9 @@ TokenLoadingResult totp_config_file_load_tokens(PluginState* const plugin_state)
|
||||
|
||||
TokenInfo* tokenInfo = token_info_alloc();
|
||||
|
||||
const char* temp_cstr = furi_string_get_cstr(temp_str);
|
||||
tokenInfo->name = (char*)malloc(strlen(temp_cstr) + 1);
|
||||
strcpy(tokenInfo->name, temp_cstr);
|
||||
size_t temp_cstr_len = furi_string_size(temp_str);
|
||||
tokenInfo->name = (char*)malloc(temp_cstr_len + 1);
|
||||
strlcpy(tokenInfo->name, furi_string_get_cstr(temp_str), temp_cstr_len + 1);
|
||||
|
||||
uint32_t secret_bytes_count;
|
||||
if(!flipper_format_get_value_count(
|
||||
@@ -355,9 +355,11 @@ TokenLoadingResult totp_config_file_load_tokens(PluginState* const plugin_state)
|
||||
|
||||
if(secret_bytes_count == 1) { // Plain secret key
|
||||
if(flipper_format_read_string(fff_data_file, TOTP_CONFIG_KEY_TOKEN_SECRET, temp_str)) {
|
||||
temp_cstr = furi_string_get_cstr(temp_str);
|
||||
if(token_info_set_secret(
|
||||
tokenInfo, temp_cstr, strlen(temp_cstr), &plugin_state->iv[0])) {
|
||||
tokenInfo,
|
||||
furi_string_get_cstr(temp_str),
|
||||
furi_string_size(temp_str),
|
||||
&plugin_state->iv[0])) {
|
||||
FURI_LOG_W(LOGGING_TAG, "Token \"%s\" has plain secret", tokenInfo->name);
|
||||
} else {
|
||||
tokenInfo->token = NULL;
|
||||
|
||||
@@ -16,8 +16,8 @@ Storage* totp_open_storage();
|
||||
void totp_close_storage();
|
||||
FlipperFormat* totp_open_config_file(Storage* storage);
|
||||
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);
|
||||
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);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <furi_hal.h>
|
||||
#include "../config/config.h"
|
||||
#include "../../types/common.h"
|
||||
#include "memset_s.h"
|
||||
|
||||
#define CRYPTO_KEY_SLOT 2
|
||||
#define CRYPTO_VERIFY_KEY "FFF_Crypto_pass"
|
||||
@@ -11,13 +12,13 @@
|
||||
|
||||
uint8_t* totp_crypto_encrypt(
|
||||
const uint8_t* plain_data,
|
||||
const uint8_t plain_data_length,
|
||||
const size_t plain_data_length,
|
||||
const uint8_t* iv,
|
||||
uint8_t* encrypted_data_length) {
|
||||
size_t* encrypted_data_length) {
|
||||
uint8_t* encrypted_data;
|
||||
size_t remain = plain_data_length % CRYPTO_ALIGNMENT_FACTOR;
|
||||
if(remain) {
|
||||
uint8_t plain_data_aligned_length = plain_data_length - remain + CRYPTO_ALIGNMENT_FACTOR;
|
||||
size_t plain_data_aligned_length = plain_data_length - remain + CRYPTO_ALIGNMENT_FACTOR;
|
||||
uint8_t* plain_data_aligned = malloc(plain_data_aligned_length);
|
||||
memset(plain_data_aligned, 0, plain_data_aligned_length);
|
||||
memcpy(plain_data_aligned, plain_data, plain_data_length);
|
||||
@@ -29,7 +30,7 @@ uint8_t* totp_crypto_encrypt(
|
||||
furi_hal_crypto_encrypt(plain_data_aligned, encrypted_data, plain_data_aligned_length);
|
||||
furi_hal_crypto_store_unload_key(CRYPTO_KEY_SLOT);
|
||||
|
||||
memset(plain_data_aligned, 0, plain_data_aligned_length);
|
||||
memset_s(plain_data_aligned, sizeof(plain_data_aligned), 0, plain_data_aligned_length);
|
||||
free(plain_data_aligned);
|
||||
} else {
|
||||
encrypted_data = malloc(plain_data_length);
|
||||
@@ -45,9 +46,9 @@ uint8_t* totp_crypto_encrypt(
|
||||
|
||||
uint8_t* totp_crypto_decrypt(
|
||||
const uint8_t* encrypted_data,
|
||||
const uint8_t encrypted_data_length,
|
||||
const size_t encrypted_data_length,
|
||||
const uint8_t* iv,
|
||||
uint8_t* decrypted_data_length) {
|
||||
size_t* decrypted_data_length) {
|
||||
*decrypted_data_length = encrypted_data_length;
|
||||
uint8_t* decrypted_data = malloc(*decrypted_data_length);
|
||||
furi_hal_crypto_store_load_key(CRYPTO_KEY_SLOT, iv);
|
||||
@@ -56,7 +57,7 @@ uint8_t* totp_crypto_decrypt(
|
||||
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) {
|
||||
FURI_LOG_D(LOGGING_TAG, "Generating new IV");
|
||||
furi_hal_random_fill_buf(&plugin_state->base_iv[0], TOTP_IV_SIZE);
|
||||
@@ -118,8 +119,8 @@ void totp_crypto_seed_iv(PluginState* plugin_state, uint8_t* pin, uint8_t pin_le
|
||||
}
|
||||
|
||||
bool totp_crypto_verify_key(const PluginState* plugin_state) {
|
||||
uint8_t decrypted_key_length;
|
||||
uint8_t* decrypted_key = totp_crypto_decrypt(
|
||||
size_t decrypted_key_length;
|
||||
const uint8_t* decrypted_key = totp_crypto_decrypt(
|
||||
plugin_state->crypto_verify_data,
|
||||
plugin_state->crypto_verify_data_length,
|
||||
&plugin_state->iv[0],
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
uint8_t* totp_crypto_encrypt(
|
||||
const uint8_t* plain_data,
|
||||
const uint8_t plain_data_length,
|
||||
const size_t plain_data_length,
|
||||
const uint8_t* iv,
|
||||
uint8_t* encrypted_data_length);
|
||||
size_t* encrypted_data_length);
|
||||
uint8_t* totp_crypto_decrypt(
|
||||
const uint8_t* encrypted_data,
|
||||
const uint8_t encrypted_data_length,
|
||||
const size_t encrypted_data_length,
|
||||
const uint8_t* iv,
|
||||
uint8_t* decrypted_data_length);
|
||||
void totp_crypto_seed_iv(PluginState* plugin_state, uint8_t* pin, uint8_t pin_length);
|
||||
size_t* decrypted_data_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);
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "memset_s.h"
|
||||
|
||||
#define RSIZE_MAX 0x7fffffffffffffffUL
|
||||
|
||||
errno_t memset_s(void* s, rsize_t smax, int c, rsize_t n) {
|
||||
if(!s || smax > RSIZE_MAX) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
errno_t violation_present = 0;
|
||||
if(n > smax) {
|
||||
n = smax;
|
||||
violation_present = EINVAL;
|
||||
}
|
||||
|
||||
volatile unsigned char* v = s;
|
||||
for(rsize_t i = 0u; i < n; ++i) {
|
||||
*v++ = (unsigned char)c;
|
||||
}
|
||||
|
||||
return violation_present;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef _RSIZE_T_DECLARED
|
||||
typedef uint64_t rsize_t;
|
||||
#define _RSIZE_T_DECLARED
|
||||
#endif
|
||||
#ifndef _ERRNOT_DECLARED
|
||||
typedef int16_t errno_t;
|
||||
#define _ERRNOT_DECLARED
|
||||
#endif
|
||||
|
||||
errno_t memset_s(void* s, rsize_t smax, int c, rsize_t n);
|
||||
@@ -42,14 +42,14 @@ uint32_t otp_generate(
|
||||
TOTP_ALGO algo,
|
||||
uint8_t digits,
|
||||
const uint8_t* plain_secret,
|
||||
uint8_t plain_secret_length,
|
||||
size_t plain_secret_length,
|
||||
uint64_t input) {
|
||||
uint8_t* hmac = malloc(64);
|
||||
memset(hmac, 0, 64);
|
||||
|
||||
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) {
|
||||
free(hmac);
|
||||
return OTP_ERROR;
|
||||
@@ -80,7 +80,7 @@ uint32_t totp_at(
|
||||
TOTP_ALGO algo,
|
||||
uint8_t digits,
|
||||
const uint8_t* plain_secret,
|
||||
uint8_t plain_secret_length,
|
||||
size_t plain_secret_length,
|
||||
uint64_t for_time,
|
||||
float timezone,
|
||||
uint8_t interval) {
|
||||
@@ -96,9 +96,9 @@ uint32_t totp_at(
|
||||
|
||||
static int totp_algo_sha1(
|
||||
const uint8_t* key,
|
||||
uint8_t key_length,
|
||||
size_t key_length,
|
||||
const uint8_t* input,
|
||||
uint8_t input_length,
|
||||
size_t input_length,
|
||||
uint8_t* output) {
|
||||
hmac_sha1(key, key_length, input, input_length, output);
|
||||
return HMAC_SHA1_RESULT_SIZE;
|
||||
@@ -106,9 +106,9 @@ static int totp_algo_sha1(
|
||||
|
||||
static int totp_algo_sha256(
|
||||
const uint8_t* key,
|
||||
uint8_t key_length,
|
||||
size_t key_length,
|
||||
const uint8_t* input,
|
||||
uint8_t input_length,
|
||||
size_t input_length,
|
||||
uint8_t* output) {
|
||||
hmac_sha256(key, key_length, input, input_length, output);
|
||||
return HMAC_SHA256_RESULT_SIZE;
|
||||
@@ -116,9 +116,9 @@ static int totp_algo_sha256(
|
||||
|
||||
static int totp_algo_sha512(
|
||||
const uint8_t* key,
|
||||
uint8_t key_length,
|
||||
size_t key_length,
|
||||
const uint8_t* input,
|
||||
uint8_t input_length,
|
||||
size_t input_length,
|
||||
uint8_t* output) {
|
||||
hmac_sha512(key, key_length, input, input_length, output);
|
||||
return HMAC_SHA512_RESULT_SIZE;
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
typedef int (*TOTP_ALGO)(
|
||||
const uint8_t* key,
|
||||
uint8_t key_length,
|
||||
size_t key_length,
|
||||
const uint8_t* input,
|
||||
uint8_t input_length,
|
||||
size_t input_length,
|
||||
uint8_t* output);
|
||||
|
||||
/*
|
||||
@@ -47,7 +47,7 @@ uint32_t totp_at(
|
||||
TOTP_ALGO algo,
|
||||
uint8_t digits,
|
||||
const uint8_t* plain_secret,
|
||||
uint8_t plain_secret_length,
|
||||
size_t plain_secret_length,
|
||||
uint64_t for_time,
|
||||
float timezone,
|
||||
uint8_t interval);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <totp_icons.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define ICON_ARROW_LEFT_8x9_WIDTH 8
|
||||
|
||||
@@ -5,7 +5,11 @@
|
||||
#define TEXT_BOX_HEIGHT 13
|
||||
#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) {
|
||||
return;
|
||||
}
|
||||
@@ -44,7 +48,7 @@ void ui_control_select_render(
|
||||
int16_t x,
|
||||
int16_t y,
|
||||
uint8_t width,
|
||||
char* text,
|
||||
const char* text,
|
||||
bool is_selected) {
|
||||
if(y < -TEXT_BOX_HEIGHT) {
|
||||
return;
|
||||
@@ -99,7 +103,7 @@ void ui_control_button_render(
|
||||
int16_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
char* text,
|
||||
const char* text,
|
||||
bool is_selected) {
|
||||
if(y < -height) {
|
||||
return;
|
||||
|
||||
@@ -3,19 +3,23 @@
|
||||
#include <inttypes.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(
|
||||
Canvas* const canvas,
|
||||
int16_t x,
|
||||
int16_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
char* text,
|
||||
const char* text,
|
||||
bool is_selected);
|
||||
void ui_control_select_render(
|
||||
Canvas* const canvas,
|
||||
int16_t x,
|
||||
int16_t y,
|
||||
uint8_t width,
|
||||
char* text,
|
||||
const char* text,
|
||||
bool is_selected);
|
||||
|
||||
@@ -154,22 +154,22 @@ int32_t totp_app() {
|
||||
if(plugin_state->changing_scene) continue;
|
||||
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.type == EventTypeKey) {
|
||||
last_user_interaction_time = furi_get_tick();
|
||||
}
|
||||
|
||||
processing = totp_scene_director_handle_event(&event, plugin_state);
|
||||
processing = totp_scene_director_handle_event(&event, plugin_state_m);
|
||||
} else if(
|
||||
plugin_state->pin_set && plugin_state->current_scene != TotpSceneAuthentication &&
|
||||
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, TotpSceneAuthentication, NULL);
|
||||
totp_scene_director_activate_scene(plugin_state_m, TotpSceneAuthentication, NULL);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -22,7 +22,7 @@ typedef struct {
|
||||
uint8_t tokens_count;
|
||||
|
||||
uint8_t* crypto_verify_data;
|
||||
uint8_t crypto_verify_data_length;
|
||||
size_t crypto_verify_data_length;
|
||||
bool pin_set;
|
||||
uint8_t iv[TOTP_IV_SIZE];
|
||||
uint8_t base_iv[TOTP_IV_SIZE];
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "common.h"
|
||||
#include "../services/base32/base32.h"
|
||||
#include "../services/crypto/crypto.h"
|
||||
#include "../services/crypto/memset_s.h"
|
||||
|
||||
TokenInfo* token_info_alloc() {
|
||||
TokenInfo* tokenInfo = malloc(sizeof(TokenInfo));
|
||||
@@ -23,7 +24,7 @@ void token_info_free(TokenInfo* token_info) {
|
||||
bool token_info_set_secret(
|
||||
TokenInfo* token_info,
|
||||
const char* base32_token_secret,
|
||||
uint8_t token_secret_length,
|
||||
size_t token_secret_length,
|
||||
uint8_t* iv) {
|
||||
uint8_t* plain_secret = malloc(token_secret_length);
|
||||
int plain_secret_length =
|
||||
@@ -37,7 +38,7 @@ bool token_info_set_secret(
|
||||
result = false;
|
||||
}
|
||||
|
||||
memset(plain_secret, 0, token_secret_length);
|
||||
memset_s(plain_secret, sizeof(plain_secret), 0, token_secret_length);
|
||||
free(plain_secret);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ typedef enum { TOTP_6_DIGITS, TOTP_8_DIGITS } TokenDigitsCount;
|
||||
|
||||
typedef struct {
|
||||
uint8_t* token;
|
||||
uint8_t token_length;
|
||||
size_t token_length;
|
||||
char* name;
|
||||
TokenHashAlgo algo;
|
||||
TokenDigitsCount digits;
|
||||
@@ -19,6 +19,6 @@ void token_info_free(TokenInfo* token_info);
|
||||
bool token_info_set_secret(
|
||||
TokenInfo* token_info,
|
||||
const char* base32_token_secret,
|
||||
uint8_t token_secret_length,
|
||||
size_t token_secret_length,
|
||||
uint8_t* iv);
|
||||
uint8_t token_info_get_digits_count(TokenInfo* token_info);
|
||||
|
||||
@@ -11,5 +11,5 @@ App(
|
||||
order=60,
|
||||
fap_icon="usb_keyboard_10px.png",
|
||||
fap_category="Misc",
|
||||
fap_icon_assets="icons",
|
||||
fap_icon_assets="assets",
|
||||
)
|
||||
|
||||
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 102 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 102 B |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
@@ -8,5 +8,5 @@ App(
|
||||
order=60,
|
||||
fap_icon="wav_10px.png",
|
||||
fap_category="Music",
|
||||
fap_icon_assets="icons",
|
||||
fap_icon_assets="images",
|
||||
)
|
||||
|
||||
|
After Width: | Height: | Size: 142 B |
@@ -13,6 +13,8 @@
|
||||
#include <math.h>
|
||||
#include <WAV_Player_icons.h>
|
||||
|
||||
#include <WAV_Player_icons.h>
|
||||
|
||||
#define TAG "WavPlayer"
|
||||
|
||||
#define WAVPLAYER_FOLDER "/ext/wav_player"
|
||||
|
||||