mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-18 19:01:47 +03:00
53435579b3
* fbt, faploader: minimal app module implementation * faploader, libs: moved API hashtable core to flipper_application * example: compound api * lib: flipper_application: naming fixes, doxygen comments * fbt: changed `requires` manifest field behavior for app extensions * examples: refactored plugin apps; faploader: changed new API naming; fbt: changed PLUGIN app type meaning * loader: dropped support for debug apps & plugin menus * moved applications/plugins -> applications/external * Restored x bit on chiplist_convert.py * git: fixed free-dap submodule path * pvs: updated submodule paths * examples: example_advanced_plugins.c: removed potential memory leak on errors * examples: example_plugins: refined requires * fbt: not deploying app modules for debug/sample apps; extra validation for .PLUGIN-type apps * apps: removed cdefines for external apps * fbt: moved ext app path definition * fbt: reworked fap_dist handling; f18: synced api_symbols.csv * fbt: removed resources_paths for extapps * scripts: reworked storage * scripts: reworked runfap.py & selfupdate.py to use new api * wip: fal runner * fbt: moved file packaging into separate module * scripts: storage: fixes * scripts: storage: minor fixes for new api * fbt: changed internal artifact storage details for external apps * scripts: storage: additional fixes and better error reporting; examples: using APP_DATA_PATH() * fbt, scripts: reworked launch_app to deploy plugins; moved old runfap.py to distfap.py * fbt: extra check for plugins descriptors * fbt: additional checks in emitter * fbt: better info message on SDK rebuild * scripts: removed requirements.txt * loader: removed remnants of plugins & debug menus * post-review fixes
108 lines
2.7 KiB
C
108 lines
2.7 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <storage/storage.h>
|
|
#include <dialogs/dialogs.h>
|
|
#include <mbedtls/des.h>
|
|
|
|
#include "rfal_picopass.h"
|
|
#include <optimized_ikeys.h>
|
|
#include <optimized_cipher.h>
|
|
#include "helpers/iclass_elite_dict.h"
|
|
|
|
#define PICOPASS_DEV_NAME_MAX_LEN 22
|
|
#define PICOPASS_READER_DATA_MAX_SIZE 64
|
|
#define PICOPASS_BLOCK_LEN 8
|
|
#define PICOPASS_MAX_APP_LIMIT 32
|
|
|
|
#define PICOPASS_CSN_BLOCK_INDEX 0
|
|
#define PICOPASS_CONFIG_BLOCK_INDEX 1
|
|
#define PICOPASS_EPURSE_BLOCK_INDEX 2
|
|
#define PICOPASS_KD_BLOCK_INDEX 3
|
|
#define PICOPASS_KC_BLOCK_INDEX 4
|
|
#define PICOPASS_AIA_BLOCK_INDEX 5
|
|
#define PICOPASS_PACS_CFG_BLOCK_INDEX 6
|
|
|
|
#define PICOPASS_APP_EXTENSION ".picopass"
|
|
#define PICOPASS_APP_SHADOW_EXTENSION ".pas"
|
|
|
|
typedef void (*PicopassLoadingCallback)(void* context, bool state);
|
|
|
|
typedef enum {
|
|
PicopassDeviceEncryptionUnknown = 0,
|
|
PicopassDeviceEncryptionNone = 0x14,
|
|
PicopassDeviceEncryptionDES = 0x15,
|
|
PicopassDeviceEncryption3DES = 0x17,
|
|
} PicopassEncryption;
|
|
|
|
typedef enum {
|
|
PicopassDeviceSaveFormatHF,
|
|
PicopassDeviceSaveFormatLF,
|
|
} PicopassDeviceSaveFormat;
|
|
|
|
typedef struct {
|
|
bool valid;
|
|
uint8_t bitLength;
|
|
uint8_t FacilityCode;
|
|
uint16_t CardNumber;
|
|
} PicopassWiegandRecord;
|
|
|
|
typedef struct {
|
|
bool legacy;
|
|
bool se_enabled;
|
|
bool sio;
|
|
bool biometrics;
|
|
uint8_t key[8];
|
|
uint8_t pin_length;
|
|
PicopassEncryption encryption;
|
|
uint8_t credential[8];
|
|
uint8_t pin0[8];
|
|
uint8_t pin1[8];
|
|
PicopassWiegandRecord record;
|
|
} PicopassPacs;
|
|
|
|
typedef struct {
|
|
uint8_t data[PICOPASS_BLOCK_LEN];
|
|
} PicopassBlock;
|
|
|
|
typedef struct {
|
|
PicopassBlock AA1[PICOPASS_MAX_APP_LIMIT];
|
|
PicopassPacs pacs;
|
|
} PicopassDeviceData;
|
|
|
|
typedef struct {
|
|
Storage* storage;
|
|
DialogsApp* dialogs;
|
|
PicopassDeviceData dev_data;
|
|
char dev_name[PICOPASS_DEV_NAME_MAX_LEN + 1];
|
|
FuriString* load_path;
|
|
PicopassDeviceSaveFormat format;
|
|
PicopassLoadingCallback loading_cb;
|
|
void* loading_cb_ctx;
|
|
} PicopassDevice;
|
|
|
|
PicopassDevice* picopass_device_alloc();
|
|
|
|
void picopass_device_free(PicopassDevice* picopass_dev);
|
|
|
|
void picopass_device_set_name(PicopassDevice* dev, const char* name);
|
|
|
|
bool picopass_device_save(PicopassDevice* dev, const char* dev_name);
|
|
|
|
bool picopass_file_select(PicopassDevice* dev);
|
|
|
|
void picopass_device_data_clear(PicopassDeviceData* dev_data);
|
|
|
|
void picopass_device_clear(PicopassDevice* dev);
|
|
|
|
bool picopass_device_delete(PicopassDevice* dev, bool use_load_path);
|
|
|
|
void picopass_device_set_loading_callback(
|
|
PicopassDevice* dev,
|
|
PicopassLoadingCallback callback,
|
|
void* context);
|
|
|
|
ReturnCode picopass_device_parse_credential(PicopassBlock* AA1, PicopassPacs* pacs);
|
|
ReturnCode picopass_device_parse_wiegand(uint8_t* data, PicopassWiegandRecord* record);
|