uhf_device.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include <storage/storage.h>
  5. #include <dialogs/dialogs.h>
  6. #include <mbedtls/des.h>
  7. #include "uhf_data.h"
  8. // #include "rfal_picopass.h"
  9. #define UHF_DEV_NAME_MAX_LEN 22
  10. #define PICOPASS_READER_DATA_MAX_SIZE 64
  11. #define PICOPASS_BLOCK_LEN 8
  12. #define PICOPASS_MAX_APP_LIMIT 32
  13. #define UHF_BANK_DOES_NOT_EXIST \
  14. (uint8_t[]) { \
  15. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
  16. 0xFF \
  17. }
  18. #define UHF_RFU_BANK "RFU"
  19. #define UHF_EPC_BANK "EPC"
  20. #define UHF_TID_BANK "TID"
  21. #define UHF_USER_BANK "USER"
  22. #define UHF_APP_EXTENSION ".uhf"
  23. // #define PICOPASS_APP_SHADOW_EXTENSION ".pas"
  24. typedef void (*UHFLoadingCallback)(void* context, bool state);
  25. // typedef struct {
  26. // IclassEliteDict* dict;
  27. // IclassEliteDictType type;
  28. // uint8_t current_sector;
  29. // } IclassEliteDictAttackData;
  30. // typedef enum {
  31. // PicopassDeviceEncryptionUnknown = 0,
  32. // PicopassDeviceEncryptionNone = 0x14,
  33. // PicopassDeviceEncryptionDES = 0x15,
  34. // PicopassDeviceEncryption3DES = 0x17,
  35. // } PicopassEncryption;
  36. // typedef enum {
  37. // PicopassDeviceSaveFormatHF,
  38. // PicopassDeviceSaveFormatLF,
  39. // } PicopassDeviceSaveFormat;
  40. // typedef struct {
  41. // bool valid;
  42. // uint8_t bitLength;
  43. // uint8_t FacilityCode;
  44. // uint16_t CardNumber;
  45. // } PicopassWiegandRecord;
  46. // typedef struct {
  47. // bool legacy;
  48. // bool se_enabled;
  49. // bool sio;
  50. // bool biometrics;
  51. // uint8_t key[8];
  52. // bool elite_kdf;
  53. // uint8_t pin_length;
  54. // PicopassEncryption encryption;
  55. // uint8_t credential[8];
  56. // uint8_t pin0[8];
  57. // uint8_t pin1[8];
  58. // PicopassWiegandRecord record;
  59. // } PicopassPacs;
  60. // typedef struct {
  61. // uint8_t data[PICOPASS_BLOCK_LEN];
  62. // } PicopassBlock;
  63. // typedef struct {
  64. // PicopassBlock AA1[PICOPASS_MAX_APP_LIMIT];
  65. // PicopassPacs pacs;
  66. // IclassEliteDictAttackData iclass_elite_dict_attack_data;
  67. // } PicopassDeviceData;
  68. typedef struct {
  69. Storage* storage;
  70. DialogsApp* dialogs;
  71. UHFResponseData* dev_data;
  72. char dev_name[UHF_DEV_NAME_MAX_LEN + 1];
  73. FuriString* load_path;
  74. UHFLoadingCallback loading_cb;
  75. void* loading_cb_ctx;
  76. } UHFDevice;
  77. UHFDevice* uhf_device_alloc();
  78. void uhf_device_free(UHFDevice* uhf_dev);
  79. void uhf_device_set_name(UHFDevice* dev, const char* name);
  80. bool uhf_device_save(UHFDevice* dev, const char* dev_name);
  81. bool uhf_file_select(UHFDevice* dev);
  82. // void uhf_device_data_clear(PicopassDeviceData* dev_data);
  83. void uhf_device_clear(UHFDevice* dev);
  84. bool uhf_device_delete(UHFDevice* dev, bool use_load_path);
  85. void uhf_device_set_loading_callback(UHFDevice* dev, UHFLoadingCallback callback, void* context);
  86. // ReturnCode uhf_device_parse_credential(PicopassBlock* AA1, PicopassPacs* pacs);
  87. // ReturnCode uhf_device_parse_wiegand(uint8_t* data, PicopassWiegandRecord* record);