Support adding and removing new Ultralight C keys

This commit is contained in:
noproto
2024-11-10 16:19:44 -05:00
parent 147a81c38e
commit c3b8c54aa0
15 changed files with 409 additions and 24 deletions

View File

@@ -58,6 +58,12 @@ ADD_SCENE(nfc, mf_classic_keys_delete, MfClassicKeysDelete)
ADD_SCENE(nfc, mf_classic_keys_add, MfClassicKeysAdd) ADD_SCENE(nfc, mf_classic_keys_add, MfClassicKeysAdd)
ADD_SCENE(nfc, mf_classic_keys_warn_duplicate, MfClassicKeysWarnDuplicate) ADD_SCENE(nfc, mf_classic_keys_warn_duplicate, MfClassicKeysWarnDuplicate)
ADD_SCENE(nfc, mf_ultralight_c_keys, MfUltralightCKeys)
ADD_SCENE(nfc, mf_ultralight_c_keys_list, MfUltralightCKeysList)
ADD_SCENE(nfc, mf_ultralight_c_keys_delete, MfUltralightCKeysDelete)
ADD_SCENE(nfc, mf_ultralight_c_keys_add, MfUltralightCKeysAdd)
ADD_SCENE(nfc, mf_ultralight_c_keys_warn_duplicate, MfUltralightCKeysWarnDuplicate)
ADD_SCENE(nfc, set_type, SetType) ADD_SCENE(nfc, set_type, SetType)
ADD_SCENE(nfc, set_sak, SetSak) ADD_SCENE(nfc, set_sak, SetSak)
ADD_SCENE(nfc, set_atqa, SetAtqa) ADD_SCENE(nfc, set_atqa, SetAtqa)

View File

@@ -28,6 +28,10 @@ bool nfc_scene_delete_success_on_event(void* context, SceneManagerEvent event) {
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneMfClassicKeys)) { if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneMfClassicKeys)) {
consumed = scene_manager_search_and_switch_to_previous_scene( consumed = scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneMfClassicKeys); nfc->scene_manager, NfcSceneMfClassicKeys);
} else if(scene_manager_has_previous_scene(
nfc->scene_manager, NfcSceneMfUltralightCKeys)) {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneMfUltralightCKeys);
} else { } else {
consumed = scene_manager_search_and_switch_to_previous_scene( consumed = scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneFileSelect); nfc->scene_manager, NfcSceneFileSelect);

View File

@@ -3,7 +3,7 @@
enum SubmenuIndex { enum SubmenuIndex {
SubmenuIndexReadCardType, SubmenuIndexReadCardType,
SubmenuIndexMfClassicKeys, SubmenuIndexMfClassicKeys,
SubmenuIndexMfUlCKeys, SubmenuIndexMfUltralightCKeys,
SubmenuIndexMfUltralightUnlock, SubmenuIndexMfUltralightUnlock,
SubmenuIndexSlixUnlock, SubmenuIndexSlixUnlock,
}; };
@@ -33,7 +33,7 @@ void nfc_scene_extra_actions_on_enter(void* context) {
submenu_add_item( submenu_add_item(
submenu, submenu,
"MIFARE Ultralight C Keys", "MIFARE Ultralight C Keys",
SubmenuIndexMfUlCKeys, SubmenuIndexMfUltralightCKeys,
nfc_scene_extra_actions_submenu_callback, nfc_scene_extra_actions_submenu_callback,
instance); instance);
submenu_add_item( submenu_add_item(
@@ -61,8 +61,8 @@ bool nfc_scene_extra_actions_on_event(void* context, SceneManagerEvent event) {
if(event.event == SubmenuIndexMfClassicKeys) { if(event.event == SubmenuIndexMfClassicKeys) {
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicKeys); scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicKeys);
consumed = true; consumed = true;
} else if(event.event == SubmenuIndexMfUlCKeys) { } else if(event.event == SubmenuIndexMfUltralightCKeys) {
// TODO: Add MFUL C key management scene here scene_manager_next_scene(instance->scene_manager, NfcSceneMfUltralightCKeys);
consumed = true; consumed = true;
} else if(event.event == SubmenuIndexMfUltralightUnlock) { } else if(event.event == SubmenuIndexMfUltralightUnlock) {
mf_ultralight_auth_reset(instance->mf_ul_auth); mf_ultralight_auth_reset(instance->mf_ul_auth);

View File

@@ -1,7 +1,5 @@
#include "../nfc_app_i.h" #include "../nfc_app_i.h"
#define NFC_SCENE_MF_CLASSIC_KEYS_MAX (100)
void nfc_scene_mf_classic_keys_widget_callback(GuiButtonType result, InputType type, void* context) { void nfc_scene_mf_classic_keys_widget_callback(GuiButtonType result, InputType type, void* context) {
NfcApp* instance = context; NfcApp* instance = context;
if(type == InputTypeShort) { if(type == InputTypeShort) {

View File

@@ -39,7 +39,7 @@ bool nfc_scene_mf_classic_keys_add_on_event(void* context, SceneManagerEvent eve
instance->scene_manager, NfcSceneMfClassicKeysWarnDuplicate); instance->scene_manager, NfcSceneMfClassicKeysWarnDuplicate);
} else if(keys_dict_add_key(dict, key.data, sizeof(MfClassicKey))) { } else if(keys_dict_add_key(dict, key.data, sizeof(MfClassicKey))) {
scene_manager_next_scene(instance->scene_manager, NfcSceneSaveSuccess); scene_manager_next_scene(instance->scene_manager, NfcSceneSaveSuccess);
dolphin_deed(DolphinDeedNfcMfcAdd); dolphin_deed(DolphinDeedNfcKeyAdd);
} else { } else {
scene_manager_previous_scene(instance->scene_manager); scene_manager_previous_scene(instance->scene_manager);
} }

View File

@@ -0,0 +1,96 @@
#include "../nfc_app_i.h"
void nfc_scene_mf_ultralight_c_keys_widget_callback(
GuiButtonType result,
InputType type,
void* context) {
NfcApp* instance = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(instance->view_dispatcher, result);
}
}
void nfc_scene_mf_ultralight_c_keys_on_enter(void* context) {
NfcApp* instance = context;
// Load flipper dict keys total
uint32_t flipper_dict_keys_total = 0;
KeysDict* dict = keys_dict_alloc(
NFC_APP_MF_ULTRALIGHT_C_DICT_SYSTEM_PATH,
KeysDictModeOpenExisting,
sizeof(MfUltralightC3DesAuthKey));
flipper_dict_keys_total = keys_dict_get_total_keys(dict);
keys_dict_free(dict);
// Load user dict keys total
uint32_t user_dict_keys_total = 0;
dict = keys_dict_alloc(
NFC_APP_MF_ULTRALIGHT_C_DICT_USER_PATH,
KeysDictModeOpenAlways,
sizeof(MfUltralightC3DesAuthKey));
user_dict_keys_total = keys_dict_get_total_keys(dict);
keys_dict_free(dict);
FuriString* temp_str = furi_string_alloc();
widget_add_string_element(
instance->widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "MIFARE Ultralight C Keys");
furi_string_printf(temp_str, "System dict: %lu", flipper_dict_keys_total);
widget_add_string_element(
instance->widget,
0,
20,
AlignLeft,
AlignTop,
FontSecondary,
furi_string_get_cstr(temp_str));
furi_string_printf(temp_str, "User dict: %lu", user_dict_keys_total);
widget_add_string_element(
instance->widget,
0,
32,
AlignLeft,
AlignTop,
FontSecondary,
furi_string_get_cstr(temp_str));
widget_add_icon_element(instance->widget, 87, 13, &I_Keychain_39x36);
widget_add_button_element(
instance->widget,
GuiButtonTypeCenter,
"Add",
nfc_scene_mf_ultralight_c_keys_widget_callback,
instance);
if(user_dict_keys_total > 0) {
widget_add_button_element(
instance->widget,
GuiButtonTypeRight,
"List",
nfc_scene_mf_ultralight_c_keys_widget_callback,
instance);
}
furi_string_free(temp_str);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewWidget);
}
bool nfc_scene_mf_ultralight_c_keys_on_event(void* context, SceneManagerEvent event) {
NfcApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeCenter) {
scene_manager_next_scene(instance->scene_manager, NfcSceneMfUltralightCKeysAdd);
consumed = true;
} else if(event.event == GuiButtonTypeRight) {
scene_manager_next_scene(instance->scene_manager, NfcSceneMfUltralightCKeysList);
consumed = true;
}
}
return consumed;
}
void nfc_scene_mf_ultralight_c_keys_on_exit(void* context) {
NfcApp* instance = context;
widget_reset(instance->widget);
}

View File

@@ -0,0 +1,63 @@
#include "../nfc_app_i.h"
void nfc_scene_mf_ultralight_c_keys_add_byte_input_callback(void* context) {
NfcApp* instance = context;
view_dispatcher_send_custom_event(instance->view_dispatcher, NfcCustomEventByteInputDone);
}
void nfc_scene_mf_ultralight_c_keys_add_on_enter(void* context) {
NfcApp* instance = context;
// Setup view
ByteInput* byte_input = instance->byte_input;
byte_input_set_header_text(byte_input, "Enter the key in hex");
byte_input_set_result_callback(
byte_input,
nfc_scene_mf_ultralight_c_keys_add_byte_input_callback,
NULL,
instance,
instance->byte_input_store,
sizeof(MfUltralightC3DesAuthKey));
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewByteInput);
}
bool nfc_scene_mf_ultralight_c_keys_add_on_event(void* context, SceneManagerEvent event) {
NfcApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcCustomEventByteInputDone) {
// Add key to dict
KeysDict* dict = keys_dict_alloc(
NFC_APP_MF_ULTRALIGHT_C_DICT_USER_PATH,
KeysDictModeOpenAlways,
sizeof(MfUltralightC3DesAuthKey));
MfUltralightC3DesAuthKey key = {};
memcpy(key.data, instance->byte_input_store, sizeof(MfUltralightC3DesAuthKey));
if(keys_dict_is_key_present(dict, key.data, sizeof(MfUltralightC3DesAuthKey))) {
scene_manager_next_scene(
instance->scene_manager, NfcSceneMfUltralightCKeysWarnDuplicate);
} else if(keys_dict_add_key(dict, key.data, sizeof(MfUltralightC3DesAuthKey))) {
scene_manager_next_scene(instance->scene_manager, NfcSceneSaveSuccess);
dolphin_deed(DolphinDeedNfcKeyAdd);
} else {
scene_manager_previous_scene(instance->scene_manager);
}
keys_dict_free(dict);
consumed = true;
}
}
return consumed;
}
void nfc_scene_mf_ultralight_c_keys_add_on_exit(void* context) {
NfcApp* instance = context;
// Clear view
byte_input_set_result_callback(instance->byte_input, NULL, NULL, NULL, NULL, 0);
byte_input_set_header_text(instance->byte_input, "");
}

View File

@@ -0,0 +1,108 @@
#include "../nfc_app_i.h"
void nfc_scene_mf_ultralight_c_keys_delete_widget_callback(
GuiButtonType result,
InputType type,
void* context) {
NfcApp* instance = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(instance->view_dispatcher, result);
}
}
void nfc_scene_mf_ultralight_c_keys_delete_on_enter(void* context) {
NfcApp* instance = context;
uint32_t key_index =
scene_manager_get_scene_state(instance->scene_manager, NfcSceneMfUltralightCKeysDelete);
FuriString* key_str = furi_string_alloc();
widget_add_string_element(
instance->widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "Delete this key?");
widget_add_button_element(
instance->widget,
GuiButtonTypeLeft,
"Cancel",
nfc_scene_mf_ultralight_c_keys_delete_widget_callback,
instance);
widget_add_button_element(
instance->widget,
GuiButtonTypeRight,
"Delete",
nfc_scene_mf_ultralight_c_keys_delete_widget_callback,
instance);
KeysDict* mf_ultralight_c_user_dict = keys_dict_alloc(
NFC_APP_MF_ULTRALIGHT_C_DICT_USER_PATH,
KeysDictModeOpenAlways,
sizeof(MfUltralightC3DesAuthKey));
size_t dict_keys_num = keys_dict_get_total_keys(mf_ultralight_c_user_dict);
furi_assert(key_index < dict_keys_num);
MfUltralightC3DesAuthKey stack_key;
for(size_t i = 0; i < (key_index + 1); i++) {
bool key_loaded = keys_dict_get_next_key(
mf_ultralight_c_user_dict, stack_key.data, sizeof(MfUltralightC3DesAuthKey));
furi_assert(key_loaded);
}
furi_string_reset(key_str);
for(size_t i = 0; i < sizeof(MfUltralightC3DesAuthKey); i++) {
furi_string_cat_printf(key_str, "%02X", stack_key.data[i]);
}
widget_add_string_element(
instance->widget,
64,
32,
AlignCenter,
AlignCenter,
FontSecondary,
furi_string_get_cstr(key_str));
keys_dict_free(mf_ultralight_c_user_dict);
furi_string_free(key_str);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewWidget);
}
bool nfc_scene_mf_ultralight_c_keys_delete_on_event(void* context, SceneManagerEvent event) {
NfcApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeRight) {
uint32_t key_index = scene_manager_get_scene_state(
instance->scene_manager, NfcSceneMfUltralightCKeysDelete);
KeysDict* mf_ultralight_c_user_dict = keys_dict_alloc(
NFC_APP_MF_ULTRALIGHT_C_DICT_USER_PATH,
KeysDictModeOpenAlways,
sizeof(MfUltralightC3DesAuthKey));
size_t dict_keys_num = keys_dict_get_total_keys(mf_ultralight_c_user_dict);
furi_assert(key_index < dict_keys_num);
MfUltralightC3DesAuthKey stack_key;
for(size_t i = 0; i < (key_index + 1); i++) {
bool key_loaded = keys_dict_get_next_key(
mf_ultralight_c_user_dict, stack_key.data, sizeof(MfUltralightC3DesAuthKey));
furi_assert(key_loaded);
}
bool key_delete_success = keys_dict_delete_key(
mf_ultralight_c_user_dict, stack_key.data, sizeof(MfUltralightC3DesAuthKey));
keys_dict_free(mf_ultralight_c_user_dict);
if(key_delete_success) {
scene_manager_next_scene(instance->scene_manager, NfcSceneDeleteSuccess);
} else {
scene_manager_previous_scene(instance->scene_manager);
}
} else if(event.event == GuiButtonTypeLeft) {
scene_manager_previous_scene(instance->scene_manager);
}
consumed = true;
}
return consumed;
}
void nfc_scene_mf_ultralight_c_keys_delete_on_exit(void* context) {
NfcApp* instance = context;
widget_reset(instance->widget);
}

