flipperzero-firmware/lib/subghz/subghz_keystore.h
Skorpionm 6d548637f2
SubGhz: reading keys from encrypted files (#803)
* SubGhz: add file with manufactory codes, and the ability to add your own manufactory codes for KeeLog
* SubGhz: add encrypt RAW data, add decrypt and get RAW data
* SubGhz: add encrypt  magic_xor_atomo
* SubGhz: parsing atomo using file encrypt
* SubGhz: fix calculating the size of the read buffer
* SubGhz: parsing Nice FLOR S using file encrypt
* SubGhz: add file encrypt nice_flor_s_tx, fix name load file
* SubGhz: fix checking read buffer size
* Update subghz_keystore.c
* SubGhz: fix calculating the size of the read buffer

Co-authored-by: あく <alleteam@gmail.com>
2021-11-03 19:41:07 +03:00

70 lines
1.8 KiB
C

#pragma once
#include <m-string.h>
#include <m-array.h>
#include <stdint.h>
typedef struct {
string_t name;
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;
/** Allocate SubGhzKeystore
*
* @return SubGhzKeystore*
*/
SubGhzKeystore* subghz_keystore_alloc();
/** Free SubGhzKeystore
*
* @param instance
*/
void subghz_keystore_free(SubGhzKeystore* instance);
/** Loading manufacture key from file
*
* @param instance - SubGhzKeystore instance
* @param filename - const char* full path to the file
*/
bool subghz_keystore_load(SubGhzKeystore* instance, const char* filename);
/** Save manufacture key to file
*
* @param instance - SubGhzKeystore instance
* @param filename - const char* full path to the file
*/
bool subghz_keystore_save(SubGhzKeystore* instance, const char* filename, uint8_t* iv);
/** Get array of keys and names manufacture
*
* @param instance - SubGhzKeystore instance
* @return SubGhzKeyArray_t*
*/
SubGhzKeyArray_t* subghz_keystore_get_data(SubGhzKeystore* instance);
/** Save RAW encrypted to file
*
* @param input_file_name - const char* full path to the input file
* @param output_file_name - const char* full path to the output file
*/
bool subghz_keystore_raw_encrypted_save(
const char* input_file_name,
const char* output_file_name,
uint8_t* iv);
/** Get decrypt RAW data to file
*
* @param file_name - const char* 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
*/
bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t* data, size_t len);