EMV dump save/load fix

This commit is contained in:
Methodius 2024-02-12 00:28:01 +09:00
parent 4a382bc1de
commit 08f096df24
No known key found for this signature in database
GPG Key ID: 122FA99A00B41679
4 changed files with 15 additions and 15 deletions

View File

@ -73,8 +73,10 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) {
const EmvApplication app = data->emv_application; const EmvApplication app = data->emv_application;
do { do {
if(strlen(app.payment_sys)) if(strlen(app.label))
furi_string_cat_printf(parsed_data, "\e#%s\n", app.payment_sys); furi_string_cat_printf(parsed_data, "\e#%s\n", app.label);
else if(strlen(app.name))
furi_string_cat_printf(parsed_data, "\e#%s\n", app.name);
else else
furi_string_cat_printf(parsed_data, "\e#%s\n", "EMV"); furi_string_cat_printf(parsed_data, "\e#%s\n", "EMV");
@ -93,8 +95,6 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) {
furi_string_free(pan); furi_string_free(pan);
} }
if(strlen(app.name)) furi_string_cat_printf(parsed_data, "Name: %s\n", app.name);
if(app.effective_month) { if(app.effective_month) {
char day[] = "??"; char day[] = "??";
if(app.effective_day) itoa(app.effective_day, day, 16); if(app.effective_day) itoa(app.effective_day, day, 16);

View File

@ -76,12 +76,12 @@ bool emv_load(EmvData* data, FlipperFormat* ff, uint32_t version) {
EmvApplication* app = &data->emv_application; EmvApplication* app = &data->emv_application;
if(!flipper_format_read_string(ff, "Name", temp_str)) break; flipper_format_read_string(ff, "Application name", temp_str);
strcpy(app->name, furi_string_get_cstr(temp_str)); strcpy(app->name, furi_string_get_cstr(temp_str));
//Read label //Read label
if(!flipper_format_read_string(ff, "Payment system", temp_str)) break; flipper_format_read_string(ff, "Application label", temp_str);
strcpy(app->payment_sys, furi_string_get_cstr(temp_str)); strcpy(app->label, furi_string_get_cstr(temp_str));
uint32_t pan_len; uint32_t pan_len;
if(!flipper_format_read_uint32(ff, "PAN length", &pan_len, 1)) break; if(!flipper_format_read_uint32(ff, "PAN length", &pan_len, 1)) break;
@ -131,9 +131,9 @@ bool emv_save(const EmvData* data, FlipperFormat* ff) {
if(!flipper_format_write_comment_cstr(ff, "EMV specific data:\n")) break; if(!flipper_format_write_comment_cstr(ff, "EMV specific data:\n")) break;
if(!flipper_format_write_string_cstr(ff, "Name", app.name)) break; if(!flipper_format_write_string_cstr(ff, "Application name", app.name)) break;
if(!flipper_format_write_string_cstr(ff, "Payment system", app.payment_sys)) break; if(!flipper_format_write_string_cstr(ff, "Application label", app.label)) break;
uint32_t pan_len = app.pan_len; uint32_t pan_len = app.pan_len;
if(!flipper_format_write_uint32(ff, "PAN length", &pan_len, 1)) break; if(!flipper_format_write_uint32(ff, "PAN length", &pan_len, 1)) break;

View File

@ -13,7 +13,7 @@ extern "C" {
#define EMV_TAG_AID 0x4F #define EMV_TAG_AID 0x4F
#define EMV_TAG_PRIORITY 0x87 #define EMV_TAG_PRIORITY 0x87
#define EMV_TAG_PDOL 0x9F38 #define EMV_TAG_PDOL 0x9F38
#define EMV_TAG_APPL_PAYMENT_SYS 0x50 #define EMV_TAG_APPL_LABEL 0x50
#define EMV_TAG_APPL_NAME 0x9F12 #define EMV_TAG_APPL_NAME 0x9F12
#define EMV_TAG_APPL_EFFECTIVE 0x5F25 #define EMV_TAG_APPL_EFFECTIVE 0x5F25
#define EMV_TAG_PIN_ATTEMPTS_COUNTER 0x9F17 #define EMV_TAG_PIN_ATTEMPTS_COUNTER 0x9F17
@ -79,7 +79,7 @@ typedef struct {
uint8_t aid[16]; uint8_t aid[16];
uint8_t aid_len; uint8_t aid_len;
char name[16 + 1]; char name[16 + 1];
char payment_sys[16 + 1]; char label[16 + 1];
uint8_t pan[10]; // card_number uint8_t pan[10]; // card_number
uint8_t pan_len; uint8_t pan_len;
uint8_t exp_day; uint8_t exp_day;

View File

@ -115,11 +115,11 @@ static bool
success = true; success = true;
FURI_LOG_T(TAG, "found EMV_TAG_APP_PRIORITY %X: %d", tag, app->priority); FURI_LOG_T(TAG, "found EMV_TAG_APP_PRIORITY %X: %d", tag, app->priority);
break; break;
case EMV_TAG_APPL_PAYMENT_SYS: case EMV_TAG_APPL_LABEL:
memcpy(app->payment_sys, &buff[i], tlen); memcpy(app->label, &buff[i], tlen);
app->payment_sys[tlen] = '\0'; app->label[tlen] = '\0';
success = true; success = true;
FURI_LOG_T(TAG, "found EMV_TAG_APPL_PAYMENT_SYS %x: %s", tag, app->payment_sys); FURI_LOG_T(TAG, "found EMV_TAG_APPL_LABEL %x: %s", tag, app->label);
break; break;
case EMV_TAG_APPL_NAME: case EMV_TAG_APPL_NAME:
furi_check(tlen < sizeof(app->name)); furi_check(tlen < sizeof(app->name));