View File

@@ -0,0 +1,66 @@
#include "../nfc_app_i.h"
#define NFC_SCENE_MF_ULTRALIGHT_C_KEYS_LIST_MAX (100)
void nfc_scene_mf_ultralight_c_keys_list_submenu_callback(void* context, uint32_t index) {
NfcApp* instance = context;
view_dispatcher_send_custom_event(instance->view_dispatcher, index);
}
void nfc_scene_mf_ultralight_c_keys_list_on_enter(void* context) {
NfcApp* instance = context;
KeysDict* mf_ultralight_c_user_dict = keys_dict_alloc(
NFC_APP_MF_ULTRALIGHT_C_DICT_USER_PATH,
KeysDictModeOpenAlways,
sizeof(MfUltralightC3DesAuthKey));
submenu_set_header(instance->submenu, "Select key to delete:");
FuriString* temp_str = furi_string_alloc();
size_t dict_keys_num = keys_dict_get_total_keys(mf_ultralight_c_user_dict);
size_t keys_num = MIN((size_t)NFC_SCENE_MF_ULTRALIGHT_C_KEYS_LIST_MAX, dict_keys_num);
MfUltralightC3DesAuthKey stack_key;
if(keys_num > 0) {
for(size_t i = 0; i < keys_num; i++) {
bool key_loaded = keys_dict_get_next_key(
mf_ultralight_c_user_dict, stack_key.data, sizeof(MfUltralightC3DesAuthKey));
furi_assert(key_loaded);
furi_string_reset(temp_str);
for(size_t i = 0; i < sizeof(MfUltralightC3DesAuthKey); i++) {
furi_string_cat_printf(temp_str, "%02X", stack_key.data[i]);
}
submenu_add_item(
instance->submenu,
furi_string_get_cstr(temp_str),
i,
nfc_scene_mf_ultralight_c_keys_list_submenu_callback,
instance);
}
}
keys_dict_free(mf_ultralight_c_user_dict);
furi_string_free(temp_str);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewMenu);
}
bool nfc_scene_mf_ultralight_c_keys_list_on_event(void* context, SceneManagerEvent event) {
NfcApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
scene_manager_set_scene_state(
instance->scene_manager, NfcSceneMfUltralightCKeysDelete, event.event);
scene_manager_next_scene(instance->scene_manager, NfcSceneMfUltralightCKeysDelete);
}
return consumed;
}
void nfc_scene_mf_ultralight_c_keys_list_on_exit(void* context) {
NfcApp* instance = context;
submenu_reset(instance->submenu);
}

