subghz_keystore.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #pragma once
  2. #include <furi.h>
  3. #include <m-array.h>
  4. #include <stdint.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. typedef struct {
  9. FuriString* name;
  10. uint64_t key;
  11. uint16_t type;
  12. } SubGhzKey;
  13. ARRAY_DEF(SubGhzKeyArray, SubGhzKey, M_POD_OPLIST)
  14. #define M_OPL_SubGhzKeyArray_t() ARRAY_OPLIST(SubGhzKeyArray, M_POD_OPLIST)
  15. typedef struct SubGhzKeystore SubGhzKeystore;
  16. /**
  17. * Allocate SubGhzKeystore.
  18. * @return SubGhzKeystore* pointer to a SubGhzKeystore instance
  19. */
  20. SubGhzKeystore* subghz_keystore_alloc();
  21. /**
  22. * Free SubGhzKeystore.
  23. * @param instance Pointer to a SubGhzKeystore instance
  24. */
  25. void subghz_keystore_free(SubGhzKeystore* instance);
  26. /**
  27. * Loading manufacture key from file
  28. * @param instance Pointer to a SubGhzKeystore instance
  29. * @param filename Full path to the file
  30. */
  31. bool subghz_keystore_load(SubGhzKeystore* instance, const char* filename);
  32. /**
  33. * Save manufacture key to file
  34. * @param instance Pointer to a SubGhzKeystore instance
  35. * @param filename Full path to the file
  36. * @return true On success
  37. */
  38. bool subghz_keystore_save(SubGhzKeystore* instance, const char* filename, uint8_t* iv);
  39. /**
  40. * Get array of keys and names manufacture
  41. * @param instance Pointer to a SubGhzKeystore instance
  42. * @return SubGhzKeyArray_t*
  43. */
  44. SubGhzKeyArray_t* subghz_keystore_get_data(SubGhzKeystore* instance);
  45. /**
  46. * Save RAW encrypted to file
  47. * @param input_file_name Full path to the input file
  48. * @param output_file_name Full path to the output file
  49. * @param iv IV, 16 bytes in hex
  50. */
  51. bool subghz_keystore_raw_encrypted_save(
  52. const char* input_file_name,
  53. const char* output_file_name,
  54. uint8_t* iv);
  55. /**
  56. * Get decrypt RAW data to file
  57. * @param file_name Full path to the input file
  58. * @param offset Offset from the start of the RAW data
  59. * @param data Returned array
  60. * @param len Required data length
  61. * @return true On success
  62. */
  63. bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t* data, size_t len);
  64. #ifdef __cplusplus
  65. }
  66. #endif