How to use ISO7816 select command with DESfire Ev1 card?

烈酒焚心 提交于 2019-12-14 03:52:50

问题


I have a DESfire Ev1 version 1.3 card and I'm trying to select a file using ISO7816 apdu style.

I have one file, with aid A0 A1 A2 and I can select it using both native or wrapped mode:

Native:

-> 5A A0 A1 A2
<- 00

Wrapped:

-> 90 5A 00 00 03 A0 A1 A2 00
<- 91 00

However, if I try to select it using ISO7816 style, I always get a file not found error:

ISO7816:

-> 00 A4 04 00 03 A0 A1 A2 00
-> 6A 82

When using ISO apdu, is the AID in a different format? How can I select this AID using it?


回答1:


From the docs:

This APDU selects an ISO Application by it’s ISO Application Identifier (AID). The ISO AID of DESFire is ”0xD2 76 00 00 85 01 00”. The full ISO AID has to be transmitted, partial selection is NOT supported. Other ISO AIDs are not supported by DESFire

This appears to contradict the fact that you have an AID 0xA0 0xA1 0xA2.

Seems like you need to be sending:

[CLA] [INS] [P1] [P2] [Len(AID)] [AID] 

Thus:

0x00 0xA4 0x04 0x00 0x07 0xD2 0x76 0x00 0x00 0x85 0x01 0x00

** EDIT **

Try ISO SELECT DIRECTORY instead:

This APDU selects a DESFire Application by it’s three byte DESFire Application Identifier (DESFire AID). ...

The functionality of the ISO SELECT DIRECTORY Command is compatible with the native DESFire “Select Application” command.

So:

0x00 0xA4 0x04 0x00 0x03 0xA0 0xA1 0xA2

(this was on the following page, and probably what you wanted in the first place.)

I think this is identical to what you had, minus the NUL at the end.



来源:https://stackoverflow.com/questions/27535344/how-to-use-iso7816-select-command-with-desfire-ev1-card

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!