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 71395acf5..d625ed22c 100644 --- a/applications/main/nfc/helpers/protocol_support/emv/emv_render.c +++ b/applications/main/nfc/helpers/protocol_support/emv/emv_render.c @@ -76,6 +76,21 @@ void nfc_render_emv_application(const EmvApplication* apl, FuriString* str) { furi_string_cat_printf(str, "\n"); } +void nfc_render_emv_application_interchange_profile(const EmvApplication* apl, FuriString* str) { + //TODO: CLEANUP AFERT BITLIB MERGE + uint16_t data = (apl->application_interchange_profile[0] << 8) | + (apl->application_interchange_profile[1]); + if(!data) { + furi_string_cat_printf(str, "No Interchange profile found\n"); + return; + } + + furi_string_cat_printf(str, "Interchange profile: "); + for(uint8_t i = 0; i < 2; i++) + furi_string_cat_printf(str, "%02X", apl->application_interchange_profile[i]); + furi_string_cat_printf(str, "\n"); +} + void nfc_render_emv_transactions(const EmvApplication* apl, FuriString* str) { if(apl->transaction_counter) furi_string_cat_printf(str, "Transactions count: %d\n", apl->transaction_counter); @@ -159,6 +174,7 @@ 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_application_interchange_profile(&data->emv_application, str); nfc_render_emv_currency(data->emv_application.currency_code, str); nfc_render_emv_country(data->emv_application.country_code, 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 d2dabe965..4f1e9bb09 100644 --- a/applications/main/nfc/helpers/protocol_support/emv/emv_render.h +++ b/applications/main/nfc/helpers/protocol_support/emv/emv_render.h @@ -15,6 +15,8 @@ void nfc_render_emv_name(const char* data, FuriString* str); void nfc_render_emv_application(const EmvApplication* data, FuriString* str); +void nfc_render_emv_application_interchange_profile(const EmvApplication* apl, FuriString* str); + void nfc_render_emv_extra(const EmvData* data, FuriString* str); void nfc_render_emv_country(uint16_t country_code, FuriString* str); diff --git a/applications/main/nfc/plugins/supported_cards/emv.c b/applications/main/nfc/plugins/supported_cards/emv.c index 8f26d8178..fd2c3fcb3 100644 --- a/applications/main/nfc/plugins/supported_cards/emv.c +++ b/applications/main/nfc/plugins/supported_cards/emv.c @@ -152,6 +152,11 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) { parsed = true; } + if((app.application_interchange_profile[1] >> 6) & 0b1) { + furi_string_cat_printf(parsed_data, "Mobile: yes\n"); + parsed = true; + } + if(!parsed) furi_string_cat_printf(parsed_data, "No data was parsed\n"); parsed = true; diff --git a/lib/nfc/protocols/emv/emv.c b/lib/nfc/protocols/emv/emv.c index 278828071..af208ea10 100644 --- a/lib/nfc/protocols/emv/emv.c +++ b/lib/nfc/protocols/emv/emv.c @@ -82,7 +82,6 @@ bool emv_load(EmvData* data, FlipperFormat* ff, uint32_t version) { flipper_format_read_string(ff, "Application name", temp_str); strcpy(app->application_name, furi_string_get_cstr(temp_str)); - //Read label flipper_format_read_string(ff, "Application label", temp_str); strcpy(app->application_label, furi_string_get_cstr(temp_str)); @@ -98,6 +97,10 @@ bool emv_load(EmvData* data, FlipperFormat* ff, uint32_t version) { if(!flipper_format_read_hex(ff, "AID", app->aid, aid_len)) break; + if(!flipper_format_read_hex( + ff, "Application interchange profile", app->application_interchange_profile, 2)) + break; + if(!flipper_format_read_hex(ff, "Country code", (uint8_t*)&app->country_code, 2)) break; if(!flipper_format_read_hex(ff, "Currency code", (uint8_t*)&app->currency_code, 2)) break; @@ -151,6 +154,10 @@ bool emv_save(const EmvData* data, FlipperFormat* ff) { if(!flipper_format_write_hex(ff, "AID", app.aid, aid_len)) break; + if(!flipper_format_write_hex( + ff, "Application interchange profile", app.application_interchange_profile, 2)) + break; + if(!flipper_format_write_hex(ff, "Country code", (uint8_t*)&app.country_code, 2)) break; if(!flipper_format_write_hex(ff, "Currency code", (uint8_t*)&app.currency_code, 2)) break; diff --git a/lib/nfc/protocols/emv/emv.h b/lib/nfc/protocols/emv/emv.h index bd195dde6..d7708e049 100644 --- a/lib/nfc/protocols/emv/emv.h +++ b/lib/nfc/protocols/emv/emv.h @@ -12,6 +12,7 @@ extern "C" { #define EMV_TAG_AID 0x4F #define EMV_TAG_PRIORITY 0x87 +#define EMV_TAG_APPL_INTERCHANGE_PROFILE 0x82 #define EMV_TAG_PDOL 0x9F38 #define EMV_TAG_APPL_LABEL 0x50 #define EMV_TAG_APPL_NAME 0x9F12 @@ -79,6 +80,7 @@ typedef struct { uint8_t priority; uint8_t aid[16]; uint8_t aid_len; + uint8_t application_interchange_profile[2]; char application_name[16 + 1]; char application_label[16 + 1]; char cardholder_name[24 + 1]; diff --git a/lib/nfc/protocols/emv/emv_poller_i.c b/lib/nfc/protocols/emv/emv_poller_i.c index 61efc6799..e72432287 100644 --- a/lib/nfc/protocols/emv/emv_poller_i.c +++ b/lib/nfc/protocols/emv/emv_poller_i.c @@ -115,6 +115,16 @@ static bool success = true; FURI_LOG_T(TAG, "found EMV_TAG_APP_PRIORITY %X: %d", tag, app->priority); break; + case EMV_TAG_APPL_INTERCHANGE_PROFILE: + furi_check(tlen == 2); + memcpy(app->application_interchange_profile, &buff[i], tlen); + success = true; + FURI_LOG_T(TAG, "found EMV_TAG_APPL_INTERCHANGE_PROFILE %x: ", tag); + for(size_t x = 0; x < tlen; x++) { + FURI_LOG_RAW_T("%02X ", app->application_interchange_profile[x]); + } + FURI_LOG_RAW_T("\r\n"); + break; case EMV_TAG_APPL_LABEL: memcpy(app->application_label, &buff[i], tlen); app->application_label[tlen] = '\0';