Skip to content

Commit

Permalink
Stringify various EMV fields
Browse files Browse the repository at this point in the history
* Last Online Application Transaction Counter (ATC) Register; field 9F13
* Lower Consecutive Offline Limit; field 9F14
* Personal Identification Number (PIN) Try Counter; field 9F17
* Certification Authority Public Key Index; field 9F22
* Upper Consecutive Offline Limit; field 9F23
* Payment Account Reference (PAR); field 9F24

Also move Token Requestor ID (field 9F19) to its proper place.
  • Loading branch information
leonlynch committed Apr 22, 2024
1 parent 678dd75 commit 0a9fb4b
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 15 deletions.
80 changes: 69 additions & 11 deletions src/emv_strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ int emv_tlv_get_info(
return emv_cvm_list_get_string_list(tlv->value, tlv->length, value_str, value_str_len);

case EMV_TAG_8F_CERTIFICATION_AUTHORITY_PUBLIC_KEY_INDEX:
info->tag_name = "Certification Authority Public Key Index";
info->tag_name = "Certification Authority Public Key (CAPK) Index";
info->tag_desc =
"Identifies the certification authority's public key in "
"conjunction with the RID";
Expand Down Expand Up @@ -711,6 +711,26 @@ int emv_tlv_get_info(
info->format = EMV_FORMAT_ANS;
return emv_tlv_value_get_string(tlv, info->format, 16, value_str, value_str_len);

case EMV_TAG_9F13_LAST_ONLINE_ATC_REGISTER:
info->tag_name =
"Last Online Application Transaction Counter (ATC) Register";
info->tag_desc =
"Application Transaction Counter (ATC) "
"value of the last transaction that went "
"online";
info->format = EMV_FORMAT_B;
return 0;

case EMV_TAG_9F14_LOWER_CONSECUTIVE_OFFLINE_LIMIT:
info->tag_name = "Lower Consecutive Offline Limit";
info->tag_desc =
"Issuer-specified preference for the maximum "
"number of consecutive offline transactions for "
"this ICC application allowed in a terminal "
"with online capability";
info->format = EMV_FORMAT_B;
return 0;

case EMV_TAG_9F15_MCC:
info->tag_name = "Merchant Category Code (MCC)";
info->tag_desc = "Classifies the type of business being done by "
Expand All @@ -727,12 +747,29 @@ int emv_tlv_get_info(
info->format = EMV_FORMAT_ANS;
return emv_tlv_value_get_string(tlv, info->format, 15, value_str, value_str_len);

case EMV_TAG_9F17_PIN_TRY_COUNTER:
info->tag_name =
"Personal Identification Number (PIN) Try Counter";
info->tag_desc = "Number of PIN tries remaining";
info->format = EMV_FORMAT_B;
return 0;

case EMV_TAG_9F18_ISSUER_SCRIPT_IDENTIFIER:
info->tag_name = "Issuer Script Identifier";
info->tag_desc = "Identification of the Issuer Script";
info->format = EMV_FORMAT_B;
return 0;

case EMV_TAG_9F19_TOKEN_REQUESTOR_ID:
info->tag_name = "Token Requestor ID";
info->tag_desc =
"Uniquely identifies the pairing of the Token "
"Requestor with the Token Domain, as defined "
"in the EMV Payment Tokenisation "
"Framework";
info->format = EMV_FORMAT_N;
return 0;

case EMV_TAG_9F1A_TERMINAL_COUNTRY_CODE:
info->tag_name = "Terminal Country Code";
info->tag_desc =
Expand Down Expand Up @@ -780,16 +817,6 @@ int emv_tlv_get_info(
info->format = EMV_FORMAT_ANS;
return emv_tlv_value_get_string(tlv, info->format, 0, value_str, value_str_len);

case EMV_TAG_9F19_TOKEN_REQUESTOR_ID:
info->tag_name = "Token Requestor ID";
info->tag_desc =
"Uniquely identifies the pairing of the Token "
"Requestor with the Token Domain, as defined "
"in the EMV Payment Tokenisation "
"Framework";
info->format = EMV_FORMAT_N;
return 0;

case EMV_TAG_9F20_TRACK2_DISCRETIONARY_DATA:
info->tag_name = "Track 2 Discretionary Data";
info->tag_desc =
Expand All @@ -804,6 +831,37 @@ int emv_tlv_get_info(
info->format = EMV_FORMAT_N;
return emv_time_get_string(tlv->value, tlv->length, value_str, value_str_len);

case EMV_TAG_9F22_CERTIFICATION_AUTHORITY_PUBLIC_KEY_INDEX:
info->tag_name = "Certification Authority Public Key (CAPK) Index";
info->tag_desc =
"Identifies the certification authority's public key in "
"conjunction with the RID";
info->format = EMV_FORMAT_B;
return 0;

case EMV_TAG_9F23_UPPER_CONSECUTIVE_OFFLINE_LIMIT:
info->tag_name = "Upper Consecutive Offline Limit";
info->tag_desc =
"Issuer-specified preference for the maximum "
"number of consecutive offline transactions for "
"this ICC application allowed in a terminal "
"without online capability";
info->format = EMV_FORMAT_B;
return 0;

case EMV_TAG_9F24_PAYMENT_ACCOUNT_REFERENCE:
info->tag_name = "Payment Account Reference (PAR)";
info->tag_desc =
"A non-financial reference assigned to each "
"unique PAN and used to link a Payment "
"Account represented by that PAN to affiliated "
"Payment Tokens, as defined in the EMV "
"Tokenisation Framework. The PAR may be "
"assigned in advance of Payment Token "
"issuance.";
info->format = EMV_FORMAT_AN;
return emv_tlv_value_get_string(tlv, info->format, 29, value_str, value_str_len);

case EMV_TAG_9F25_LAST_4_DIGITS_OF_PAN:
info->tag_name = "Last 4 Digits of PAN";
info->tag_desc =
Expand Down
26 changes: 22 additions & 4 deletions src/emv_tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ __BEGIN_DECLS
/// EMV tag 8E Cardholder Verification Method (CVM) List. Template 70 or 77.
#define EMV_TAG_8E_CVM_LIST (0x8E)

/// EMV tag 8F Certification Authority Public Key Index. Template 70 or 77.
/// EMV tag 8F Certification Authority Public Key (CAPK) Index. Template 70 or 77.
#define EMV_TAG_8F_CERTIFICATION_AUTHORITY_PUBLIC_KEY_INDEX (0x8F)

/// EMV tag 90 Issuer Public Key Certificate. Template 70 or 77.
Expand Down Expand Up @@ -257,16 +257,28 @@ __BEGIN_DECLS
/// EMV tag 9F12 Application Preferred Name. Template 61 or A5.
#define EMV_TAG_9F12_APPLICATION_PREFERRED_NAME (0x9F12)

/// EMV tag 9F13 Last Online Application Transaction Counter (ATC) Register
#define EMV_TAG_9F13_LAST_ONLINE_ATC_REGISTER (0x9F13)

/// EMV tag 9F14 Lower Consecutive Offline Limit. Template 70 or 77.
#define EMV_TAG_9F14_LOWER_CONSECUTIVE_OFFLINE_LIMIT (0x9F14)

/// EMV tag 9F15 Merchant Category Code (MCC)
#define EMV_TAG_9F15_MCC (0x9F15)

/// EMV tag 9F16 Merchant Identifier
/// @remark Also used as the Card Acceptor Identification by ISO 8583. See EMV 4.4 Book 4, Annex C, Table 40
#define EMV_TAG_9F16_MERCHANT_IDENTIFIER (0x9F16)

/// EMV tag 9F17 Personal Identification Number (PIN) Try Counter
#define EMV_TAG_9F17_PIN_TRY_COUNTER (0x9F17)

/// EMV tag 9F18 Issuer Script Identifier. Template 71 or 72.
#define EMV_TAG_9F18_ISSUER_SCRIPT_IDENTIFIER (0x9F18)

/// EMV tag 9F19 Token Requestor ID. Template 70 or 77.
#define EMV_TAG_9F19_TOKEN_REQUESTOR_ID (0x9F19)

/// EMV tag 9F1A Terminal Country Code
#define EMV_TAG_9F1A_TERMINAL_COUNTRY_CODE (0x9F1A)

Expand All @@ -289,15 +301,21 @@ __BEGIN_DECLS
/// EMV tag 9F1F Track 1 Discretionary Data. Template 70 or 77.
#define EMV_TAG_9F1F_TRACK1_DISCRETIONARY_DATA (0x9F1F)

/// EMV tag 9F19 Token Requestor ID. Template 70 or 77.
#define EMV_TAG_9F19_TOKEN_REQUESTOR_ID (0x9F19)

/// EMV tag 9F20 Track 2 Discretionary Data. Template 70 or 77.
#define EMV_TAG_9F20_TRACK2_DISCRETIONARY_DATA (0x9F20)

/// EMV tag 9F21 Transaction Time
#define EMV_TAG_9F21_TRANSACTION_TIME (0x9F21)

/// EMV tag 9F22 Certification Authority Public Key (CAPK) Index
#define EMV_TAG_9F22_CERTIFICATION_AUTHORITY_PUBLIC_KEY_INDEX (0x9F22)

/// EMV tag 9F23 Upper Consecutive Offline Limit. Template 70 or 77.
#define EMV_TAG_9F23_UPPER_CONSECUTIVE_OFFLINE_LIMIT (0x9F23)

/// EMV tag 9F24 Payment Account Reference (PAR). Template 70 or 77.
#define EMV_TAG_9F24_PAYMENT_ACCOUNT_REFERENCE (0x9F24)

/// EMV tag 9F25 Last 4 Digits of PAN. Template 70 or 77.
#define EMV_TAG_9F25_LAST_4_DIGITS_OF_PAN (0x9F25)

Expand Down

0 comments on commit 0a9fb4b

Please sign in to comment.