This commit is contained in:
Willy-JL
2023-07-25 19:43:51 +02:00
90 changed files with 1764 additions and 1075 deletions

View File

@@ -1,7 +1,7 @@
#include "bt_type_code.h"
#include <furi_hal_bt.h>
#include <furi_hal_bt_hid.h>
#include <furi_hal_version.h>
#include <bt/bt_service/bt_i.h>
#include <furi/core/thread.h>
#include <furi/core/mutex.h>
#include <furi/core/string.h>
@@ -13,7 +13,7 @@
#include "../type_code_common.h"
#include "../../features_config.h"
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
#define TOTP_BT_WORKER_BT_ADV_NAME_MAX_LEN FURI_HAL_BT_ADV_NAME_LENGTH
#define TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN GAP_MAC_ADDR_SIZE
#endif
@@ -27,7 +27,7 @@ struct TotpBtTypeCodeWorkerContext {
Bt* bt;
bool is_advertising;
bool is_connected;
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
char previous_bt_name[TOTP_BT_WORKER_BT_ADV_NAME_MAX_LEN];
uint8_t previous_bt_mac[TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN];
#endif
@@ -37,7 +37,7 @@ static inline bool totp_type_code_worker_stop_requested() {
return furi_thread_flags_get() & TotpBtTypeCodeWorkerEventStop;
}
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
static void totp_type_code_worker_bt_set_app_mac(uint8_t* mac) {
uint8_t max_i;
size_t uid_size = furi_hal_version_uid_size();
@@ -47,7 +47,7 @@ static void totp_type_code_worker_bt_set_app_mac(uint8_t* mac) {
max_i = TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN;
}
const uint8_t* uid = furi_hal_version_uid();
const uint8_t* uid = (const uint8_t*)UID64_BASE; //-V566
memcpy(mac, uid, max_i);
for(uint8_t i = max_i; i < TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN; i++) {
mac[i] = 0;
@@ -159,7 +159,7 @@ TotpBtTypeCodeWorkerContext* totp_bt_type_code_worker_init() {
furi_delay_ms(200);
bt_keys_storage_set_storage_path(context->bt, TOTP_BT_KEYS_STORAGE_PATH);
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
memcpy(
&context->previous_bt_name[0],
furi_hal_bt_get_profile_adv_name(FuriHalBtProfileHidKeyboard),
@@ -182,7 +182,7 @@ TotpBtTypeCodeWorkerContext* totp_bt_type_code_worker_init() {
furi_hal_bt_start_advertising();
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
bt_enable_peer_key_update(context->bt);
#endif
@@ -209,7 +209,7 @@ void totp_bt_type_code_worker_free(TotpBtTypeCodeWorkerContext* context) {
furi_delay_ms(200);
bt_keys_storage_set_default_path(context->bt);
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME_UL
furi_hal_bt_set_profile_adv_name(FuriHalBtProfileHidKeyboard, context->previous_bt_name);
furi_hal_bt_set_profile_mac_addr(FuriHalBtProfileHidKeyboard, context->previous_bt_mac);
#endif

View File

@@ -21,7 +21,7 @@ struct TotpGenerateCodeWorkerContext {
void* on_code_lifetime_changed_handler_context;
};
static const char* STEAM_ALGO_ALPHABET = "23456789BCDFGHJKMNPQRTVWXY";
static const char STEAM_ALGO_ALPHABET[] = "23456789BCDFGHJKMNPQRTVWXY";
static void
int_token_to_str(uint64_t i_token_code, char* str, TokenDigitsCount len, TokenHashAlgo algo) {
@@ -30,7 +30,7 @@ static void
if(i_token_code == OTP_ERROR) {
memset(str, '-', len);
} else {
if(algo == STEAM) {
if(algo == TokenHashAlgoSteam) {
char* s = str;
for(uint8_t i = 0; i < len; i++, s++) {
*s = STEAM_ALGO_ALPHABET[i_token_code % 26];
@@ -48,12 +48,12 @@ static void
static TOTP_ALGO get_totp_algo_impl(TokenHashAlgo algo) {
switch(algo) {
case SHA1:
case STEAM:
case TokenHashAlgoSha1:
case TokenHashAlgoSteam:
return TOTP_ALGO_SHA1;
case SHA256:
case TokenHashAlgoSha256:
return TOTP_ALGO_SHA256;
case SHA512:
case TokenHashAlgoSha512:
return TOTP_ALGO_SHA512;
default:
break;