Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>IsoDep allows you to communicate over a ISO-14443-4 connection with the <code>transceive</code> operation. Over this protocol application data units (APDUs) are exchanged. The format is specified, you find a description on <a href="http://en.wikipedia.org/wiki/Smart_card_application_protocol_data_unit" rel="nofollow">Wikipedia.</a></p> <p>For exaple, to select an application on a smart card with a particular application identifier (AID) you would execute the following APDU command. The result simply indicates ok (9000) or an error.</p> <pre><code> byte[] SELECT = { (byte) 0x00, // CLA Class (byte) 0xA4, // INS Instruction (byte) 0x04, // P1 Parameter 1 (byte) 0x00, // P2 Parameter 2 (byte) 0x0A, // Length 0x63,0x64,0x63,0x00,0x00,0x00,0x00,0x32,0x32,0x31 // AID }; Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); IsoDep tag = IsoDep.get(tagFromIntent); tag.connect(); byte[] result = tag.transceive(SELECT); if (!(result[0] == (byte) 0x90 &amp;&amp; result[1] == (byte) 0x00)) throw new IOException("could not select applet"); </code></pre> <p>After the application has been selected, you can execute application specific commands. The programs are typically written in JavaCard which follows the GlobalPlatorm spec. The following example executes on the above selected application the method 4 (0x04) which returns a byte array of at most 11 bytes. This result is then converted to a string.</p> <pre><code> byte[] GET_STRING = { (byte) 0x80, // CLA Class 0x04, // INS Instruction 0x00, // P1 Parameter 1 0x00, // P2 Parameter 2 0x10 // LE maximal number of bytes expected in result }; result = tag.transceive(GET_STRING); int len = result.length; if (!(result[len-2]==(byte)0x90&amp;&amp;result[len-1]==(byte) 0x00)) throw new RuntimeException("could not retrieve msisdn"); byte[] data = new byte[len-2]; System.arraycopy(result, 0, data, 0, len-2); String str = new String(data).trim(); tag.close(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload