subghz_keystore.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. /**
  14. * Allocate SubGhzKeystore.
  15. * @return SubGhzKeystore* pointer to a SubGhzKeystore instance
  16. */
  17. SubGhzKeystore* subghz_keystore_alloc();
  18. /**
  19. * Free SubGhzKeystore.
  20. * @param instance Pointer to a SubGhzKeystore instance
  21. */
  22. void subghz_keystore_free(SubGhzKeystore* instance);
  23. /**
  24. * Loading manufacture key from file
  25. * @param instance Pointer to a SubGhzKeystore instance
  26. * @param filename Full path to the file
  27. */
  28. bool subghz_keystore_load(SubGhzKeystore* instance, const char* filename);
  29. /**
  30. * Save manufacture key to file
  31. * @param instance Pointer to a SubGhzKeystore instance
  32. * @param filename Full path to the file
  33. * @return true On success
  34. */
  35. bool subghz_keystore_save(SubGhzKeystore* instance, const char* filename, uint8_t* iv);
  36. /**
  37. * Get array of keys and names manufacture
  38. * @param instance Pointer to a SubGhzKeystore instance
  39. * @return SubGhzKeyArray_t*
  40. */
  41. SubGhzKeyArray_t* subghz_keystore_get_data(SubGhzKeystore* instance);
  42. /**
  43. * Save RAW encrypted to file
  44. * @param input_file_name Full path to the input file
  45. * @param output_file_name Full path to the output file
  46. * @param iv IV, 16 bytes in hex
  47. */
  48. bool subghz_keystore_raw_encrypted_save(
  49. const char* input_file_name,
  50. const char* output_file_name,
  51. uint8_t* iv);
  52. /**
  53. * Get decrypt RAW data to file
  54. * @param file_name Full path to the input file
  55. * @param offset Offset from the start of the RAW data
  56. * @param data Returned array
  57. * @param len Required data length
  58. * @return true On success
  59. */
  60. bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t* data, size_t len);