mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 07:28:36 -07:00
add picopass/iclass to build list & include key
Key: https://github.com/flipperdevices/flipperzero-firmware/pull/1360/files
This commit is contained in:
@@ -36,6 +36,7 @@ App(
|
|||||||
provides=[
|
provides=[
|
||||||
"music_player",
|
"music_player",
|
||||||
"bt_hid",
|
"bt_hid",
|
||||||
|
"picopass",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,5 @@ App(
|
|||||||
cdefines=["APP_PICOPASS"],
|
cdefines=["APP_PICOPASS"],
|
||||||
requires=["gui"],
|
requires=["gui"],
|
||||||
stack_size=1 * 1024,
|
stack_size=1 * 1024,
|
||||||
icon="A_Plugins_14",
|
|
||||||
order=30,
|
order=30,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,9 +13,6 @@
|
|||||||
|
|
||||||
#define TAG "PicoPass"
|
#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 {
|
typedef enum {
|
||||||
EventTypeTick,
|
EventTypeTick,
|
||||||
EventTypeKey,
|
EventTypeKey,
|
||||||
@@ -42,46 +39,17 @@ typedef struct {
|
|||||||
WiegandRecord record;
|
WiegandRecord record;
|
||||||
} PACS;
|
} PACS;
|
||||||
|
|
||||||
enum State { INIT, KEYS_MISSING, READY, RESULT };
|
enum State { INIT, READY, RESULT };
|
||||||
typedef struct {
|
typedef struct {
|
||||||
enum State state;
|
enum State state;
|
||||||
PACS pacs;
|
PACS pacs;
|
||||||
} PluginState;
|
} PluginState;
|
||||||
|
|
||||||
uint8_t iclass_key[8] = {0}; // NB: not the permuted version
|
uint8_t iclass_key[8] = {0xaf, 0xa7, 0x85, 0xa7, 0xda, 0xb3, 0x33, 0x78};
|
||||||
uint8_t iclass_decryptionkey[16] = {0};
|
uint8_t iclass_decryptionkey[16] =
|
||||||
|
{0xb4, 0x21, 0x2c, 0xca, 0xb7, 0xed, 0x21, 0x0f, 0x7b, 0x93, 0xd4, 0x59, 0x39, 0xc7, 0xdd, 0x36};
|
||||||
ApplicationArea AA1;
|
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) {
|
static void render_callback(Canvas* const canvas, void* ctx) {
|
||||||
const PluginState* plugin_state = acquire_mutex((ValueMutex*)ctx, 25);
|
const PluginState* plugin_state = acquire_mutex((ValueMutex*)ctx, 25);
|
||||||
if(plugin_state == NULL) {
|
if(plugin_state == NULL) {
|
||||||
@@ -94,8 +62,6 @@ static void render_callback(Canvas* const canvas, void* ctx) {
|
|||||||
|
|
||||||
if(plugin_state->state == INIT) {
|
if(plugin_state->state == INIT) {
|
||||||
canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignTop, "Loading...");
|
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) {
|
} else if(plugin_state->state == READY) {
|
||||||
canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignTop, "Push center to scan");
|
canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignTop, "Push center to scan");
|
||||||
} else if(plugin_state->state == RESULT) {
|
} 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) {
|
static void picopass_state_init(PluginState* const plugin_state) {
|
||||||
plugin_state->state = INIT;
|
plugin_state->state = READY;
|
||||||
if(picopass_load_keys()) {
|
|
||||||
plugin_state->state = READY;
|
|
||||||
} else {
|
|
||||||
plugin_state->state = KEYS_MISSING;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnCode decrypt(uint8_t* enc_data, uint8_t* dec_data) {
|
ReturnCode decrypt(uint8_t* enc_data, uint8_t* dec_data) {
|
||||||
@@ -433,4 +394,4 @@ int32_t picopass_app(void* p) {
|
|||||||
osMessageQueueDelete(event_queue);
|
osMessageQueueDelete(event_queue);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user