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>
This commit is contained in:
@@ -188,7 +188,8 @@ SubGhz* subghz_alloc() {
|
||||
string_init(subghz->error_str);
|
||||
|
||||
subghz_parser_load_keeloq_file(subghz->txrx->parser, "/ext/subghz/keeloq_mfcodes");
|
||||
subghz_parser_load_nice_flor_s_file(subghz->txrx->parser, "/ext/subghz/nice_floor_s_rx");
|
||||
subghz_parser_load_keeloq_file(subghz->txrx->parser, "/ext/subghz/keeloq_mfcodes_user");
|
||||
subghz_parser_load_nice_flor_s_file(subghz->txrx->parser, "/ext/subghz/nice_flor_s_rx");
|
||||
subghz_parser_load_came_atomo_file(subghz->txrx->parser, "/ext/subghz/came_atomo");
|
||||
|
||||
//subghz_parser_enable_dump_text(subghz->protocol, subghz_text_callback, subghz);
|
||||
|
@@ -212,7 +212,9 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
|
||||
|
||||
SubGhzParser* parser = subghz_parser_alloc();
|
||||
subghz_parser_load_keeloq_file(parser, "/ext/subghz/keeloq_mfcodes");
|
||||
subghz_parser_load_nice_flor_s_file(parser, "/ext/subghz/nice_floor_s_rx");
|
||||
subghz_parser_load_keeloq_file(parser, "/ext/subghz/keeloq_mfcodes_user");
|
||||
subghz_parser_load_nice_flor_s_file(parser, "/ext/subghz/nice_flor_s_rx");
|
||||
subghz_parser_load_came_atomo_file(parser, "/ext/subghz/came_atomo");
|
||||
subghz_parser_enable_dump_text(parser, subghz_cli_command_rx_text_callback, instance);
|
||||
|
||||
// Configure radio
|
||||
@@ -260,10 +262,12 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
|
||||
|
||||
void subghz_cli_command_print_usage() {
|
||||
printf("Usage:\r\n");
|
||||
printf("subghz_crypto <cmd> <args>\r\n");
|
||||
printf("subghz <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");
|
||||
"\tencrypt_keeloq <path_decrypted_file> <path_encrypted_file> <IV:16 bytes in hex>\t - Encrypt keeloq manufacture keys\r\n");
|
||||
printf(
|
||||
"\tencrypt_raw <path_decrypted_file> <path_encrypted_file> <IV:16 bytes in hex>\t - Encrypt RAW data\r\n");
|
||||
}
|
||||
|
||||
void subghz_cli_command_encrypt_keeloq(Cli* cli, string_t args) {
|
||||
@@ -308,6 +312,42 @@ void subghz_cli_command_encrypt_keeloq(Cli* cli, string_t args) {
|
||||
string_clear(source);
|
||||
}
|
||||
|
||||
void subghz_cli_command_encrypt_raw(Cli* cli, string_t args) {
|
||||
uint8_t iv[16];
|
||||
|
||||
string_t source;
|
||||
string_t destination;
|
||||
string_init(source);
|
||||
string_init(destination);
|
||||
|
||||
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_raw_encrypted_save(
|
||||
string_get_cstr(source), string_get_cstr(destination), iv)) {
|
||||
printf("Failed to save Keystore");
|
||||
break;
|
||||
}
|
||||
|
||||
} while(false);
|
||||
|
||||
string_clear(destination);
|
||||
string_clear(source);
|
||||
}
|
||||
|
||||
void subghz_cli_command(Cli* cli, string_t args, void* context) {
|
||||
string_t cmd;
|
||||
string_init(cmd);
|
||||
@@ -323,6 +363,11 @@ void subghz_cli_command(Cli* cli, string_t args, void* context) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(string_cmp_str(cmd, "encrypt_raw") == 0) {
|
||||
subghz_cli_command_encrypt_raw(cli, args);
|
||||
break;
|
||||
}
|
||||
|
||||
subghz_cli_command_print_usage();
|
||||
} while(false);
|
||||
|
||||
|
Reference in New Issue
Block a user