Skip to content

Commit

Permalink
Define PSE and PPSE strings
Browse files Browse the repository at this point in the history
These definitions can be used to stringify DF Name (field 84) as well as
by the TAL.
  • Loading branch information
leonlynch committed Jan 25, 2024
1 parent fad8d4a commit ab98641
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/emv_fields.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

__BEGIN_DECLS

// Payment System Environment strings
#define EMV_PSE "1PAY.SYS.DDF01" ///< Payment System Environment (PSE)
#define EMV_PPSE "2PAY.SYS.DDF01" ///< Proximity Payment System Environment (PPSE)

// Application Priority Indicator
// See EMV 4.4 Book 1, 12.2.3, table 13
#define EMV_APP_PRIORITY_INDICATOR_MASK (0x0F)
Expand Down
9 changes: 9 additions & 0 deletions src/emv_strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ int emv_tlv_get_info(
"Identifies the name of the Dedicated File (DF) as described "
"in ISO/IEC 7816-4";
info->format = EMV_FORMAT_B;
if ((tlv->length == strlen(EMV_PSE) && strncmp((const char*)tlv->value, EMV_PSE, strlen(EMV_PSE))) ||
(tlv->length == strlen(EMV_PPSE) && strncmp((const char*)tlv->value, EMV_PPSE, strlen(EMV_PPSE)))
) {
if (value_str_len > tlv->length) {
memcpy(value_str, tlv->value, tlv->length);
value_str[tlv->length] = 0;
}
return 0;
}
return emv_aid_get_string(tlv->value, tlv->length, value_str, value_str_len);

case EMV_TAG_87_APPLICATION_PRIORITY_INDICATOR:
Expand Down
5 changes: 2 additions & 3 deletions src/emv_tal.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ int emv_tal_read_pse(
)
{
int r;
const uint8_t PSE[] = "1PAY.SYS.DDF01";
uint8_t fci[EMV_RAPDU_DATA_MAX];
size_t fci_len = sizeof(fci);
uint16_t sw1sw2;
Expand All @@ -66,8 +65,8 @@ int emv_tal_read_pse(
// SELECT Payment System Environment (PSE) Directory Definition File (DDF)
// See EMV 4.4 Book 1, 12.2.2
// See EMV 4.4 Book 1, 12.3.2
emv_debug_info("SELECT %s", PSE);
r = emv_ttl_select_by_df_name(ttl, PSE, sizeof(PSE) - 1, fci, &fci_len, &sw1sw2);
emv_debug_info("SELECT %s", EMV_PSE);
r = emv_ttl_select_by_df_name(ttl, EMV_PSE, strlen(EMV_PSE), fci, &fci_len, &sw1sw2);
if (r) {
emv_debug_trace_msg("emv_ttl_select_by_df_name() failed; r=%d", r);

Expand Down

0 comments on commit ab98641

Please sign in to comment.