1 Reply Latest reply on Nov 13, 2012 12:18 AM by safarmer

    CRC32 Checksum between Java and JavaCard

      Hi there,

      iam trying to send a message with a CRC32 code from the java host to the java card.

      The host creates a checksum and send it with the message to the card:
      Checksum checksum = new CRC32();
      checksum.update(rawData, 0, rawData.length); //rawData is the message
      long checksum_value = checksum.getValue();
      On the card i create also a checksum:
      Checksum checksum = Checksum.getInstance(Checksum.ALG_ISO3309_CRC32, false);
      checksum.doFinal(data, (short)0, (short)data.length, checksum_value, (short)0); //data is the message read from the buffer
      But the result differs from what the host creates.
      After a while i found out that the Java CRC32 starts with an initial value from 0xffffffff.
      Setting the card to this initial value helps:
      byte[] ini = new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};
      checksum.init(ini, (short)0, (short)ini.length);
      Now both checksums, host and card, are the same.
      My question now is, whats the initial value of CRC32 on a JavaCard ? it is not zero, because setting the inital value of the host to zero does not result in the same checksums. So the initial value of the card must be other then 0x00000000 and 0xffffffff. for me that looks really stupid. someone knows the standard initial value from javacard ?

      best regards