ic 卡获取帐号apdu指令_什么APDU命令获取卡ID

What APDU command gets 7 byte of card ID?

I use T=CL (ISO7816) pritocol with ISO14443 layer. On detect card I can see only 4 byte of card ID.

I searched, that is APDU command for gets card ID.

For example its:

0xFF, 0xCA, 0x00, 0x00, 0x00

but result of thouse command is: 6E 00, that on specifications of APDU answers tell that "Class not supported"

Then I find, that its APDU command may be as:

0x00, 0xCA, 0x00, 0x00, 0x00

this command return 6A 88

where 6A XX - "Wrong parameter(s) P1-P2" and 88 - "Referenced data not found"

What you think about it?

Thank you!

p.s. All command as: CLA, INS, P1, P2, LenData, Data

Other my command work normaly (such as sellect aplet and work with it), problem only at getting card ID

解决方案

The answer given before is wrong. This is because we are not talking about a ISO 7816 command here but a internal command of the PC/SC API.

The APDU "0xFF 0xCA 0x00 0x00 0x00" is in fact correct and I have cards for which I get a 7 byte answer. Please note that this will only work with contactless (RFID) cards because this UID is part of the radio protocol. Please note further that some chips will return a new random UID after each power up. This is for example true for my passport chip as well as my german national identity card and a countermeasure to prevent tracking of card holders. In theory such random UIDs shall begin with 0x08 but this is not always the case.

As the UID is a "internal" value of the protocol, the APDU in question is NOT sent to the card but is only a internal command (of the PC/SC Interface) to get the UID from the card reader driver. CLA 0xFF is generally not in normal use as it is only used for reserved for "Protocol Parameter Selection" (PPS). PC/SC abuses this CLA for internal commands.

The command here is the PC/SC internal "Get Data" Command, specified in Part 3, Section 3.2.2.1.3 of the PC/SC specification. Here P1 and P2 have special predefined meanings, so there is no point in trying different values. The standard only defineds P1=0,P2=0 for getting the UID and P1=1,P2=0 for "all historical bytes from the ATS of a ISO 14443 A card without CRC". Other values are not supported.

Interestingly the answer 0x6A 0x88 is not defined in the standard. 0x6a 0x81 would mean "Function not supported" which would be the case which cards which don't have a UID (standard mentions 7816-10 contact card). The two other defined answers (0x62 0x82 and 0x6C 0xXX) define a mismatch between the requested answer length and the actual amount of data and won't occur here, because we simply request any length data by specifying 0 in the last byte of the request.

So why it isn't working for the submitter I don't know. For me it works, some cards return 4 bytes, other return 7 bytes.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值