subghz_keystore.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include <m-string.h>
  3. #include <m-array.h>
  4. #include <stdint.h>
  5. typedef struct {
  6. string_t name;
  7. uint64_t key;
  8. uint16_t type;
  9. } SubGhzKey;
  10. ARRAY_DEF(SubGhzKeyArray, SubGhzKey, M_POD_OPLIST)
  11. #define M_OPL_SubGhzKeyArray_t() ARRAY_OPLIST(SubGhzKeyArray, M_POD_OPLIST)
  12. typedef struct SubGhzKeystore SubGhzKeystore;
  13. /** Allocate SubGhzKeystore
  14. *
  15. * @return SubGhzKeystore*
  16. */
  17. SubGhzKeystore* subghz_keystore_alloc();
  18. /** Free SubGhzKeystore
  19. *
  20. * @param instance
  21. */
  22. void subghz_keystore_free(SubGhzKeystore* instance);
  23. /** Loading manufacture key from file
  24. *
  25. * @param instance - SubGhzKeystore instance
  26. * @param filename - const char* full path to the file
  27. */
  28. bool subghz_keystore_load(SubGhzKeystore* instance, const char* filename);
  29. /** Save manufacture key to file
  30. *
  31. * @param instance - SubGhzKeystore instance
  32. * @param filename - const char* full path to the file
  33. */
  34. bool subghz_keystore_save(SubGhzKeystore* instance, const char* filename, uint8_t* iv);
  35. /** Get array of keys and names manufacture
  36. *
  37. * @param instance - SubGhzKeystore instance
  38. * @return SubGhzKeyArray_t*
  39. */
  40. SubGhzKeyArray_t* subghz_keystore_get_data(SubGhzKeystore* instance);
  41. /** Save RAW encrypted to file
  42. *
  43. * @param input_file_name - const char* full path to the input file
  44. * @param output_file_name - const char* full path to the output file
  45. */
  46. bool subghz_keystore_raw_encrypted_save(
  47. const char* input_file_name,
  48. const char* output_file_name,
  49. uint8_t* iv);
  50. /** Get decrypt RAW data to file
  51. *
  52. * @param file_name - const char* full path to the input file
  53. * @param offset - offset from the start of the RAW data
  54. * @param data - returned array
  55. * @param len - required data length
  56. */
  57. bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t* data, size_t len);