View File

@@ -0,0 +1,49 @@
#include "../nfc_app_i.h"
void nfc_scene_mf_ultralight_c_keys_warn_duplicate_popup_callback(void* context) {
NfcApp* instance = context;
view_dispatcher_send_custom_event(instance->view_dispatcher, NfcCustomEventViewExit);
}
void nfc_scene_mf_ultralight_c_keys_warn_duplicate_on_enter(void* context) {
NfcApp* instance = context;
// Setup view
Popup* popup = instance->popup;
popup_set_icon(popup, 83, 22, &I_WarningDolphinFlip_45x42);
popup_set_header(popup, "Key Already Exists!", 64, 3, AlignCenter, AlignTop);
popup_set_text(
popup,
"Please enter a\n"
"different key.",
4,
24,
AlignLeft,
AlignTop);
popup_set_timeout(popup, 1500);
popup_set_context(popup, instance);
popup_set_callback(popup, nfc_scene_mf_ultralight_c_keys_warn_duplicate_popup_callback);
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewPopup);
}
bool nfc_scene_mf_ultralight_c_keys_warn_duplicate_on_event(void* context, SceneManagerEvent event) {
NfcApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcCustomEventViewExit) {
consumed = scene_manager_search_and_switch_to_previous_scene(
instance->scene_manager, NfcSceneMfUltralightCKeysAdd);
}
}
return consumed;
}
void nfc_scene_mf_ultralight_c_keys_warn_duplicate_on_exit(void* context) {
NfcApp* instance = context;
popup_reset(instance->popup);
}

View File

@@ -28,6 +28,10 @@ bool nfc_scene_save_success_on_event(void* context, SceneManagerEvent event) {
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneMfClassicKeys)) { if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneMfClassicKeys)) {
consumed = scene_manager_search_and_switch_to_previous_scene( consumed = scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneMfClassicKeys); nfc->scene_manager, NfcSceneMfClassicKeys);
} else if(scene_manager_has_previous_scene(
nfc->scene_manager, NfcSceneMfUltralightCKeys)) {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneMfUltralightCKeys);
} else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSaveConfirm)) { } else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSaveConfirm)) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicDetectReader); scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicDetectReader);
consumed = true; consumed = true;

View File

