Page 1 of 1

Come across error when calculating the Cryptogram

Posted: Wed Mar 02, 2016 8:39 am
by tomc2016
Does anyone know how I can confirm the static key in the SSD ? When I try to execute INITIAZE UPDATE COMMAND, the card Cryptogram can not verified correctly. Anybody tell me where is wrong in my code? Or how can I confirm the static key in the SSD ?

Here is my code to calculate Cryptogram.

Code: Select all

IvParameterSpec params =
new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0});

if (sessionSENC.length == 16) {
byte[] temp = (byte[]) sessionSENC.clone();
sessionSENC = new byte[24];
System.arraycopy(temp, 0, sessionSENC, 0, temp.length);
System.arraycopy(temp, 0, sessionSENC, 16, 8);
}


byte[] temp = null;
SecretKey secretKey = new SecretKeySpec(sessionSENC, "DESede");

          Cipher cbcDES = Cipher.getInstance("DESede/CBC/NoPadding");
          cbcDES.init(Cipher.ENCRYPT_MODE, secretKey, params);
         
          temp = cbcDES.doFinal(data);

byte[] signature = new byte[8];
System.arraycopy(temp, temp.length - 8, signature, 0, signature.length);
return signature;

Re: Come across error when calculating the Cryptogram

Posted: Mon Mar 14, 2016 3:11 am
by mabel
Can you post a complete code of your applet if convenient?