[FL-1934] Core: wipe memory after free. SubGhz: key encryption tool. (#797)
* Core: wipe memory after free. RFID,iButton: fix iterator use after invalidation. * Debug: support unix wildcards for register matching in svd, update MCU description file and minify it. * Toolbox: getter for File in FlipperFile. * Makefile: conditional flashing * SubGhz: keeloq_mfcodes encryption tool. * FuriHal: proper IV handling on CBC in crypto. SubGhz: add support for encrypted keeloq keys. Makefile: move formatting to top Makefile. * SubGhz: rename some function names to match naming scheme. * SubGhz: encryption tool, fix windows line endings Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
This commit is contained in:
@@ -48,8 +48,8 @@ iButtonApp::iButtonApp()
|
||||
iButtonApp::~iButtonApp() {
|
||||
for(std::map<Scene, iButtonScene*>::iterator it = scenes.begin(); it != scenes.end(); ++it) {
|
||||
delete it->second;
|
||||
scenes.erase(it);
|
||||
}
|
||||
scenes.clear();
|
||||
delete key_worker;
|
||||
|
||||
furi_hal_power_insomnia_exit();
|
||||
|
@@ -10,8 +10,9 @@ RfidTimerEmulator::~RfidTimerEmulator() {
|
||||
|
||||
for(it = encoders.begin(); it != encoders.end(); ++it) {
|
||||
delete it->second;
|
||||
encoders.erase(it);
|
||||
}
|
||||
|
||||
encoders.clear();
|
||||
}
|
||||
|
||||
void RfidTimerEmulator::start(LfrfidKeyType type, const uint8_t* data, uint8_t data_size) {
|
||||
|
@@ -3,26 +3,15 @@
|
||||
#include <furi.h>
|
||||
#include <furi-hal.h>
|
||||
#include <stream_buffer.h>
|
||||
#include <lib/toolbox/args.h>
|
||||
#include <lib/subghz/subghz_parser.h>
|
||||
#include <lib/subghz/subghz_keystore.h>
|
||||
#include <lib/subghz/protocols/subghz_protocol_common.h>
|
||||
#include <lib/subghz/protocols/subghz_protocol_princeton.h>
|
||||
|
||||
#define SUBGHZ_FREQUENCY_RANGE_STR \
|
||||
"299999755...348000000 or 386999938...464000000 or 778999847...928000000"
|
||||
|
||||
void subghz_cli_init() {
|
||||
Cli* cli = furi_record_open("cli");
|
||||
|
||||
cli_add_command(
|
||||
cli, "subghz_tx_carrier", CliCommandFlagDefault, subghz_cli_command_tx_carrier, NULL);
|
||||
cli_add_command(
|
||||
cli, "subghz_rx_carrier", CliCommandFlagDefault, subghz_cli_command_rx_carrier, NULL);
|
||||
cli_add_command(cli, "subghz_tx", CliCommandFlagDefault, subghz_cli_command_tx, NULL);
|
||||
cli_add_command(cli, "subghz_rx", CliCommandFlagDefault, subghz_cli_command_rx, NULL);
|
||||
|
||||
furi_record_close("cli");
|
||||
}
|
||||
|
||||
void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) {
|
||||
uint32_t frequency = 433920000;
|
||||
|
||||
@@ -267,3 +256,88 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
|
||||
vStreamBufferDelete(instance->stream);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void subghz_cli_command_print_usage() {
|
||||
printf("Usage:\r\n");
|
||||
printf("subghz_crypto <cmd> <args>\r\n");
|
||||
printf("Cmd list:\r\n");
|
||||
printf(
|
||||
"\tkeeloq <plain_text_file> <encrypted_file> <IV:16 bytes in hex>\t - Encrypt keeloq manufacture keys\r\n");
|
||||
}
|
||||
|
||||
void subghz_cli_command_encrypt_keeloq(Cli* cli, string_t args) {
|
||||
uint8_t iv[16];
|
||||
|
||||
string_t source;
|
||||
string_t destination;
|
||||
string_init(source);
|
||||
string_init(destination);
|
||||
|
||||
SubGhzKeystore* keystore = subghz_keystore_alloc();
|
||||
|
||||
do {
|
||||
if(!args_read_string_and_trim(args, source)) {
|
||||
subghz_cli_command_print_usage();
|
||||
break;
|
||||
}
|
||||
|
||||
if(!args_read_string_and_trim(args, destination)) {
|
||||
subghz_cli_command_print_usage();
|
||||
break;
|
||||
}
|
||||
|
||||
if(!args_read_hex_bytes(args, iv, 16)) {
|
||||
subghz_cli_command_print_usage();
|
||||
break;
|
||||
}
|
||||
|
||||
if(!subghz_keystore_load(keystore, string_get_cstr(source))) {
|
||||
printf("Failed to load Keystore");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!subghz_keystore_save(keystore, string_get_cstr(destination), iv)) {
|
||||
printf("Failed to save Keystore");
|
||||
break;
|
||||
}
|
||||
} while(false);
|
||||
|
||||
subghz_keystore_free(keystore);
|
||||
string_clear(destination);
|
||||
string_clear(source);
|
||||
}
|
||||
|
||||
void subghz_cli_command(Cli* cli, string_t args, void* context) {
|
||||
string_t cmd;
|
||||
string_init(cmd);
|
||||
|
||||
do {
|
||||
if(!args_read_string_and_trim(args, cmd)) {
|
||||
subghz_cli_command_print_usage();
|
||||
break;
|
||||
}
|
||||
|
||||
if(string_cmp_str(cmd, "encrypt_keeloq") == 0) {
|
||||
subghz_cli_command_encrypt_keeloq(cli, args);
|
||||
break;
|
||||
}
|
||||
|
||||
subghz_cli_command_print_usage();
|
||||
} while(false);
|
||||
|
||||
string_clear(cmd);
|
||||
}
|
||||
|
||||
void subghz_cli_init() {
|
||||
Cli* cli = furi_record_open("cli");
|
||||
|
||||
cli_add_command(
|
||||
cli, "subghz_tx_carrier", CliCommandFlagDefault, subghz_cli_command_tx_carrier, NULL);
|
||||
cli_add_command(
|
||||
cli, "subghz_rx_carrier", CliCommandFlagDefault, subghz_cli_command_rx_carrier, NULL);
|
||||
cli_add_command(cli, "subghz_tx", CliCommandFlagDefault, subghz_cli_command_tx, NULL);
|
||||
cli_add_command(cli, "subghz_rx", CliCommandFlagDefault, subghz_cli_command_rx, NULL);
|
||||
cli_add_command(cli, "subghz", CliCommandFlagDefault, subghz_cli_command, NULL);
|
||||
|
||||
furi_record_close("cli");
|
||||
}
|
||||
|
@@ -3,15 +3,3 @@
|
||||
#include <cli/cli.h>
|
||||
|
||||
void subghz_cli_init();
|
||||
|
||||
void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context);
|
||||
|
||||
void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context);
|
||||
|
||||
void subghz_cli_command_tx_pt(Cli* cli, string_t args, void* context);
|
||||
|
||||
void subghz_cli_command_rx_pt(Cli* cli, string_t args, void* context);
|
||||
|
||||
void subghz_cli_command_tx(Cli* cli, string_t args, void* context);
|
||||
|
||||
void subghz_cli_command_rx(Cli* cli, string_t args, void* context);
|
||||
|
Reference in New Issue
Block a user