@@ -20,7 +20,7 @@ static const DolphinDeedWeight dolphin_deed_weights[] = {
{3, DolphinAppNfc}, // DolphinDeedNfcSave {3, DolphinAppNfc}, // DolphinDeedNfcSave
{1, DolphinAppNfc}, // DolphinDeedNfcDetectReader {1, DolphinAppNfc}, // DolphinDeedNfcDetectReader
{2, DolphinAppNfc}, // DolphinDeedNfcEmulate {2, DolphinAppNfc}, // DolphinDeedNfcEmulate
{2, DolphinAppNfc}, // DolphinDeedNfcMfcAdd {2, DolphinAppNfc}, // DolphinDeedNfcKeyAdd
{1, DolphinAppNfc}, // DolphinDeedNfcAddSave {1, DolphinAppNfc}, // DolphinDeedNfcAddSave
{1, DolphinAppNfc}, // DolphinDeedNfcAddEmulate {1, DolphinAppNfc}, // DolphinDeedNfcAddEmulate

View File

@@ -36,7 +36,7 @@ typedef enum {
DolphinDeedNfcSave, DolphinDeedNfcSave,
DolphinDeedNfcDetectReader, DolphinDeedNfcDetectReader,
DolphinDeedNfcEmulate, DolphinDeedNfcEmulate,
DolphinDeedNfcMfcAdd, DolphinDeedNfcKeyAdd,
DolphinDeedNfcAddSave, DolphinDeedNfcAddSave,
DolphinDeedNfcAddEmulate, DolphinDeedNfcAddEmulate,

View File

@@ -702,7 +702,7 @@ void mfkey(ProgramState* program_state) {
keys_dict_add_key(user_dict, keyarray[i].data, sizeof(MfClassicKey)); keys_dict_add_key(user_dict, keyarray[i].data, sizeof(MfClassicKey));
} }
if(keyarray_size > 0) { if(keyarray_size > 0) {
dolphin_deed(DolphinDeedNfcMfcAdd); dolphin_deed(DolphinDeedNfcKeyAdd);
} }
free(nonce_arr); free(nonce_arr);
keys_dict_free(user_dict); keys_dict_free(user_dict);

View File

@@ -134,22 +134,21 @@ static void keys_dict_int_to_str(KeysDict* instance, const uint8_t* key_int, Fur
furi_string_cat_printf(key_str, "%02X", key_int[i]); furi_string_cat_printf(key_str, "%02X", key_int[i]);
} }
static void keys_dict_str_to_int(KeysDict* instance, FuriString* key_str, uint64_t* key_int) { static void keys_dict_str_to_int(KeysDict* instance, FuriString* key_str, uint8_t* key_out) {
furi_assert(instance); furi_assert(instance);
furi_assert(key_str); furi_assert(key_str);
furi_assert(key_int); furi_assert(key_out);
uint8_t key_byte_tmp; uint8_t key_byte_tmp;
char h, l; char h, l;
*key_int = 0ULL; // Process two hex characters at a time to create each byte
for(size_t i = 0; i < instance->key_size_symbols - 1; i += 2) { for(size_t i = 0; i < instance->key_size_symbols - 1; i += 2) {
h = furi_string_get_char(key_str, i); h = furi_string_get_char(key_str, i);
l = furi_string_get_char(key_str, i + 1); l = furi_string_get_char(key_str, i + 1);
args_char_to_hex(h, l, &key_byte_tmp); args_char_to_hex(h, l, &key_byte_tmp);
*key_int |= (uint64_t)key_byte_tmp << (8 * (instance->key_size - 1 - i / 2)); key_out[i / 2] = key_byte_tmp;
} }
} }
@@ -193,15 +192,7 @@ bool keys_dict_get_next_key(KeysDict* instance, uint8_t* key, size_t key_size) {
bool key_read = keys_dict_get_next_key_str(instance, temp_key); bool key_read = keys_dict_get_next_key_str(instance, temp_key);
if(key_read) { if(key_read) {
size_t tmp_len = key_size; keys_dict_str_to_int(instance, temp_key, key);
uint64_t key_int = 0;
keys_dict_str_to_int(instance, temp_key, &key_int);
while(tmp_len--) {
key[tmp_len] = (uint8_t)key_int;
key_int >>= 8;
}
} }
furi_string_free(temp_key); furi_string_free(temp_key);