5

I am new to nfc related development.i want to build java application which used to read and write secure element in mifare desfire ev1 smart card.so i found free library.but the problem is i want to authenticate the smart card first.so i created some authenticate method and try with that.but it always says that class not supported error.in this code i want to load some keys to the application.i want to know first i want to create some application or not,if it want's to create application how it is possible to authenticate first.

These are my code

    /**
      * Load key
      */
   public String loadKey(byte[] key, char keyType) throws CardException
   {
       String res = null;
       System.out.println("Load Key");
       CommandAPDU apdu = this.reader.loadKey(this.decoder.decode(key), keyType);
       showAPDU(apdu.getBytes());
       ResponseAPDU r = send(apdu);
       showResponse(r.toString());
       if (r.getSW() == E_NO_ERROR) {
           System.out.println("Sucessfully Load  keys");
       } else{
           System.out.println("load keys failed");
       }
       res = APDUtoJSON(r).toString();
       return res;
   } 
//send command apdu
private ResponseAPDU send(CommandAPDU cmdApdu) throws CardException {
    return card.getBasicChannel().transmit(cmdApdu);
}

// read response in main class i call these methods
byte[] key = new byte[]{(byte) 0x1a, (byte) 0x1a, (byte) 0x1a, (byte) 0x1a,
                        (byte) 0x1a, (byte) 0x1a, (byte) 0x1a, (byte) 0x1a,
                        (byte) 0x1a, (byte) 0x1a, (byte) 0x1a, (byte) 0x1a,
                        (byte) 0x1a, (byte) 0x1a, (byte) 0x1a, (byte) 0x1a};
terminal.loadKey(key, 'a');
jlordo
  • 37,490
  • 6
  • 58
  • 83
Sajith Vijesekara
  • 1,324
  • 2
  • 17
  • 52

0 Answers0