2021-07-16 15:37:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
#include <furi.h>
|
2021-07-16 15:37:48 +00:00
|
|
|
#include <m-array.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2022-09-14 16:11:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-07-16 15:37:48 +00:00
|
|
|
typedef struct {
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* name;
|
2021-07-16 15:37:48 +00:00
|
|
|
uint64_t key;
|
|
|
|
uint16_t type;
|
|
|
|
} SubGhzKey;
|
|
|
|
|
|
|
|
ARRAY_DEF(SubGhzKeyArray, SubGhzKey, M_POD_OPLIST)
|
|
|
|
|
|
|
|
#define M_OPL_SubGhzKeyArray_t() ARRAY_OPLIST(SubGhzKeyArray, M_POD_OPLIST)
|
|
|
|
|
|
|
|
typedef struct SubGhzKeystore SubGhzKeystore;
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Allocate SubGhzKeystore.
|
|
|
|
* @return SubGhzKeystore* pointer to a SubGhzKeystore instance
|
2021-09-01 21:05:00 +00:00
|
|
|
*/
|
2021-07-16 15:37:48 +00:00
|
|
|
SubGhzKeystore* subghz_keystore_alloc();
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Free SubGhzKeystore.
|
|
|
|
* @param instance Pointer to a SubGhzKeystore instance
|
2021-09-01 21:05:00 +00:00
|
|
|
*/
|
2021-07-16 15:37:48 +00:00
|
|
|
void subghz_keystore_free(SubGhzKeystore* instance);
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Loading manufacture key from file
|
|
|
|
* @param instance Pointer to a SubGhzKeystore instance
|
|
|
|
* @param filename Full path to the file
|
2021-09-01 21:05:00 +00:00
|
|
|
*/
|
2021-11-01 13:11:25 +00:00
|
|
|
bool subghz_keystore_load(SubGhzKeystore* instance, const char* filename);
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Save manufacture key to file
|
|
|
|
* @param instance Pointer to a SubGhzKeystore instance
|
|
|
|
* @param filename Full path to the file
|
|
|
|
* @return true On success
|
2021-11-01 13:11:25 +00:00
|
|
|
*/
|
|
|
|
bool subghz_keystore_save(SubGhzKeystore* instance, const char* filename, uint8_t* iv);
|
2021-07-16 15:37:48 +00:00
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Get array of keys and names manufacture
|
|
|
|
* @param instance Pointer to a SubGhzKeystore instance
|
2021-09-01 21:05:00 +00:00
|
|
|
* @return SubGhzKeyArray_t*
|
|
|
|
*/
|
2021-07-16 15:37:48 +00:00
|
|
|
SubGhzKeyArray_t* subghz_keystore_get_data(SubGhzKeystore* instance);
|
2021-11-03 16:41:07 +00:00
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Save RAW encrypted to file
|
|
|
|
* @param input_file_name Full path to the input file
|
|
|
|
* @param output_file_name Full path to the output file
|
|
|
|
* @param iv IV, 16 bytes in hex
|
2021-11-03 16:41:07 +00:00
|
|
|
*/
|
|
|
|
bool subghz_keystore_raw_encrypted_save(
|
|
|
|
const char* input_file_name,
|
|
|
|
const char* output_file_name,
|
|
|
|
uint8_t* iv);
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Get decrypt RAW data to file
|
|
|
|
* @param file_name Full path to the input file
|
|
|
|
* @param offset Offset from the start of the RAW data
|
|
|
|
* @param data Returned array
|
|
|
|
* @param len Required data length
|
|
|
|
* @return true On success
|
2021-11-03 16:41:07 +00:00
|
|
|
*/
|
|
|
|
bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t* data, size_t len);
|
2022-09-14 16:11:38 +00:00
|
|
|
|
2023-05-20 13:15:01 +00:00
|
|
|
void subghz_keystore_reset_kl(SubGhzKeystore* instance);
|
|
|
|
|
2022-09-14 16:11:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|