mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Random low level API cleanup
This commit is contained in:
@@ -276,7 +276,6 @@ void crypto_cli_store_key(Cli* cli, FuriString* args) {
|
||||
}
|
||||
} while(0);
|
||||
|
||||
explicit_bzero(data, sizeof(data));
|
||||
furi_string_free(key_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ void NAMESPOOF_INIT() {
|
||||
|
||||
if(!flipper_format_read_string(file, "Name", str)) break;
|
||||
version_set_custom_name(NULL, strdup(furi_string_get_cstr(str)));
|
||||
furi_hal_version_set_name(version_get_custom_name(NULL));
|
||||
furi_hal_version_set_name(NULL);
|
||||
} while(false);
|
||||
|
||||
flipper_format_free(file);
|
||||
|
||||
@@ -445,8 +445,6 @@ static void gap_advertise_start(GapState new_state) {
|
||||
0);
|
||||
if(status) {
|
||||
FURI_LOG_E(TAG, "set_discoverable failed %d", status);
|
||||
} else {
|
||||
FURI_LOG_D(TAG, "set_discoverable success");
|
||||
}
|
||||
gap->state = new_state;
|
||||
GapEvent event = {.type = GapEventTypeStartAdvertising};
|
||||
|
||||
@@ -68,7 +68,11 @@
|
||||
#define _USE_FASTSEEK 1
|
||||
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
|
||||
|
||||
#ifdef FURI_RAM_EXEC
|
||||
#define _USE_EXPAND 0
|
||||
#else
|
||||
#define _USE_EXPAND 1
|
||||
#endif
|
||||
/* This option switches f_expand function. (0:Disable or 1:Enable) */
|
||||
|
||||
#define _USE_CHMOD 0
|
||||
|
||||
@@ -95,11 +95,9 @@ static bool furi_hal_crypto_generate_unique_keys(uint8_t start_slot, uint8_t end
|
||||
key.data = key_data;
|
||||
furi_hal_random_fill_buf(key_data, 32);
|
||||
if(!furi_hal_crypto_enclave_store_key(&key, &slot)) {
|
||||
explicit_bzero(key_data, sizeof(key_data));
|
||||
FURI_LOG_E(TAG, "Error writing key to slot %u", slot);
|
||||
return false;
|
||||
}
|
||||
explicit_bzero(key_data, sizeof(key_data));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -193,7 +191,6 @@ bool furi_hal_crypto_enclave_store_key(FuriHalCryptoKey* key, uint8_t* slot) {
|
||||
memcpy(pParam.KeyData, key->data, key_data_size);
|
||||
|
||||
SHCI_CmdStatus_t shci_state = SHCI_C2_FUS_StoreUsrKey(&pParam, slot);
|
||||
explicit_bzero(&pParam, sizeof(pParam));
|
||||
furi_check(furi_mutex_release(furi_hal_crypto_mutex) == FuriStatusOk);
|
||||
return (shci_state == SHCI_Success);
|
||||
}
|
||||
|
||||
@@ -91,6 +91,13 @@ typedef struct {
|
||||
static FuriHalVersion furi_hal_version = {0};
|
||||
|
||||
void furi_hal_version_set_name(const char* name) {
|
||||
uint32_t udn = LL_FLASH_GetUDN();
|
||||
if(name == NULL) {
|
||||
name = version_get_custom_name(NULL);
|
||||
if(name != NULL) {
|
||||
udn = *((uint32_t*)name);
|
||||
}
|
||||
}
|
||||
if(name != NULL && strlen(name)) {
|
||||
strlcpy(furi_hal_version.name, name, FURI_HAL_VERSION_ARRAY_NAME_LENGTH);
|
||||
snprintf(
|
||||
@@ -105,11 +112,6 @@ void furi_hal_version_set_name(const char* name) {
|
||||
furi_hal_version.device_name[0] = AD_TYPE_COMPLETE_LOCAL_NAME;
|
||||
|
||||
// BLE Mac address
|
||||
uint32_t udn = LL_FLASH_GetUDN();
|
||||
if(version_get_custom_name(NULL) != NULL) {
|
||||
udn = *((uint32_t*)version_get_custom_name(NULL));
|
||||
}
|
||||
|
||||
uint32_t company_id = LL_FLASH_GetSTCompanyID();
|
||||
// uint32_t device_id = LL_FLASH_GetDeviceID();
|
||||
// Some flippers return 0x27 (flippers with chip revision 2003 6495) instead of 0x26 (flippers with chip revision 2001 6495)
|
||||
@@ -137,11 +139,7 @@ static void furi_hal_version_load_otp_v0() {
|
||||
furi_hal_version.board_body = otp->board_body;
|
||||
furi_hal_version.board_connect = otp->board_connect;
|
||||
|
||||
if(version_get_custom_name(NULL) != NULL) {
|
||||
furi_hal_version_set_name(version_get_custom_name(NULL));
|
||||
} else {
|
||||
furi_hal_version_set_name(otp->name);
|
||||
}
|
||||
furi_hal_version_set_name(otp->name);
|
||||
}
|
||||
|
||||
static void furi_hal_version_load_otp_v1() {
|
||||
@@ -155,11 +153,7 @@ static void furi_hal_version_load_otp_v1() {
|
||||
furi_hal_version.board_color = otp->board_color;
|
||||
furi_hal_version.board_region = otp->board_region;
|
||||
|
||||
if(version_get_custom_name(NULL) != NULL) {
|
||||
furi_hal_version_set_name(version_get_custom_name(NULL));
|
||||
} else {
|
||||
furi_hal_version_set_name(otp->name);
|
||||
}
|
||||
furi_hal_version_set_name(otp->name);
|
||||
}
|
||||
|
||||
static void furi_hal_version_load_otp_v2() {
|
||||
@@ -179,11 +173,7 @@ static void furi_hal_version_load_otp_v2() {
|
||||
if(otp->board_color != 0xFF) {
|
||||
furi_hal_version.board_color = otp->board_color;
|
||||
furi_hal_version.board_region = otp->board_region;
|
||||
if(version_get_custom_name(NULL) != NULL) {
|
||||
furi_hal_version_set_name(version_get_custom_name(NULL));
|
||||
} else {
|
||||
furi_hal_version_set_name(otp->name);
|
||||
}
|
||||
furi_hal_version_set_name(otp->name);
|
||||
} else {
|
||||
furi_hal_version.board_color = 0;
|
||||
furi_hal_version.board_region = 0;
|
||||
|
||||
Reference in New Issue
Block a user