Skip to content

Commit 93862c8

Browse files
committed
Improve debug messages for EMV and TAL
* The EMV layer should emit debug messages to indicate the high level transaction flow regardless of whether emv-tool already prints its own * Use info messages for READ RECORD responses in TAL, which reverts the previous decision that that was too verbose
1 parent 437944a commit 93862c8

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/emv.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ int emv_build_candidate_list(
359359
return EMV_ERROR_INVALID_PARAMETER;
360360
}
361361

362-
emv_debug_info("SELECT Payment System Environment (PSE)");
362+
emv_debug_info("Select Payment System Environment (PSE)");
363363
r = emv_tal_read_pse(ctx->ttl, &ctx->supported_aids, app_list);
364364
if (r < 0) {
365365
emv_debug_trace_msg("emv_tal_read_pse() failed; r=%d", r);
@@ -439,6 +439,7 @@ int emv_select_application(
439439
ctx->selected_app = NULL;
440440
}
441441

442+
emv_debug_info("Select application index #%u", index);
442443
current_app = emv_app_list_remove_index(app_list, index);
443444
if (!current_app) {
444445
emv_debug_trace_msg("emv_app_list_remove_index() failed; index=%u", index);
@@ -521,6 +522,8 @@ int emv_initiate_application_processing(
521522
return EMV_ERROR_INVALID_PARAMETER;
522523
}
523524

525+
emv_debug_info("Initiate application processing");
526+
524527
// Clear existing ICC data and terminal data lists to avoid ambiguity
525528
emv_tlv_list_clear(&ctx->icc);
526529
emv_tlv_list_clear(&ctx->terminal);
@@ -803,6 +806,8 @@ int emv_read_application_data(struct emv_ctx_t* ctx)
803806
return EMV_ERROR_INVALID_PARAMETER;
804807
}
805808

809+
emv_debug_info("Read application data");
810+
806811
// Application File Locator (AFL) is required to read application records
807812
if (!ctx->afl) {
808813
// AFL not found; terminate session
@@ -842,7 +847,7 @@ int emv_read_application_data(struct emv_ctx_t* ctx)
842847
if (r) {
843848
emv_debug_trace_msg("emv_tal_read_afl_records() failed; r=%d", r);
844849
if (r < 0) {
845-
emv_debug_error("Error reading application data");
850+
emv_debug_error("Error while reading application data");
846851
if (r == EMV_TAL_ERROR_INTERNAL || r == EMV_TAL_ERROR_INVALID_PARAMETER) {
847852
r = EMV_ERROR_INTERNAL;
848853
} else {
@@ -851,7 +856,7 @@ int emv_read_application_data(struct emv_ctx_t* ctx)
851856
goto error;
852857
}
853858
if (r != EMV_TAL_RESULT_ODA_RECORD_INVALID) {
854-
emv_debug_error("Failed to read application data");
859+
emv_debug_error("Failure while reading application data");
855860
r = EMV_OUTCOME_CARD_ERROR;
856861
goto error;
857862
}
@@ -924,6 +929,8 @@ int emv_offline_data_authentication(struct emv_ctx_t* ctx)
924929
return EMV_ERROR_INVALID_PARAMETER;
925930
}
926931

932+
emv_debug_info("Offline data authentication");
933+
927934
// Ensure mandatory configuration fields are present and have valid length
928935
term_caps = emv_tlv_list_find_const(&ctx->config, EMV_TAG_9F33_TERMINAL_CAPABILITIES);
929936
if (!term_caps || term_caps->length != 3) {
@@ -1000,6 +1007,8 @@ int emv_processing_restrictions(struct emv_ctx_t* ctx)
10001007
return EMV_ERROR_INVALID_PARAMETER;
10011008
}
10021009

1010+
emv_debug_info("Processing restrictions");
1011+
10031012
// Ensure mandatory configuration fields are present and have valid length
10041013
term_app_version = emv_tlv_list_find_const(&ctx->config, EMV_TAG_9F09_APPLICATION_VERSION_NUMBER_TERMINAL);
10051014
if (!term_app_version || term_app_version->length != 2) {
@@ -1230,6 +1239,8 @@ int emv_terminal_risk_management(struct emv_ctx_t* ctx,
12301239
return EMV_ERROR_INVALID_PARAMETER;
12311240
}
12321241

1242+
emv_debug_info("Terminal risk management");
1243+
12331244
// Ensure mandatory configuration fields are present and have valid length
12341245
term_floor_limit = emv_tlv_list_find_const(&ctx->config, EMV_TAG_9F1B_TERMINAL_FLOOR_LIMIT);
12351246
if (!term_floor_limit || term_floor_limit->length != 4) {
@@ -1569,6 +1580,8 @@ int emv_card_action_analysis(struct emv_ctx_t* ctx)
15691580
return EMV_ODA_ERROR_INVALID_PARAMETER;
15701581
}
15711582

1583+
emv_debug_info("Card action analysis");
1584+
15721585
// Always decline offline for now until Terminal Action Analysis is fully
15731586
// implemented
15741587
ref_ctrl = EMV_TTL_GENAC_TYPE_AAC;

src/emv_tal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ static int emv_tal_read_sfi_records(
920920
return EMV_TAL_ERROR_READ_RECORD_PARSE_FAILED;
921921
}
922922
}
923-
emv_debug_trace_ber("READ RECORD from SFI %u, record %u", record, record_len, afl_entry->sfi, record_number);
923+
emv_debug_info_ber("READ RECORD [%u,%u] response", record, record_len, afl_entry->sfi, record_number);
924924

925925
r = emv_tlv_list_append(list, &record_list);
926926
if (r) {

0 commit comments

Comments
 (0)