Search code examples
smartcardapdusmartcard-readeremv

Doubts to understand C-APDU and R-APDU commands


I began to study basic notions of APDU command and response these days and i'm in a doubt about the use of the Lc and data track and his meaning. For example, if i write a command like: 00 A4 04 00 0E 31 50 41 59 2E 53 59 53 2E 44 44 46 30 31 00 I'd say that his (correct me case if i'm wrong)

  • CLA = is equal 00
  • INS = A4 that is SELECT
  • P1 = 04 by his first record name
  • P2 = 00 as default
  • Lc = 0E = exact length of 14 Bytes
  • Data = where it's my doubt
  • Le = 00 as default, and if it was equal another value what happens?

My doubt is about understand the clearly meaning of the Lc (exact command length), data and Le (maximum response length), how am i do to know what is this data instruction mean? and am i supposed to turn it into a text?


Solution

  • 6F 15 84 0E 31 50 41 59 2E 53 59 53 2E 44 44 46 30 31 A5 03 88 01 01 90 00 would be parsed as

     
    6F File Control Information (FCI) Template
    16 Length in hex
        84 Dedicated File (DF) Name
        0E Length in hex
            315041592E5359532E4444463031    =>1PAY.SYS.DDF01
        A5 File Control Information (FCI) Proprietary Template
        03 length in hex
            88 Short File Identifier (SFI)
            01 length in hex
                01
        90 00 Successful operation

    Simply, you can use this to parse your response TPDUs :-)