mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 12:42:30 +04:00
parser fix
This commit is contained in:
@@ -178,8 +178,8 @@ App(
|
|||||||
apptype=FlipperAppType.PLUGIN,
|
apptype=FlipperAppType.PLUGIN,
|
||||||
entry_point="emv_plugin_ep",
|
entry_point="emv_plugin_ep",
|
||||||
targets=["f7"],
|
targets=["f7"],
|
||||||
requires=["nfc"],
|
requires=["nfc", "storage"],
|
||||||
sources=["plugins/supported_cards/emv.c"],
|
sources=["plugins/supported_cards/emv.c", "helpers/nfc_emv_parser.c"],
|
||||||
)
|
)
|
||||||
|
|
||||||
App(
|
App(
|
||||||
|
|||||||
@@ -4,12 +4,41 @@
|
|||||||
#include "nfc/nfc_app_i.h"
|
#include "nfc/nfc_app_i.h"
|
||||||
|
|
||||||
void nfc_render_emv_info(const EmvData* data, NfcProtocolFormatType format_type, FuriString* str) {
|
void nfc_render_emv_info(const EmvData* data, NfcProtocolFormatType format_type, FuriString* str) {
|
||||||
nfc_render_iso14443_4a_info(data->iso14443_4a_data, format_type, str);
|
nfc_render_emv_header(str);
|
||||||
// nfc_render_emv_name(data->emv_application.name, str);
|
nfc_render_emv_uid(
|
||||||
// nfc_render_emv_pan(data->emv_application.pan, data->emv_application.pan_len, str);
|
data->iso14443_4a_data->iso14443_3a_data->uid,
|
||||||
// nfc_render_emv_expired(&data->emv_application, str);
|
data->iso14443_4a_data->iso14443_3a_data->uid_len,
|
||||||
|
str);
|
||||||
|
|
||||||
// if(format_type == NfcProtocolFormatTypeFull) nfc_render_emv_extra(data, str);
|
if(format_type == NfcProtocolFormatTypeFull) nfc_render_emv_extra(data, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nfc_render_emv_header(FuriString* str) {
|
||||||
|
furi_string_cat_printf(str, "\e#%s\n", "EMV");
|
||||||
|
}
|
||||||
|
|
||||||
|
void nfc_render_emv_uid(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_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) {
|
||||||
@@ -42,31 +71,13 @@ void nfc_render_emv_expired(const EmvApplication* apl, FuriString* str) {
|
|||||||
void nfc_render_emv_currency(uint16_t cur_code, FuriString* str) {
|
void nfc_render_emv_currency(uint16_t cur_code, FuriString* str) {
|
||||||
if(!cur_code) return;
|
if(!cur_code) return;
|
||||||
|
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
furi_string_cat_printf(str, "Currency code: %04X\n", cur_code);
|
||||||
FuriString* currency_name = furi_string_alloc();
|
|
||||||
if(nfc_emv_parser_get_currency_name(storage, cur_code, currency_name)) {
|
|
||||||
furi_string_cat_printf(str, "Currency: %s\n", furi_string_get_cstr(currency_name));
|
|
||||||
}
|
|
||||||
furi_string_free(currency_name);
|
|
||||||
furi_record_close(RECORD_STORAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nfc_render_emv_country(uint16_t country_code, FuriString* str) {
|
void nfc_render_emv_country(uint16_t country_code, FuriString* str) {
|
||||||
if(!country_code) return;
|
if(!country_code) return;
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
||||||
FuriString* country_name = furi_string_alloc();
|
|
||||||
if(nfc_emv_parser_get_country_name(storage, country_code, country_name)) {
|
|
||||||
furi_string_cat_printf(str, "Country: %s\n", furi_string_get_cstr(country_name));
|
|
||||||
}
|
|
||||||
furi_string_free(country_name);
|
|
||||||
furi_record_close(RECORD_STORAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void nfc_render_emv_name(const char* data, FuriString* str) {
|
furi_string_cat_printf(str, "Country code: %04X\n", country_code);
|
||||||
if(strlen(data) == 0) return;
|
|
||||||
furi_string_cat_printf(str, "\e#");
|
|
||||||
furi_string_cat(str, data);
|
|
||||||
furi_string_cat_printf(str, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nfc_render_emv_application(const EmvApplication* apl, FuriString* str) {
|
void nfc_render_emv_application(const EmvApplication* apl, FuriString* str) {
|
||||||
@@ -78,18 +89,10 @@ void nfc_render_emv_application(const EmvApplication* apl, FuriString* str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
furi_string_cat_printf(str, "AID: ");
|
furi_string_cat_printf(str, "AID: ");
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
||||||
FuriString* aid_name = furi_string_alloc();
|
|
||||||
|
|
||||||
if(nfc_emv_parser_get_aid_name(storage, apl->aid, len, aid_name)) {
|
for(uint8_t i = 0; i < len; i++) furi_string_cat_printf(str, "%02X", apl->aid[i]);
|
||||||
furi_string_cat_printf(str, "%s", furi_string_get_cstr(aid_name));
|
|
||||||
} else {
|
|
||||||
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");
|
||||||
furi_string_free(aid_name);
|
|
||||||
furi_record_close(RECORD_STORAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nfc_render_emv_pin_try_counter(uint8_t counter, FuriString* str) {
|
static void nfc_render_emv_pin_try_counter(uint8_t counter, FuriString* str) {
|
||||||
@@ -171,8 +174,9 @@ void nfc_render_emv_transactions(const EmvApplication* apl, FuriString* str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void nfc_render_emv_extra(const EmvData* data, FuriString* str) {
|
void nfc_render_emv_extra(const EmvData* data, FuriString* str) {
|
||||||
|
nfc_render_emv_application(&data->emv_application, str);
|
||||||
|
|
||||||
nfc_render_emv_currency(data->emv_application.currency_code, str);
|
nfc_render_emv_currency(data->emv_application.currency_code, str);
|
||||||
nfc_render_emv_country(data->emv_application.country_code, str);
|
nfc_render_emv_country(data->emv_application.country_code, str);
|
||||||
nfc_render_emv_application(&data->emv_application, str);
|
|
||||||
nfc_render_emv_pin_try_counter(data->emv_application.pin_try_counter, str);
|
nfc_render_emv_pin_try_counter(data->emv_application.pin_try_counter, str);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,4 +23,8 @@ void nfc_render_emv_country(uint16_t country_code, FuriString* str);
|
|||||||
|
|
||||||
void nfc_render_emv_currency(uint16_t cur_code, FuriString* str);
|
void nfc_render_emv_currency(uint16_t cur_code, FuriString* str);
|
||||||
|
|
||||||
void nfc_render_emv_transactions(const EmvApplication* data, FuriString* str);
|
void nfc_render_emv_transactions(const EmvApplication* data, FuriString* str);
|
||||||
|
|
||||||
|
void nfc_render_emv_uid(const uint8_t* uid, const uint8_t uid_len, FuriString* str);
|
||||||
|
|
||||||
|
void nfc_render_emv_header(FuriString* str);
|
||||||
@@ -89,20 +89,20 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) {
|
|||||||
furi_string_cat(parsed_data, pan);
|
furi_string_cat(parsed_data, pan);
|
||||||
furi_string_free(pan);
|
furi_string_free(pan);
|
||||||
|
|
||||||
furi_string_cat_printf(parsed_data, "\nExp: %02X/%02X", app.exp_month, app.exp_year);
|
furi_string_cat_printf(parsed_data, "\nExp: %02X/%02X\n", app.exp_month, app.exp_year);
|
||||||
|
|
||||||
FuriString* str = furi_string_alloc();
|
FuriString* str = furi_string_alloc();
|
||||||
bool storage_readed = emv_get_country_name(app.country_code, str);
|
bool storage_readed = emv_get_country_name(app.country_code, str);
|
||||||
|
|
||||||
if(storage_readed)
|
if(storage_readed)
|
||||||
furi_string_cat_printf(parsed_data, "\nCountry: %s", furi_string_get_cstr(str));
|
furi_string_cat_printf(parsed_data, "Country: %s\n", furi_string_get_cstr(str));
|
||||||
|
|
||||||
storage_readed = emv_get_currency_name(app.currency_code, str);
|
storage_readed = emv_get_currency_name(app.currency_code, str);
|
||||||
if(storage_readed)
|
if(storage_readed)
|
||||||
furi_string_cat_printf(parsed_data, "\nCurrency: %s", furi_string_get_cstr(str));
|
furi_string_cat_printf(parsed_data, "Currency: %s\n", furi_string_get_cstr(str));
|
||||||
|
|
||||||
if(app.pin_try_counter != 0xFF)
|
if(app.pin_try_counter != 0xFF)
|
||||||
furi_string_cat_printf(str, "\nPIN try left: %d\n", app.pin_try_counter);
|
furi_string_cat_printf(str, "PIN try left: %d\n", app.pin_try_counter);
|
||||||
|
|
||||||
parsed = true;
|
parsed = true;
|
||||||
} while(false);
|
} while(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user