简体   繁体   中英

Upload CAP file to smart card using APDU

I'm trying to install an applet (.cap file) into a smart card. I read that can be done using APDU. I created my applet using Netbeans and its aid is //aid/9AE9BE4D27/53.

Firstly build apdu that will select the installer applet :

0x00 0xA4 0x04 0x00 0X09 0xA0 0x00 0x00 0x00 0x62 0x03 0x01 0x08 0x01 0x7F ;

Then build the apdu which will create my applet (following this sctructure):

header: 0x80 0xb8 0x00 0x00

lc aid:

aid:

le: 0x7F;

I developed an application which can send an apdu command to a real card using channel.transmit(new CommandAPDU(apdu) . I guess that if I send the proper installation command, my .cap file should be installed in the card.

With this information can anyone help me to build the correct apdu to install my cap file into a real card?

Thank you.

If the card is using Global Platform, then it's not that simple, you need to authenticated against the card manager. Then you send multiple commands to load the .cap file (as APDU's may only contain 255 bytes payload - GP does not use extended length). Then you issue an INSTALL for INSTALL command to instantiate the Applet (using the instance AID).

Fortunately for you, there are open source libraries available that are build on top of javax.smartcardio . I would still recommend to read through the basics of Global Platform though, the documents can be obtained online without charge.

http://sourceforge.net/projects/gpj/

Yes if you are sending the correct command APDUs then you will be able to install it but in case of Global-platform cards you will need to create secure channel first and then you might send InstallForLoad and subsequent load/install commands. The sequence of steps will be:

  • Select card manager
  • Authenticate your card with SCP01/SCO02 whichever is supported by your card
  • Send InstallForInstall command
  • Send load commands
  • Send InstallForInstall command

Every commands should trail with 0x9000, that will means that command is executed successfully.

But as you are beginner so you should use some tools like GPShell to load your .cap file onto card and then try to analyze the APDUs that comes out after installation.

To install an applet and personalized it into the card you need mutual authenticate consists of INTERNAL AUTHENTICATE command and EXTERNAL AUTHENTICATE. Please read EMV CPS or GlobalPlatform for details.

You can also easily install an applet if you are using emulator. I have using JAVACos and it is very simple, and its support JC and GP libraries. Developed the applet in eclipse using library from JAVACos and emulate the applet using JAVACos emulator using scrypt for testing the applet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM