From 34348102e5755aacb87914691a4530a97df20d88 Mon Sep 17 00:00:00 2001 From: Eng1n33r <10697207+xMasterX@users.noreply.github.com> Date: Mon, 4 Jul 2022 03:33:17 +0300 Subject: [PATCH] add picopass/iclass to build list & include key Key: https://github.com/flipperdevices/flipperzero-firmware/pull/1360/files --- applications/meta/application.fam | 1 + applications/picopass/application.fam | 1 - applications/picopass/picopass.c | 51 ++++----------------------- 3 files changed, 7 insertions(+), 46 deletions(-) diff --git a/applications/meta/application.fam b/applications/meta/application.fam index 7f7ee3120..50275e338 100644 --- a/applications/meta/application.fam +++ b/applications/meta/application.fam @@ -36,6 +36,7 @@ App( provides=[ "music_player", "bt_hid", + "picopass", ], ) diff --git a/applications/picopass/application.fam b/applications/picopass/application.fam index 3ad72d274..6ae3c1452 100644 --- a/applications/picopass/application.fam +++ b/applications/picopass/application.fam @@ -6,6 +6,5 @@ App( cdefines=["APP_PICOPASS"], requires=["gui"], stack_size=1 * 1024, - icon="A_Plugins_14", order=30, ) diff --git a/applications/picopass/picopass.c b/applications/picopass/picopass.c index 477b7b86c..317fd4b6b 100644 --- a/applications/picopass/picopass.c +++ b/applications/picopass/picopass.c @@ -13,9 +13,6 @@ #define TAG "PicoPass" -#define PICOPASS_APP_ICLASS_KEY_PATH "/any/picopass/iclass_key.bin" -#define PICOPASS_APP_ICLASS_DECRYPT_KEY_PATH "/any/picopass/iclass_decryptionkey.bin" - typedef enum { EventTypeTick, EventTypeKey, @@ -42,46 +39,17 @@ typedef struct { WiegandRecord record; } PACS; -enum State { INIT, KEYS_MISSING, READY, RESULT }; +enum State { INIT, READY, RESULT }; typedef struct { enum State state; PACS pacs; } PluginState; -uint8_t iclass_key[8] = {0}; // NB: not the permuted version -uint8_t iclass_decryptionkey[16] = {0}; +uint8_t iclass_key[8] = {0xaf, 0xa7, 0x85, 0xa7, 0xda, 0xb3, 0x33, 0x78}; +uint8_t iclass_decryptionkey[16] = + {0xb4, 0x21, 0x2c, 0xca, 0xb7, 0xed, 0x21, 0x0f, 0x7b, 0x93, 0xd4, 0x59, 0x39, 0xc7, 0xdd, 0x36}; ApplicationArea AA1; -static bool picopass_load_keys() { - Storage* storage = furi_record_open("storage"); - File* file = storage_file_alloc(storage); - - if(!storage_file_open(file, PICOPASS_APP_ICLASS_KEY_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) { - FURI_LOG_E(TAG, "Unable to open iClass key"); - storage_file_free(file); - furi_record_close("storage"); - return false; - }; - storage_file_read(file, iclass_key, sizeof(iclass_key)); - storage_file_close(file); - FURI_LOG_D(TAG, "iClass key loaded"); - - if(!storage_file_open( - file, PICOPASS_APP_ICLASS_DECRYPT_KEY_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) { - FURI_LOG_E(TAG, "Unable to open iClass decryption key"); - storage_file_free(file); - furi_record_close("storage"); - return false; - }; - storage_file_read(file, iclass_decryptionkey, sizeof(iclass_decryptionkey)); - storage_file_close(file); - FURI_LOG_D(TAG, "iClass decryption key loaded"); - - storage_file_free(file); - furi_record_close("storage"); - return true; -} - static void render_callback(Canvas* const canvas, void* ctx) { const PluginState* plugin_state = acquire_mutex((ValueMutex*)ctx, 25); if(plugin_state == NULL) { @@ -94,8 +62,6 @@ static void render_callback(Canvas* const canvas, void* ctx) { if(plugin_state->state == INIT) { canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignTop, "Loading..."); - } else if(plugin_state->state == KEYS_MISSING) { - canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignTop, "Keys missing"); } else if(plugin_state->state == READY) { canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignTop, "Push center to scan"); } else if(plugin_state->state == RESULT) { @@ -135,12 +101,7 @@ static void input_callback(InputEvent* input_event, osMessageQueueId_t event_que } static void picopass_state_init(PluginState* const plugin_state) { - plugin_state->state = INIT; - if(picopass_load_keys()) { - plugin_state->state = READY; - } else { - plugin_state->state = KEYS_MISSING; - } + plugin_state->state = READY; } ReturnCode decrypt(uint8_t* enc_data, uint8_t* dec_data) { @@ -433,4 +394,4 @@ int32_t picopass_app(void* p) { osMessageQueueDelete(event_queue); return 0; -} +} \ No newline at end of file