Nice Flor S protocol acceleration

This commit is contained in:
Dmitry422
2026-01-09 10:36:32 +07:00
parent 015ee6e7e4
commit ea3b237530
2 changed files with 42 additions and 21 deletions

View File

@@ -141,7 +141,7 @@ LevelDuration subghz_protocol_encoder_alutech_at_4n_yield(void* context) {
}
/**
* Read bytes from rainbow table
* Read bytes from buffer array with rainbow table
* @param buffer Pointer to decrypted magic data buffer
* @param number_alutech_at_4n_magic_data number in the array
* @return alutech_at_4n_magic_data
@@ -190,7 +190,8 @@ static uint8_t subghz_protocol_alutech_at_4n_decrypt_data_crc(uint8_t data) {
}
static uint64_t subghz_protocol_alutech_at_4n_decrypt(uint64_t data, const char* file_name) {
if(!strcmp(file_name, "")) return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
// load and decrypt rainbow table from file to buffer array in RAM
if(!file_name) return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
uint8_t buffer[SUBGHZ_ALUTECH_AT_4N_RAINBOW_TABLE_SIZE_BYTES] = {0};
uint8_t* buffer_ptr = (uint8_t*)&buffer;
@@ -236,7 +237,8 @@ static uint64_t subghz_protocol_alutech_at_4n_decrypt(uint64_t data, const char*
}
static uint64_t subghz_protocol_alutech_at_4n_encrypt(uint64_t data, const char* file_name) {
if(!strcmp(file_name, "")) return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
// load and decrypt rainbow table from file to buffer array in RAM
if(!file_name) return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
uint8_t buffer[SUBGHZ_ALUTECH_AT_4N_RAINBOW_TABLE_SIZE_BYTES] = {0};
uint8_t* buffer_ptr = (uint8_t*)&buffer;

View File

@@ -18,6 +18,8 @@
#define NICE_ONE_COUNT_BIT 72
#define NICE_ONE_NAME "Nice One"
#define SUBGHZ_NICE_FLOR_S_RAINBOW_TABLE_SIZE_BYTES 32
#define SUBGHZ_NO_NICE_FLOR_S_RAINBOW_TABLE 0
static const SubGhzBlockConst subghz_protocol_nice_flor_s_const = {
.te_short = 500,
@@ -414,21 +416,13 @@ static void subghz_protocol_nice_one_get_data(uint8_t* p, uint8_t num_parcel, ui
}
/**
* Read bytes from rainbow table
* @param file_name Full path to rainbow table the file
* Read bytes from buffer array with rainbow table
* @param buffer pointer to decrypted rainbow table
* @param address Byte address in file
* @return data
*/
static uint8_t
subghz_protocol_nice_flor_s_get_byte_in_file(const char* file_name, uint32_t address) {
if(!file_name) return 0;
uint8_t buffer[1] = {0};
if(subghz_keystore_raw_get_data(file_name, address, buffer, sizeof(uint8_t))) {
return buffer[0];
} else {
return 0;
}
static uint8_t subghz_protocol_nice_flor_s_get_byte_from_buffer(uint8_t* buffer, uint8_t address) {
return buffer[address];
}
static inline void subghz_protocol_decoder_nice_flor_s_magic_xor(uint8_t* p, uint8_t k) {
@@ -438,16 +432,28 @@ static inline void subghz_protocol_decoder_nice_flor_s_magic_xor(uint8_t* p, uin
}
uint64_t subghz_protocol_nice_flor_s_encrypt(uint64_t data, const char* file_name) {
// load and decrypt rainbow table from file to buffer array in RAM
if(!file_name) return SUBGHZ_NO_NICE_FLOR_S_RAINBOW_TABLE;
uint8_t buffer[SUBGHZ_NICE_FLOR_S_RAINBOW_TABLE_SIZE_BYTES] = {0};
uint8_t* buffer_ptr = (uint8_t*)&buffer;
if(subghz_keystore_raw_get_data(
file_name, 0, buffer, SUBGHZ_NICE_FLOR_S_RAINBOW_TABLE_SIZE_BYTES)) {
} else {
return SUBGHZ_NO_NICE_FLOR_S_RAINBOW_TABLE;
}
uint8_t* p = (uint8_t*)&data;
uint8_t k = 0;
for(uint8_t y = 0; y < 2; y++) {
k = subghz_protocol_nice_flor_s_get_byte_in_file(file_name, p[0] & 0x1f);
k = subghz_protocol_nice_flor_s_get_byte_from_buffer(buffer_ptr, p[0] & 0x1f);
subghz_protocol_decoder_nice_flor_s_magic_xor(p, k);
p[5] &= 0x0f;
p[0] ^= k & 0xe0;
k = subghz_protocol_nice_flor_s_get_byte_in_file(file_name, p[0] >> 3) + 0x25;
k = subghz_protocol_nice_flor_s_get_byte_from_buffer(buffer_ptr, p[0] >> 3) + 0x25;
subghz_protocol_decoder_nice_flor_s_magic_xor(p, k);
p[5] &= 0x0f;
@@ -475,6 +481,19 @@ static uint64_t
subghz_protocol_nice_flor_s_decrypt(SubGhzBlockGeneric* instance, const char* file_name) {
furi_assert(instance);
uint64_t data = instance->data;
// load and decrypt rainbow table from file to buffer array in RAM
if(!file_name) return SUBGHZ_NO_NICE_FLOR_S_RAINBOW_TABLE;
uint8_t buffer[SUBGHZ_NICE_FLOR_S_RAINBOW_TABLE_SIZE_BYTES] = {0};
uint8_t* buffer_ptr = (uint8_t*)&buffer;
if(subghz_keystore_raw_get_data(
file_name, 0, buffer, SUBGHZ_NICE_FLOR_S_RAINBOW_TABLE_SIZE_BYTES)) {
} else {
return SUBGHZ_NO_NICE_FLOR_S_RAINBOW_TABLE;
}
uint8_t* p = (uint8_t*)&data;
uint8_t k = 0;
@@ -489,12 +508,12 @@ static uint64_t
p[1] = k;
for(uint8_t y = 0; y < 2; y++) {
k = subghz_protocol_nice_flor_s_get_byte_in_file(file_name, p[0] >> 3) + 0x25;
k = subghz_protocol_nice_flor_s_get_byte_from_buffer(buffer_ptr, p[0] >> 3) + 0x25;
subghz_protocol_decoder_nice_flor_s_magic_xor(p, k);
p[5] &= 0x0f;
p[0] ^= k & 0x7;
k = subghz_protocol_nice_flor_s_get_byte_in_file(file_name, p[0] & 0x1f);
k = subghz_protocol_nice_flor_s_get_byte_from_buffer(buffer_ptr, p[0] & 0x1f);
subghz_protocol_decoder_nice_flor_s_magic_xor(p, k);
p[5] &= 0x0f;