mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-25 22:32:29 +03:00
Fix PDOL parsing
This commit is contained in:
parent
ec356626fa
commit
d195de502e
@ -29,18 +29,6 @@ void nfc_render_emv_uid(const uint8_t* uid, const uint8_t uid_len, FuriString* s
|
|||||||
furi_string_cat_printf(str, "\n");
|
furi_string_cat_printf(str, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void nfc_render_emv_aid(const uint8_t* uid, const uint8_t uid_len, FuriString* str) {
|
|
||||||
if(uid_len == 0) return;
|
|
||||||
|
|
||||||
furi_string_cat_printf(str, "UID: ");
|
|
||||||
|
|
||||||
for(uint8_t i = 0; i < uid_len; i++) {
|
|
||||||
furi_string_cat_printf(str, "%02X ", uid[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
furi_string_cat_printf(str, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void nfc_render_emv_data(const EmvData* data, FuriString* str) {
|
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_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.name, str);
|
||||||
@ -83,7 +71,7 @@ void nfc_render_emv_application(const EmvApplication* apl, FuriString* str) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_string_cat_printf(str, " AID:");
|
furi_string_cat_printf(str, "AID: ");
|
||||||
for(uint8_t i = 0; i < len; i++) furi_string_cat_printf(str, "%02X", apl->aid[i]);
|
for(uint8_t i = 0; i < len; i++) furi_string_cat_printf(str, "%02X", apl->aid[i]);
|
||||||
furi_string_cat_printf(str, "\n");
|
furi_string_cat_printf(str, "\n");
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#define TAG "EMVPoller"
|
#define TAG "EMVPoller"
|
||||||
|
|
||||||
|
// "Terminal" parameters, which could be requested by card
|
||||||
const PDOLValue pdol_term_info = {0x9F59, {0xC8, 0x80, 0x00}}; // Terminal transaction information
|
const PDOLValue pdol_term_info = {0x9F59, {0xC8, 0x80, 0x00}}; // Terminal transaction information
|
||||||
const PDOLValue pdol_term_type = {0x9F5A, {0x00}}; // Terminal transaction type
|
const PDOLValue pdol_term_type = {0x9F5A, {0x00}}; // Terminal transaction type
|
||||||
const PDOLValue pdol_merchant_type = {0x9F58, {0x01}}; // Merchant type indicator
|
const PDOLValue pdol_merchant_type = {0x9F58, {0x01}}; // Merchant type indicator
|
||||||
@ -392,18 +393,25 @@ static void emv_prepare_pdol(APDU* dest, APDU* src) {
|
|||||||
uint8_t tlen = 0;
|
uint8_t tlen = 0;
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
while(i < src->size) {
|
while(i < src->size) {
|
||||||
bool tag_found = emv_parse_tag(src->data, src->size, &tag, &tlen, &i);
|
bool tag_found = false;
|
||||||
if(tag_found) {
|
if(!emv_parse_tag(src->data, src->size, &tag, &tlen, &i)) {
|
||||||
for(uint8_t j = 0; j < COUNT_OF(pdol_values); j++) {
|
FURI_LOG_T(TAG, "Parsing PDOL failed at 0x%x", i);
|
||||||
if(tag == pdol_values[j]->tag) {
|
dest->size = 0;
|
||||||
memcpy(dest->data + dest->size, pdol_values[j]->data, tlen);
|
return;
|
||||||
dest->size += tlen;
|
}
|
||||||
break;
|
|
||||||
}
|
furi_check(dest->size + tlen < sizeof(dest->data));
|
||||||
|
for(uint8_t j = 0; j < COUNT_OF(pdol_values); j++) {
|
||||||
|
if(tag == pdol_values[j]->tag) {
|
||||||
|
memcpy(dest->data + dest->size, pdol_values[j]->data, tlen);
|
||||||
|
dest->size += tlen;
|
||||||
|
tag_found = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if(!tag_found) {
|
||||||
// Unknown tag, fill zeros
|
// Unknown tag, fill zeros
|
||||||
furi_check(dest->size + tlen < sizeof(dest->data));
|
|
||||||
memset(dest->data + dest->size, 0, tlen);
|
memset(dest->data + dest->size, 0, tlen);
|
||||||
dest->size += tlen;
|
dest->size += tlen;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user