diff --git a/applications/main/nfc/application.fam b/applications/main/nfc/application.fam index 569c680eb..ab9690ec1 100644 --- a/applications/main/nfc/application.fam +++ b/applications/main/nfc/application.fam @@ -178,8 +178,8 @@ App( apptype=FlipperAppType.PLUGIN, entry_point="emv_plugin_ep", targets=["f7"], - requires=["nfc"], - sources=["plugins/supported_cards/emv.c"], + requires=["nfc", "storage"], + sources=["plugins/supported_cards/emv.c", "helpers/nfc_emv_parser.c"], ) App( diff --git a/applications/main/nfc/helpers/protocol_support/emv/emv_render.c b/applications/main/nfc/helpers/protocol_support/emv/emv_render.c index 2d76a3fb9..c1320a077 100644 --- a/applications/main/nfc/helpers/protocol_support/emv/emv_render.c +++ b/applications/main/nfc/helpers/protocol_support/emv/emv_render.c @@ -4,12 +4,41 @@ #include "nfc/nfc_app_i.h" void nfc_render_emv_info(const EmvData* data, NfcProtocolFormatType format_type, FuriString* str) { - nfc_render_iso14443_4a_info(data->iso14443_4a_data, format_type, str); - // nfc_render_emv_name(data->emv_application.name, str); - // nfc_render_emv_pan(data->emv_application.pan, data->emv_application.pan_len, str); - // nfc_render_emv_expired(&data->emv_application, str); + nfc_render_emv_header(str); + nfc_render_emv_uid( + data->iso14443_4a_data->iso14443_3a_data->uid, + data->iso14443_4a_data->iso14443_3a_data->uid_len, + str); - // if(format_type == NfcProtocolFormatTypeFull) nfc_render_emv_extra(data, str); + if(format_type == NfcProtocolFormatTypeFull) nfc_render_emv_extra(data, str); +} + +void nfc_render_emv_header(FuriString* str) { + furi_string_cat_printf(str, "\e#%s\n", "EMV"); +} + +void nfc_render_emv_uid(const uint8_t* uid, const uint8_t uid_len, FuriString* str) { + if(uid_len == 0) return; + + furi_string_cat_printf(str, "UID: "); + + for(uint8_t i = 0; i < uid_len; i++) { + furi_string_cat_printf(str, "%02X ", uid[i]); + } + + furi_string_cat_printf(str, "\n"); +} + +void nfc_render_emv_aid(const uint8_t* uid, const uint8_t uid_len, FuriString* str) { + if(uid_len == 0) return; + + furi_string_cat_printf(str, "UID: "); + + for(uint8_t i = 0; i < uid_len; i++) { + furi_string_cat_printf(str, "%02X ", uid[i]); + } + + furi_string_cat_printf(str, "\n"); } void nfc_render_emv_data(const EmvData* data, FuriString* str) { @@ -42,31 +71,13 @@ void nfc_render_emv_expired(const EmvApplication* apl, FuriString* str) { void nfc_render_emv_currency(uint16_t cur_code, FuriString* str) { if(!cur_code) return; - Storage* storage = furi_record_open(RECORD_STORAGE); - FuriString* currency_name = furi_string_alloc(); - if(nfc_emv_parser_get_currency_name(storage, cur_code, currency_name)) { - furi_string_cat_printf(str, "Currency: %s\n", furi_string_get_cstr(currency_name)); - } - furi_string_free(currency_name); - furi_record_close(RECORD_STORAGE); + furi_string_cat_printf(str, "Currency code: %04X\n", cur_code); } void nfc_render_emv_country(uint16_t country_code, FuriString* str) { if(!country_code) return; - Storage* storage = furi_record_open(RECORD_STORAGE); - FuriString* country_name = furi_string_alloc(); - if(nfc_emv_parser_get_country_name(storage, country_code, country_name)) { - furi_string_cat_printf(str, "Country: %s\n", furi_string_get_cstr(country_name)); - } - furi_string_free(country_name); - furi_record_close(RECORD_STORAGE); -} -void nfc_render_emv_name(const char* data, FuriString* str) { - if(strlen(data) == 0) return; - furi_string_cat_printf(str, "\e#"); - furi_string_cat(str, data); - furi_string_cat_printf(str, "\n"); + furi_string_cat_printf(str, "Country code: %04X\n", country_code); } void nfc_render_emv_application(const EmvApplication* apl, FuriString* str) { @@ -78,18 +89,10 @@ void nfc_render_emv_application(const EmvApplication* apl, FuriString* str) { } furi_string_cat_printf(str, "AID: "); - Storage* storage = furi_record_open(RECORD_STORAGE); - FuriString* aid_name = furi_string_alloc(); - if(nfc_emv_parser_get_aid_name(storage, apl->aid, len, aid_name)) { - furi_string_cat_printf(str, "%s", furi_string_get_cstr(aid_name)); - } else { - for(uint8_t i = 0; i < len; i++) furi_string_cat_printf(str, "%02X", apl->aid[i]); - } + for(uint8_t i = 0; i < len; i++) furi_string_cat_printf(str, "%02X", apl->aid[i]); furi_string_cat_printf(str, "\n"); - furi_string_free(aid_name); - furi_record_close(RECORD_STORAGE); } static void nfc_render_emv_pin_try_counter(uint8_t counter, FuriString* str) { @@ -171,8 +174,9 @@ void nfc_render_emv_transactions(const EmvApplication* apl, FuriString* str) { } void nfc_render_emv_extra(const EmvData* data, FuriString* str) { + nfc_render_emv_application(&data->emv_application, str); + nfc_render_emv_currency(data->emv_application.currency_code, str); nfc_render_emv_country(data->emv_application.country_code, str); - nfc_render_emv_application(&data->emv_application, str); nfc_render_emv_pin_try_counter(data->emv_application.pin_try_counter, str); } diff --git a/applications/main/nfc/helpers/protocol_support/emv/emv_render.h b/applications/main/nfc/helpers/protocol_support/emv/emv_render.h index 80f80d423..855acdc4a 100644 --- a/applications/main/nfc/helpers/protocol_support/emv/emv_render.h +++ b/applications/main/nfc/helpers/protocol_support/emv/emv_render.h @@ -23,4 +23,8 @@ void nfc_render_emv_country(uint16_t country_code, FuriString* str); void nfc_render_emv_currency(uint16_t cur_code, FuriString* str); -void nfc_render_emv_transactions(const EmvApplication* data, FuriString* str); \ No newline at end of file +void nfc_render_emv_transactions(const EmvApplication* data, FuriString* str); + +void nfc_render_emv_uid(const uint8_t* uid, const uint8_t uid_len, FuriString* str); + +void nfc_render_emv_header(FuriString* str); \ No newline at end of file diff --git a/applications/main/nfc/plugins/supported_cards/emv.c b/applications/main/nfc/plugins/supported_cards/emv.c index 99842f2d6..f0bdded4a 100644 --- a/applications/main/nfc/plugins/supported_cards/emv.c +++ b/applications/main/nfc/plugins/supported_cards/emv.c @@ -89,20 +89,20 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) { furi_string_cat(parsed_data, pan); furi_string_free(pan); - furi_string_cat_printf(parsed_data, "\nExp: %02X/%02X", app.exp_month, app.exp_year); + furi_string_cat_printf(parsed_data, "\nExp: %02X/%02X\n", app.exp_month, app.exp_year); FuriString* str = furi_string_alloc(); bool storage_readed = emv_get_country_name(app.country_code, str); if(storage_readed) - furi_string_cat_printf(parsed_data, "\nCountry: %s", furi_string_get_cstr(str)); + furi_string_cat_printf(parsed_data, "Country: %s\n", furi_string_get_cstr(str)); storage_readed = emv_get_currency_name(app.currency_code, str); if(storage_readed) - furi_string_cat_printf(parsed_data, "\nCurrency: %s", furi_string_get_cstr(str)); + furi_string_cat_printf(parsed_data, "Currency: %s\n", furi_string_get_cstr(str)); if(app.pin_try_counter != 0xFF) - furi_string_cat_printf(str, "\nPIN try left: %d\n", app.pin_try_counter); + furi_string_cat_printf(str, "PIN try left: %d\n", app.pin_try_counter); parsed = true; } while(false);