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

View file

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

View file

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

View file

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