Moscow social card parser (#3464)

* Updated troyka layout (full version)
* Changed to furi func
* Small refactor
* Bitlib refactor
* Moved to API
* Rollback troyka parser
* Fix functions
* Added MSK Social card parser
* Parser func refactor start
* Layout E3 refactored
* Layout E4 refactored
* Layout 6 refactored
* Layout E5 refactored
* Layout 2 refactored
* Layout E5 fix
* Layout E6 refactored, valid_date need fix
* Layout E6 fix
* Layout FCB refactored
* Layout F0B refactored
* Layout 8 refactored
* Layout A refactored
* Layout C refactored
* Layout D refactored
* Layout E1 refactored
* Layout E2 refactored
* Old code cleanup
* Memory cleanup
* Unused imports cleanup
* Keys struct refactor
* Keys struct refactor
* Layout E1 fix
* Added debug info for layout and department
* Fix social card parse validation
* Added card number validation
* Added transport data ui improvements from Astrrra's troyka render func.

Co-authored-by: gornekich <n.gorbadey@gmail.com>
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
assasinfil
2024-10-06 19:33:07 +03:00
committed by GitHub
parent cfb9c991cb
commit 6ead328bb7
6 changed files with 349 additions and 25 deletions

View File

@@ -82,20 +82,6 @@ static const MfClassicKeyPair troika_4k_keys[] = {
{.a = 0xBB52F8CCE07F, .b = 0x6B6119752C70}, //40
};
static void troika_render_section_header(
FuriString* str,
const char* name,
uint8_t prefix_separator_cnt,
uint8_t suffix_separator_cnt) {
for(uint8_t i = 0; i < prefix_separator_cnt; i++) {
furi_string_cat_printf(str, ":");
}
furi_string_cat_printf(str, "[ %s ]", name);
for(uint8_t i = 0; i < suffix_separator_cnt; i++) {
furi_string_cat_printf(str, ":");
}
}
static bool troika_get_card_config(TroikaCardConfig* config, MfClassicType type) {
bool success = true;
@@ -212,23 +198,25 @@ static bool troika_parse(const NfcDevice* device, FuriString* parsed_data) {
FuriString* ground_result = furi_string_alloc();
FuriString* tat_result = furi_string_alloc();
bool result1 = mosgortrans_parse_transport_block(&data->block[32], metro_result);
bool result2 = mosgortrans_parse_transport_block(&data->block[28], ground_result);
bool result3 = mosgortrans_parse_transport_block(&data->block[16], tat_result);
bool is_metro_data_present =
mosgortrans_parse_transport_block(&data->block[32], metro_result);
bool is_ground_data_present =
mosgortrans_parse_transport_block(&data->block[28], ground_result);
bool is_tat_data_present = mosgortrans_parse_transport_block(&data->block[16], tat_result);
furi_string_cat_printf(parsed_data, "\e#Troyka card\n");
if(result1 && !furi_string_empty(metro_result)) {
troika_render_section_header(parsed_data, "Metro", 22, 21);
if(is_metro_data_present && !furi_string_empty(metro_result)) {
render_section_header(parsed_data, "Metro", 22, 21);
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(metro_result));
}
if(result2 && !furi_string_empty(ground_result)) {
troika_render_section_header(parsed_data, "Ediny", 22, 22);
if(is_ground_data_present && !furi_string_empty(ground_result)) {
render_section_header(parsed_data, "Ediny", 22, 22);
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(ground_result));
}
if(result3 && !furi_string_empty(tat_result)) {
troika_render_section_header(parsed_data, "TAT", 24, 23);
if(is_tat_data_present && !furi_string_empty(tat_result)) {
render_section_header(parsed_data, "TAT", 24, 23);
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(tat_result));
}
@@ -236,7 +224,7 @@ static bool troika_parse(const NfcDevice* device, FuriString* parsed_data) {
furi_string_free(ground_result);
furi_string_free(metro_result);
parsed = result1 || result2 || result3;
parsed = is_metro_data_present || is_ground_data_present || is_tat_data_present;
} while(false);
return parsed;