mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge pull request #942 from Dmitry422/dev
Alutech_at_4n and Nice Flor S protocols acceleration and Debug status for desktop clock
This commit is contained in:
@@ -105,7 +105,11 @@ static void desktop_clock_draw_callback(Canvas* canvas, void* context) {
|
||||
}
|
||||
|
||||
char buffer[20];
|
||||
snprintf(buffer, sizeof(buffer), "%02u:%02u", hour, desktop->clock.minute);
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||
snprintf(buffer, sizeof(buffer), "D %02u:%02u", hour, desktop->clock.minute);
|
||||
} else {
|
||||
snprintf(buffer, sizeof(buffer), "%02u:%02u", hour, desktop->clock.minute);
|
||||
}
|
||||
|
||||
view_port_set_width(
|
||||
desktop->clock_viewport,
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
#define TAG "SubGhzProtocoAlutech_at_4n"
|
||||
|
||||
#define SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE 0xFFFFFFFF
|
||||
#define SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE 0xFFFFFFFFFFFFFFFF
|
||||
#define SUBGHZ_ALUTECH_AT_4N_RAINBOW_TABLE_SIZE_BYTES 32
|
||||
|
||||
static const SubGhzBlockConst subghz_protocol_alutech_at_4n_const = {
|
||||
.te_short = 400,
|
||||
@@ -140,27 +141,21 @@ LevelDuration subghz_protocol_encoder_alutech_at_4n_yield(void* context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 magic data buffer
|
||||
* @param number_alutech_at_4n_magic_data number in the array
|
||||
* @return alutech_at_4n_magic_data
|
||||
*/
|
||||
static uint32_t subghz_protocol_alutech_at_4n_get_magic_data_in_file(
|
||||
const char* file_name,
|
||||
static uint32_t subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(
|
||||
uint8_t* buffer,
|
||||
uint8_t number_alutech_at_4n_magic_data) {
|
||||
if(!strcmp(file_name, "")) return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
|
||||
|
||||
uint8_t buffer[sizeof(uint32_t)] = {0};
|
||||
uint32_t address = number_alutech_at_4n_magic_data * sizeof(uint32_t);
|
||||
uint32_t alutech_at_4n_magic_data = 0;
|
||||
|
||||
if(subghz_keystore_raw_get_data(file_name, address, buffer, sizeof(uint32_t))) {
|
||||
for(size_t i = 0; i < sizeof(uint32_t); i++) {
|
||||
alutech_at_4n_magic_data = (alutech_at_4n_magic_data << 8) | buffer[i];
|
||||
}
|
||||
} else {
|
||||
alutech_at_4n_magic_data = SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
|
||||
for(size_t i = address; i < (address + sizeof(uint32_t)); i++) {
|
||||
alutech_at_4n_magic_data = (alutech_at_4n_magic_data << 8) | buffer[i];
|
||||
}
|
||||
|
||||
return alutech_at_4n_magic_data;
|
||||
}
|
||||
|
||||
@@ -195,17 +190,29 @@ 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) {
|
||||
// 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;
|
||||
|
||||
if(subghz_keystore_raw_get_data(
|
||||
file_name, 0, buffer, SUBGHZ_ALUTECH_AT_4N_RAINBOW_TABLE_SIZE_BYTES)) {
|
||||
} else {
|
||||
return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
|
||||
}
|
||||
|
||||
uint8_t* p = (uint8_t*)&data;
|
||||
uint32_t data1 = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
|
||||
uint32_t data2 = p[4] << 24 | p[5] << 16 | p[6] << 8 | p[7];
|
||||
uint32_t data3 = 0;
|
||||
uint32_t magic_data[] = {
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 0),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 1),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 2),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 3),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 4),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 5)};
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 0),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 1),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 2),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 3),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 4),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 5)};
|
||||
|
||||
uint32_t i = magic_data[0];
|
||||
do {
|
||||
@@ -230,17 +237,29 @@ 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) {
|
||||
// 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;
|
||||
|
||||
if(subghz_keystore_raw_get_data(
|
||||
file_name, 0, buffer, SUBGHZ_ALUTECH_AT_4N_RAINBOW_TABLE_SIZE_BYTES)) {
|
||||
} else {
|
||||
return SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE;
|
||||
}
|
||||
|
||||
uint8_t* p = (uint8_t*)&data;
|
||||
uint32_t data1 = 0;
|
||||
uint32_t data2 = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
|
||||
uint32_t data3 = p[4] << 24 | p[5] << 16 | p[6] << 8 | p[7];
|
||||
uint32_t magic_data[] = {
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 6),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 4),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 5),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 1),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 2),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_in_file(file_name, 0)};
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 6),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 4),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 5),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 1),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 2),
|
||||
subghz_protocol_alutech_at_4n_get_magic_data_from_buffer(buffer_ptr, 0)};
|
||||
|
||||
do {
|
||||
data1 = data1 + magic_data[0];
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
#define TAG "SubGhzProtocolNiceFlorS"
|
||||
|
||||
#define NICE_ONE_COUNT_BIT 72
|
||||
#define NICE_ONE_NAME "Nice One"
|
||||
#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;
|
||||
|
||||
Reference in New Issue
Block a user