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.

Error when generating CMAC

Algorithm School

Moderator: UNKNwYSHSA

Tinatco
Posts: 12
Joined: Wed Feb 24, 2016 3:04 am
Points :128
Contact:

Error when generating CMAC

Post by Tinatco » Mon Mar 13, 2017 1:48 am

I have to generate CMAC in my applet.But I encountered some problems when doing this and I can't find where I made mistake. Here is my code:

Code: Select all

 ...
 
 Zeros = { 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00}           
 SecretKeySpec desSK = new SecretKeySpec(KeySession,0, 8,"DES");
 Cipher DesCipher = Cipher.getInstance("DES/CBC/NoPadding", "SunJCE");
           
 Spec = new IvParameterSpec(Zeros);
 DesCipher.init(Cipher.ENCRYPT_MODE, desSK,Spec);
           
 byte ForLastBlock[] = DesCipher.doFinal(data, 0, 8);
 cipher = Cipher.getInstance("DESede/CBC/NoPadding", "SunJCE");
 Spec = new IvParameterSpec(ForLastBlock);
 cipher.init(Cipher.ENCRYPT_MODE, getKeySpec(KeySession), Spec);
  byte cMac[] = cipher.doFinal(data, 8, 8);   
  ...
   


Hope someone help me out.

JCaberham
Posts: 26
Joined: Mon Nov 30, 2015 3:02 am
Points :208
Contact:

Re: Error when generating CMAC

Post by JCaberham » Mon Mar 13, 2017 4:21 am

Your computation method has something wrong. You should notice that: the last block is DES3 encrypted, ICV is last calculated C_MAC

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 22 guests

JavaCard OS : Disclaimer