Commands.java
//---------------------------------------------------------------------------------------
// Useful tools for decoding smart card commands
// file:    Commands.java
// used by: ScanCmds.java
// For comments see header of ScanCmds.java.
//---------------------------------------------------------------------------------------

package scpack;

public class Commands {
  // coding and description of typical smart cards commands
  static final String CMDTABLE[] = {("0x00 0x44 ACTIVATE FILE ISO/IEC 7816-9"),
                                    ("0x00 0xE2 APPEND RECORD ISO/IEC 7816-4"),
                                    ("0x80 0x1E APPLICATION BLOCK EMV"),
                                    ("0x80 0x18 APPLICATION UNBLOCK EMV"),
                                    ("0xA0 0x24 CHANGE CHV GSM 11.11"),
                                    ("0x00 0x24 CHANGE REFERENCE DATA ISO/IEC 7816-8"),
                                    ("0x00 0xE0 CREATE FILE ISO/IEC 7816-9"),
                                    ("0x00 0x04 DEACTIVATE FILE ISO/IEC 7816-9"),
                                    ("0x00 0x44 DEACTIVATE FILE ISO/IEC 7816-9"),
                                    ("0x80 0xE4 DELETE OP"),
                                    ("0x00 0xE4 DELETE FILE ISO/IEC 7816-9"),
                                    ("0xA0 0x26 DISABLE CHV GSM 11.11"),
                                    ("0x00 0x26 DISABLE VERIFICATION REQUIREMENT ISO/IEC 7816-8"),
                                    ("0xA0 0x28 ENABLE CHV GSM 11.11"),
                                    ("0x00 0x28 ENABLE VERIFICATION REQUIREMENT ISO/IEC 7816-8"),
                                    ("0x00 0xC2 ENVELOPE ISO/IEC 7816-4"),
                                    ("0x00 0x0E ERASE BINARY ISO/IEC 7816-4"),
                                    ("0x00 0x82 EXTERNAL AUTHENTICATE ISO/IEC 7816-4"),
                                    ("0x80 0xAE GENERATE AUTHORISATION CRYPTOGRAM EMV"),
                                    ("0x00 0x46 GENERATE PUBLIC KEY PAIR ISO/IEC 7816-8"),
                                    ("0x00 0x84 GET CHALLENGE ISO/IEC 7816-4"),
                                    ("0x00 0xCA GET DATA ISO/IEC 7816-4"),
                                    ("0xA0 0xC0 GET RESPONSE GSM 11.11"),
                                    ("0x00 0xC0 GET RESPONSE ISO/IEC 7816-4"),
                                    ("0x80 0xF2 GET STATUS OP"),
                                    ("0xA0 0x32 INCREASE GSM 11.11"),
                                    ("0x80 0xE6 INSTALL OP"),
                                    ("0x00 0x88 INTERNAL AUTHENTICATE ISO/IEC 7816-4"),
                                    ("0xA0 0x04 INVALIDATE GSM 11.11"),
                                    ("0x80 0x82 ISSUER AUTHENTICATE EMV"),
                                    ("0x80 0xE8 LOAD OP"),
                                    ("0x00 0x70 MANAGE CHANNEL ISO/IEC 7816-4"),
                                    ("0x00 0x22 MANAGE SECURITY ENVIRONMENT ISO/IEC 7816-8"),
                                    ("0x00 0x82 MUTUAL AUTHENTICATE ISO/IEC 7816-8"),
                                    ("0x00 0x10 PERFORM SCQL OPERATION ISO/IEC 7816-7"),
                                    ("0x00 0x2A PERFORM SECURITY OPERATION ISO/IEC 7816-8"),
                                    ("0x00 0x12 PERFORM TRANSACTION OPERATION ISO/IEC 7816-7"),
                                    ("0x00 0x14 PERFORM USER OPERATION ISO/IEC 7816-7"),
                                    ("0x00 0xDA PUT DATA ISO/IEC 7816-4"),
                                    ("0x80 0xD8 PUT KEY OP"),
                                    ("0xA0 0xB0 READ BINARY GSM 11.11"),
                                    ("0x00 0xB0 READ BINARY ISO/IEC 7816-4"),
                                    ("0xA0 0xB2 READ RECORD  GSM 11.11"),
                                    ("0x00 0xB2 READ RECORD  ISO/IEC 7816-4"),
                                    ("0xA0 0x44 REHABILITATE GSM 11.11"),
                                    ("0x00 0x2C RESET RETRY COUNTER ISO/IEC 7816-8"),
                                    ("0xA0 0x88 RUN GSM ALGORITHM GSM 11.11"),
                                    ("0x00 0xA0 SEARCH BINARY ISO/IEC 7816-9"),
                                    ("0x00 0xA2 SEARCH RECORD ISO/IEC 7816-9"),
                                    ("0xA0 0xA2 SEEK GSM 11.11"),
                                    ("0xA0 0xA4 SELECT GSM 11.11"),
                                    ("0x00 0xA4 SELECT ISO/IEC 7816-4"),
                                    ("0x80 0xF0 SET STATUS OP"),
                                    ("0xA0 0xFA SLEEP GSM 11.11"),
                                    ("0xA0 0xF2 STATUS GSM 11.11"),
                                    ("0x00 0xFE TERMINATE CARD USAGE ISO/IEC 7816-9"),
                                    ("0x00 0xE6 TERMINATE DF ISO/IEC 7816-9"),
                                    ("0x00 0xE8 TERMINATE EF ISO/IEC 7816-9"),
                                    ("0xA0 0x2C UNBLOCK CHV GSM 11.11"),
                                    ("0xA0 0xD6 UPDATE BINARY GSM 11.11"),
                                    ("0x00 0xD6 UPDATE BINARY ISO/IEC 7816-4"),
                                    ("0xA0 0xDC UPDATE RECORD GSM 11.11"),
                                    ("0x00 0xDC UPDATE RECORD ISO/IEC 7816-4"),
                                    ("0x00 0x20 VERIFY ISO/IEC 7816-4"),
                                    ("0x80 0x20 VERIFY EMV"),
                                    ("0xA0 0x20 VERIFY CHV GSM 11.11"),
                                    ("0x00 0xD0 WRITE BINARY ISO/IEC 7816-4"),
                                    ("0x00 0xD2 WRITE RECORD ISO/IEC 7816-4")};

  /** decode a smart card on the basis of class and instruction
   *  @param  cla class byte
   *  @param  ins instruction byte
   *  @return string with the decoded command
   */
  public static String decodeCmd(int cla, int ins) {
    int i, n;
    String command = "", clains, s;

    clains = "0x" + ScanCmds.IntTo2CharHexString(cla);
    clains = clains + " 0x" + ScanCmds.IntTo2CharHexString(ins);

    for (i = 0; i < CMDTABLE.length; i++) {
      if (CMDTABLE[i].startsWith(clains) == true) command = CMDTABLE[i];
    }  // for

    return command;
  } // decodeCmd

} // class
//---------------------------------------------------------------------------------------




Commands.java