cardholder name parsing prepared

This commit is contained in:
Methodius 2024-02-12 02:59:24 +09:00
parent 08f096df24
commit a9de06d6f2
No known key found for this signature in database
GPG Key ID: 122FA99A00B41679
5 changed files with 27 additions and 22 deletions

View File

@ -31,7 +31,7 @@ void nfc_render_emv_uid(const uint8_t* uid, const uint8_t uid_len, FuriString* s
void nfc_render_emv_data(const EmvData* data, FuriString* str) {
nfc_render_emv_pan(data->emv_application.pan, data->emv_application.pan_len, str);
nfc_render_emv_name(data->emv_application.name, str);
nfc_render_emv_name(data->emv_application.application_name, str);
}
void nfc_render_emv_pan(const uint8_t* data, const uint8_t len, FuriString* str) {

View File

@ -73,10 +73,10 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) {
const EmvApplication app = data->emv_application;
do {
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);
if(strlen(app.application_label))
furi_string_cat_printf(parsed_data, "\e#%s\n", app.application_label);
else if(strlen(app.application_name))
furi_string_cat_printf(parsed_data, "\e#%s\n", app.application_name);
else
furi_string_cat_printf(parsed_data, "\e#%s\n", "EMV");
@ -95,6 +95,9 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) {
furi_string_free(pan);
}
if(strlen(app.cardholder_name))
furi_string_cat_printf(parsed_data, "Cardholder name: %s\n", app.cardholder_name);
if(app.effective_month) {
char day[] = "??";
if(app.effective_day) itoa(app.effective_day, day, 16);

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;

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;

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: