Search code examples
smartcardapduemv

parse EMV application interchange profile for CVM list


I am trying to retrieve the CVM list from a EMV card. I have done the followings:

  • Selected AID
  • Get processing options

I have recieved the following response

77 0E 82 02 39 00 94 08 18 01 02 01 20 02 03 00 90 00 

I have parsed this reponse with in the following website and this is the parsed info:

82 Application Interchange Profile 
3900
94 Application File Locator (AFL)
1801020120020300

https://www.emvlab.org/tlvutils/?data=77+0E+82+02+39+00+94+08+18+01+02+01+20+02+03+00+90+00+

Now what's the next step to successfully retrieve the CVM lists ?


Solution

  • Application File locator must be explored deeper. For sample using EMV TLV parsing tool: https://iso8583.info/lib/EMV/TLVs

    ---
    # Cheef's parser.
    # Copyright (C) 2008-2017 Alexander Shevelev. https://iso8583.info/
    # lib   : "/lib/EMV/" - Integrated Circuit Card Specifications for Payment Systems
    # tool  : "TLVs"
    # stat  : 25 nodes, 0 lookup tables
    
    TLVs:#"770E8202390094081801020120020300" # EMV, Tag + Length + Value (TLV) series
    - x77:#"770E8202390094081801020120020300" # EMV, Template, Response Message Format 2
      - tag: "77"
      - len: "0E" #  // 14
      - val:#"8202390094081801020120020300" # Template, Response Message Format 2.
        - x82:#"82023900" # EMV, Application Interchange Profile (AIP)
          - tag: "82"
          - len: "02" #  // 2
          - val:#"3900" # Application Interchange Profile (AIP).
            - B01: "39"
              # __1_____ - bit 6, DDA supported
              # ___1____ - bit 5, Cardholder verification is supported
              # ____1___ - bit 4, Terminal Risk Management is to be performed
              # _______1 - bit 1, CDA supported
            - B02: "00" # RFU
        - x94:#"94081801020120020300" # EMV, Application File Locator (AFL)
          - tag: "94"
          - len: "08" #  // 8
          - val:#"1801020120020300" # Application File Locator (AFL).
            - S1:#"18010201" # AFL Record
              - B01: "18" # SFI [xxxxx___] // 3
              - B02: "01" # From record // 1
              - B03: "02" # To record // 2
              - B04: "01" # First hashed // 1
            - S2:#"20020300" # AFL Record
              - B01: "20" # SFI [xxxxx___] // 4
              - B02: "02" # From record // 2
              - B03: "03" # To record // 3
              - B04: "00" # First hashed
    

    Then you can READ RECORD(s) according to AFL Record definitions. For Sample ISO 7816-4 APDU command to READ RECORD from SFI 3 Record 01:

    rq:#"00B2011C00" # ISO 7816-3, Case 2
    - CLA: "00" # Class.
    - INS: "B2" # Instruction. // ISO 7816-4, Read Record
    - P1: "01" # Record number or record identifier
    - P2:#"1C" # Parameter 2.
      - SFI: "18" # bits 8 to 4, SFI [xxxxx___] // 3
      - ReadRecordNum: "04" # bits 3 to 1, Read Record number from P1 [_____100] // true
    - Le: "00" # Length of Expected Data.
    

    Q: Now what's the next step to successfully retrieve the CVM lists ?

    A: Read EMV Records from SFI(s) and parse TLV data response(s).

    EMV Tag 0x8E Cardholder Verification Method (CVM) List can be a part of Record.