Skip to content

Commit

Permalink
EMV dump save/load fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Leptopt1los committed Feb 11, 2024
1 parent 4a382bc commit 08f096d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions applications/main/nfc/plugins/supported_cards/emv.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) {
const EmvApplication app = data->emv_application;

do {
if(strlen(app.payment_sys))
furi_string_cat_printf(parsed_data, "\e#%s\n", app.payment_sys);
if(strlen(app.label))
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
furi_string_cat_printf(parsed_data, "\e#%s\n", "EMV");

Expand All @@ -93,8 +95,6 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) {
furi_string_free(pan);
}

if(strlen(app.name)) furi_string_cat_printf(parsed_data, "Name: %s\n", app.name);

if(app.effective_month) {
char day[] = "??";
if(app.effective_day) itoa(app.effective_day, day, 16);
Expand Down
10 changes: 5 additions & 5 deletions lib/nfc/protocols/emv/emv.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ bool emv_load(EmvData* data, FlipperFormat* ff, uint32_t version) {

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

//Read label
if(!flipper_format_read_string(ff, "Payment system", temp_str)) break;
strcpy(app->payment_sys, furi_string_get_cstr(temp_str));
flipper_format_read_string(ff, "Application label", temp_str);
strcpy(app->label, furi_string_get_cstr(temp_str));

uint32_t pan_len;
if(!flipper_format_read_uint32(ff, "PAN length", &pan_len, 1)) break;
Expand Down Expand Up @@ -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_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;
if(!flipper_format_write_uint32(ff, "PAN length", &pan_len, 1)) break;
Expand Down
4 changes: 2 additions & 2 deletions lib/nfc/protocols/emv/emv.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern "C" {
#define EMV_TAG_AID 0x4F
#define EMV_TAG_PRIORITY 0x87
#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_EFFECTIVE 0x5F25
#define EMV_TAG_PIN_ATTEMPTS_COUNTER 0x9F17
Expand Down Expand Up @@ -79,7 +79,7 @@ typedef struct {
uint8_t aid[16];
uint8_t aid_len;
char name[16 + 1];
char payment_sys[16 + 1];
char label[16 + 1];
uint8_t pan[10]; // card_number
uint8_t pan_len;
uint8_t exp_day;
Expand Down
8 changes: 4 additions & 4 deletions lib/nfc/protocols/emv/emv_poller_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ static bool
success = true;
FURI_LOG_T(TAG, "found EMV_TAG_APP_PRIORITY %X: %d", tag, app->priority);
break;
case EMV_TAG_APPL_PAYMENT_SYS:
memcpy(app->payment_sys, &buff[i], tlen);
app->payment_sys[tlen] = '\0';
case EMV_TAG_APPL_LABEL:
memcpy(app->label, &buff[i], tlen);
app->label[tlen] = '\0';
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;
case EMV_TAG_APPL_NAME:
furi_check(tlen < sizeof(app->name));
Expand Down

0 comments on commit 08f096d

Please sign in to comment.