application interchange profile parse added

This commit is contained in:
Methodius 2024-02-12 16:35:56 +09:00
parent 14d3510d8e
commit b904555ebf
No known key found for this signature in database
GPG key ID: 122FA99A00B41679
6 changed files with 43 additions and 1 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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];

View file

@ -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';