Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

3DES

JavaCard Applet Development Related Questions and Answers.
deepanshsinghal
Posts: 44
Joined: Thu Apr 06, 2017 8:01 am
Points :460
Contact:

Re: 3DES

Post by deepanshsinghal » Fri Jun 02, 2017 3:00 am

UNKNwYSHSA wrote:
deepanshsinghal wrote:
UNKNwYSHSA wrote:What the version of your JCIDE?
This is mine:


Are you using protocol T=0?

There's wrong with my applet source code.
The code for INS 0x00 shall be:

Code: Select all

      case (byte) 0x00:
         apdu.setIncomingAndReceive();
         key.setKey(buf, ISO7816.OFFSET_CDATA);
         break;

And all will be OK.


Thanks a lot.......
That's started working

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: 3DES

Post by UNKNwYSHSA » Fri Jun 02, 2017 3:01 am

OK, OK. :D
sense and simplicity

deepanshsinghal
Posts: 44
Joined: Thu Apr 06, 2017 8:01 am
Points :460
Contact:

Re: 3DES

Post by deepanshsinghal » Fri Jun 02, 2017 3:10 am

Now finally i can complete my whole project by next week....
You are really life saver... and i will ping you more for more troubles

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: 3DES

Post by UNKNwYSHSA » Fri Jun 02, 2017 3:13 am

It's my pleasure, my friend!
sense and simplicity

deepanshsinghal
Posts: 44
Joined: Thu Apr 06, 2017 8:01 am
Points :460
Contact:

Re: 3DES

Post by deepanshsinghal » Tue Jun 06, 2017 8:46 am

Hi,
I started working on ARPC verification. For that i need to generate my own ARPC in chip card. i worked on that as per emv standards.

Code: Select all

public void generateSecondAC(APDU apdu, byte[] apduBuffer) {
      byte[] iad = new byte[8];
      byte[] atcBuffer = new byte[8];

      // First 2 bits of P1 specify the type
      // These bits also have to be returned, as the Cryptogram Information
      // Data (CID);
      // See Book 3, Sect 6.5.5.4 of the Common Core Definitions.
      byte cid = (byte) (apduBuffer[OFFSET_P1] & 0xC0);
      if (cid == RFU_CODE || cid == ARQC_CODE) {
         // not a request for TC or AAC
         ISOException.throwIt(SW_WRONG_P1P2);
      }

      short dataLen = apduBuffer[OFFSET_LC];
      Util.arrayCopy(apduBuffer, (short) 5, onlineARPC, (short) 0, (short) 8);
      
      Util.arrayCopy(apduBuffer, (short) 0x0D, responseCode, (short) 0, (short) 2);
      
      byte[] Y = new byte[8];
      // XOR between ARQC and Response Code as per mentioned in ARPC method 1 EMV book 2 (8.2.1)
      Y = xor(chipMAC, responseCode);
      
      Signature sig = Signature.getInstance(Signature.ALG_DES_MAC8_ISO9797_1_M2_ALG3, false);
      sig.init(theCrypto.sk, Signature.MODE_SIGN);
      
      short resultLen = sig.sign(Y, (short) 0, (short) (8), apduBuffer, (short) (dataLen + 10));
      
      apdu.setOutgoingAndSend((short) (dataLen + 10), (short) (resultLen));
      
   }
   
   public static byte[] xor(byte[] arqc, byte[] responseCode) {

      byte[] c = new byte[arqc.length];
      for (short i = 0; i < arqc.length; i++) {
         c[i] = (byte) (arqc[i] ^ responseCode[i]);
      }

      return c;
   }
   


But it is not generating correct. Can you review it

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: 3DES

Post by UNKNwYSHSA » Wed Jun 07, 2017 9:49 pm

deepanshsinghal wrote:Hi,
I started working on ARPC verification. For that i need to generate my own ARPC in chip card. i worked on that as per emv standards.

Code: Select all

public void generateSecondAC(APDU apdu, byte[] apduBuffer) {
      byte[] iad = new byte[8];
      byte[] atcBuffer = new byte[8];

      // First 2 bits of P1 specify the type
      // These bits also have to be returned, as the Cryptogram Information
      // Data (CID);
      // See Book 3, Sect 6.5.5.4 of the Common Core Definitions.
      byte cid = (byte) (apduBuffer[OFFSET_P1] & 0xC0);
      if (cid == RFU_CODE || cid == ARQC_CODE) {
         // not a request for TC or AAC
         ISOException.throwIt(SW_WRONG_P1P2);
      }

      short dataLen = apduBuffer[OFFSET_LC];
      Util.arrayCopy(apduBuffer, (short) 5, onlineARPC, (short) 0, (short) 8);
      
      Util.arrayCopy(apduBuffer, (short) 0x0D, responseCode, (short) 0, (short) 2);
      
      byte[] Y = new byte[8];
      // XOR between ARQC and Response Code as per mentioned in ARPC method 1 EMV book 2 (8.2.1)
      Y = xor(chipMAC, responseCode);
      
      Signature sig = Signature.getInstance(Signature.ALG_DES_MAC8_ISO9797_1_M2_ALG3, false);
      sig.init(theCrypto.sk, Signature.MODE_SIGN);
      
      short resultLen = sig.sign(Y, (short) 0, (short) (8), apduBuffer, (short) (dataLen + 10));
      
      apdu.setOutgoingAndSend((short) (dataLen + 10), (short) (resultLen));
      
   }
   
   public static byte[] xor(byte[] arqc, byte[] responseCode) {

      byte[] c = new byte[arqc.length];
      for (short i = 0; i < arqc.length; i++) {
         c[i] = (byte) (arqc[i] ^ responseCode[i]);
      }

      return c;
   }
   


But it is not generating correct. Can you review it


Sorry for later response.
Let me have a research.
sense and simplicity

deepanshsinghal
Posts: 44
Joined: Thu Apr 06, 2017 8:01 am
Points :460
Contact:

Re: 3DES

Post by deepanshsinghal » Wed Jun 07, 2017 11:19 pm

UNKNwYSHSA wrote:Sorry for later response.
Let me have a research.


No problem....

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: 3DES

Post by UNKNwYSHSA » Wed Jun 07, 2017 11:24 pm

deepanshsinghal wrote:
UNKNwYSHSA wrote:Sorry for later response.
Let me have a research.


No problem....


I already reply in this post: viewtopic.php?f=15&t=1208
sense and simplicity

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 46 guests

JavaCard OS : Disclaimer