cardholder name parsing prepared

This commit is contained in:
Methodius
2024-02-12 02:59:24 +09:00
parent 08f096df24
commit a9de06d6f2
5 changed files with 27 additions and 22 deletions
+5 -4
View File
@@ -77,11 +77,11 @@ bool emv_load(EmvData* data, FlipperFormat* ff, uint32_t version) {
EmvApplication* app = &data->emv_application;
flipper_format_read_string(ff, "Application name", temp_str);
strcpy(app->name, furi_string_get_cstr(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->label, furi_string_get_cstr(temp_str));
strcpy(app->application_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,10 @@ 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, "Application name", app.name)) break;
if(!flipper_format_write_string_cstr(ff, "Application name", app.application_name)) break;
if(!flipper_format_write_string_cstr(ff, "Application label", app.label)) break;
if(!flipper_format_write_string_cstr(ff, "Application label", app.application_label))
break;
uint32_t pan_len = app.pan_len;
if(!flipper_format_write_uint32(ff, "PAN length", &pan_len, 1)) break;
+3 -2
View File
@@ -78,8 +78,9 @@ typedef struct {
uint8_t priority;
uint8_t aid[16];
uint8_t aid_len;
char name[16 + 1];
char label[16 + 1];
char application_name[16 + 1];
char application_label[16 + 1];
char cardholder_name[24 + 1];
uint8_t pan[10]; // card_number
uint8_t pan_len;
uint8_t exp_day;
+11 -11
View File
@@ -116,17 +116,17 @@ static bool
FURI_LOG_T(TAG, "found EMV_TAG_APP_PRIORITY %X: %d", tag, app->priority);
break;
case EMV_TAG_APPL_LABEL:
memcpy(app->label, &buff[i], tlen);
app->label[tlen] = '\0';
memcpy(app->application_label, &buff[i], tlen);
app->application_label[tlen] = '\0';
success = true;
FURI_LOG_T(TAG, "found EMV_TAG_APPL_LABEL %x: %s", tag, app->label);
FURI_LOG_T(TAG, "found EMV_TAG_APPL_LABEL %x: %s", tag, app->application_label);
break;
case EMV_TAG_APPL_NAME:
furi_check(tlen < sizeof(app->name));
memcpy(app->name, &buff[i], tlen);
app->name[tlen] = '\0';
furi_check(tlen < sizeof(app->application_name));
memcpy(app->application_name, &buff[i], tlen);
app->application_name[tlen] = '\0';
success = true;
FURI_LOG_T(TAG, "found EMV_TAG_APPL_NAME %x: %s", tag, app->name);
FURI_LOG_T(TAG, "found EMV_TAG_APPL_NAME %x: %s", tag, app->application_name);
break;
case EMV_TAG_APPL_EFFECTIVE:
app->effective_year = buff[i];
@@ -190,11 +190,11 @@ static bool
break;
}
case EMV_TAG_CARDHOLDER_NAME: {
char name[27];
memcpy(name, &buff[i], tlen);
name[tlen] = '\0';
if(strlen(app->cardholder_name) > tlen) break;
memcpy(app->cardholder_name, &buff[i], tlen);
app->cardholder_name[tlen] = '\0';
success = true;
FURI_LOG_T(TAG, "found EMV_TAG_CARDHOLDER_NAME %x: %s", tag, name);
FURI_LOG_T(TAG, "found EMV_TAG_CARDHOLDER_NAME %x: %s", tag, app->cardholder_name);
break;
}
case EMV_TAG_PAN: