我正在尝试构建一个应用程序来读取/编码卡上的数据,如 PAN、到期日、客户名称、PIN 等信息,到目前为止,我发现我需要发送 APDU 命令来从卡读取数据,但似乎有没有明确的文档说明哪些命令用于什么目的以及按什么特定顺序使用,我无法找到 Mastercard/VISA 的规范。有什么文档可以参考吗?
谢谢,空
扩展另一个答案:
T-->C - 00A404000E315041592E5359532E444446303100 # select PSE
T<--C - response with FCI
T-->C - 00B2010C00
T<--C - reponse with record from selected file, read records starting from 1 until receive 6A83 (optional step in your case)
Run Code Online (Sandbox Code Playgroud)
T-->C - 00A4040007A000000003101000 # as example, Visa AID
T<--C - response with application DF FCI
Run Code Online (Sandbox Code Playgroud)
T-->C - 80A8000002830000 # check if PDOL presents on card, if not, only 8300 should be added to DATA filed of APDU
T<--C - 771282023C00940C0802020010010300180102019000 # just example reswponse, it will differ on different cards
Run Code Online (Sandbox Code Playgroud)
上面的 GET PROCESSING OPTIONS 响应是 TLV 编码的:
77 12 - response templait, containing response data
82 02 3C00 - AUC
94 0C 080202001001030018010201 - AFL
9000 - SW (Status Word), response ofapplication, telling you, that no errors occured
Run Code Online (Sandbox Code Playgroud)
请注意,对 GET PROCESSING OPTIONS 的响应可能会作为80模板返回,在这种情况下,您必须自己解析它:
80 0E - response templait, containing response data
3C00 - AUC (always 2 bytes long)
080202001001030018010201 - AFL
9000 - SW (Status Word), response ofapplication, telling you, that no errors
Run Code Online (Sandbox Code Playgroud)
您对 AFL 感兴趣,它指出了从哪里读取数据(文件和记录号):
94 0C
08020200
08 - SFI (Short File Identifier)
02 - first record in file
02 - last record in file
00 - no of records to be added to Static Data Authentication
10010300
10 - SFI
01 - first record in file
03 - last record in file (respectively, 3 records to be read - 01, 02, 03)
00 - no of records to be added to Static Data Authentication
18010201
18 - SFI
01 - first record in file
03 - last record of file
01 - count of records from first record to be used for Static Data Authentication (01 record must be used)
Run Code Online (Sandbox Code Playgroud)
SFI编码如下:
08 = 0000 1000 - first 5 bits are real SFI, it equals to 01, last 3 bits are always set to 0
Run Code Online (Sandbox Code Playgroud)
T-->C - 00B2020C00 # SFI = 01, record = 02
T<--C - response with record
T-->C - 00B2021400 # SFI = 02, record = 01
T<--C - response with record
T-->C - 00B2031400 # SFI = 02, record = 02
T<--C - response with record
etc until you process last AFL record...
Run Code Online (Sandbox Code Playgroud)
PAN、到期日、生效日期、轨道 2 等效数据等...通常位于设置为在 AFL 中的叹息数据身份验证中使用的记录中。
上面的示例适用于 T=1 协议。如果卡运行 T=0 协议,则响应每个假定 R-APDU(响应 APDU)包含数据字段的 APDU,卡将返回准备读取的字节数,并且您应该发出 GET RESPONSE 命令,如第 1 册中所述。 EMV 规范。
希望能帮助到你。