Search |
||
While APDU is an entrance to Java Card...Posted by igormedeiros on August 14, 2007 at 10:05 AM PDT
APDU is defined at ISO 7816 and means "Application Protocol Data Units", where two structured string of bytes, a Command APDU (C-APDU) and a Response APDU (R-APDU) controls the communication between the host (like the Desktop computer) and the smart card, where the smart card receives a C-APDU from the host and returns C-APDU. In the C-APDU, the first four bytes are mandatory, they are:
If the C-APDU has data, you must specify it in LC field followed by DATA field bytes. In the R-APDU, the DATA field is optional and it is followed by two bytes that composes a status word SW1 and SW2.
At the end of a successful command, ISO 7816 defines 90 00 (SW1/SW2) as default response. Thinking in applet development, the first thing that you must to do is to plan the instructions that it will be able to process, each instruction will invoke a method by the INS field in the C-APDU. You can also, define exceptions in JC, only setting 2 bytes constants that will be sent as SW1 and SW1 bytes in R-APDU. JC API has an APDU class. The method getBuffer() retrieves the DATA filed byte array from C-APDU. To illustrate, lets take a look on how a JC applet handles APDU: ... // get the buffer byte array // selects the instruction (INS byte) // ISO7816.OFFSET_INS constant is defined by JC API } As a good practice, J2SE applications can encapsulates APDU codes in objects. JC RMI or Opencard Framework are similar solutions to help you on doing it. As you need plan which instructions your applet will be able to process, without understand APDU, you cannot go ahead with JC (now you can). With the next generation of Java Card, you will be able to avoid APDU codes, treating data over HTTPS or USB for example, so, while APDU is still an entrance to Java Card development, you need to know it. See you. »
Related Topics >>
J2ME Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|