Wednesday, 22 February 2023

EMV Transaction Flow

 Command to Get Processing Options:


Cla: 80 - command class
Ins: A8 - instruction code
P1: 00
P2: 00
Lc: 14 - length of the data field
Data: 831236A0400000000000140036D3EC3906430643 - data field with tag 83 containing the concatenation of values in the same order as they are listed in the PDOL element of the command to SELECT RESPONSE. 
Let us look into them in the same order as they are set out in the example:
Tag 9F66: Terminal Transaction Qualifiers: 36A04000 - the terminal tells about the card and its functionality.
Tag 9F02: Transaction Amount: 000000000100 - amount of the transaction. 1.00 rupees.
Tag 9F37: Unpredictable Number: 36D3CE38 - random number generated by the terminal.
Tag 5F2A: Terminal Country Code: 0524 - code of the transaction currency, Nepalese Rupee
Tag 9F1A: Terminal Country Code: 0524 - country of the terminal, Nepal

The Card's Response to the command to GPO follows:
example:

Response: 774C8202200057134704340000172834D21122011676600000671F5F2002202F5F3401019F100706011103A000009F2608A4933D887F0065CE9F2701809F3602004E9F6C023E009F6E04207000009000

Tag 77: Response Message Template Format 2 - format of the data presentation in the response
Tag 82: Application Interchange Profile: 2000 - profile of the card application where its functionality is described. 
Tag 57: Track 2 Equivalent Data: 4804123456789004D23122011676600000671F - equivalent of the magnetic stripe's second track. its structure includes:
  • PAN = 4804123456789004 - card number
  • Separator field = D - separator
  • Expiry Date = 23/12 - card expiry date.  Through December 2023.
  • Service Code = 201 - service code.
  • Discretionary Data = 1676600000671F - discretionary data where the CVV/CVV2 can be encoded.
Tag 5F20: Cardholder Name: 202F - name of the cardholder.
Tag 5F34: Application PAN Sequence Number: 01 - sequence number of the card. its initial purpose was to be used in the profiles that have more than one application on one physical card. Currently, it is often used in cryptographic procedures related to card authenticity verification by the issuer's host.
Tag 9F10: Issuer Application Data: 06011103A00000 - data of the card application. its structure includes:
  • Length Indicator = 06
  • Derivation Key Index = 01
  • Cryptogram Version Number = 11
  • Card Verification Results (CVR) = 03A00000 - dynamic object based on the previous steps of exchange within the transaction. 
Tag 9F26: Application Cryptogram (AC): A4933D887F0065CE
Tag 9F27: Cryptogram Information Data (CID): 80
Tag 9F36: Application Transaction Counter (ATC): 004E - card transactions counter. Digital value: 78.
Tag 9F6C: Card Transaction Qualifiers: 3E00  - CTQ describing the card capabilities.
Tag 9F6E: Form Factor Indicator: 20700000 - the object describes the technological type of this particular mean of payment.

Wednesday, 11 January 2023

PIN Block Of Card Transaction

What is Pin Block?

=> The PIN block is the block of encoded data (i.e., PAN, PIN ). When the cardholder inputs his PIN on any terminal (i.e., ATM, POS etc.), we need to make sure that this PIN is safe and securely reached from the terminal to the acquirer and then the issuer.

There are different standards for building such blocks of data. One of the most commonly used standards for encoding data is ISO 9564-1 format 0 (i.e.,  ANSI X9.8, VISA-1, and ECI-1).

The steps for encoding this type of Encoding are as follows:

  1. Format of a 16 bytes PIN is : [0][Length][PIN][Padding]
    where,
               [0] indicates ISO-0 format.
               [Length] is the one-byte length of the PIN.
               [PIN] is the provided PIN by the cardholder.
               [Padding] is generally used as 'F'.

    So, For a PIN '123456', the padded PIN should be: '06123456FFFFFFFF'.

  2. Format of a 16 bytes PAN is : [0000][12 digit PAN]
    where,
               [12-digit PAN] should be getting by choosing the 12 rightmost digits of the PAN number (excluding the check digit).

    So, For a PAN '1234567890123456', the padded PAN should be: '0000456789012345'.

  3. Calculate the XOR of the padded PIN and the padded PAN should be the PIN block.
    here, 06123456FFFFFFFF   XOR   0000456789012345 =  0612713176FEDCBA

    '0612713176FEDCBA' is the PIN block.
There are several other PIN Block formats out there. For more information please visit ISO 9564 .