Page 1 of 1

CRC32 Checksum between Java and JavaCard

Posted: Tue Jan 12, 2016 3:27 am
by Riddle
I am working on sending a message with a CRC32 code from the java host to the java card.

Host:
I create a checksum and send it with the message to the card:

Code: Select all

Checksum checksum = new CRC32();
checksum.update(rawData, 0, rawData.length);
long checksum_value = checksum.getValue();


Card:
I also create a checksum.

Code: Select all

Checksum checksum = Checksum.getInstance(Checksum.ALG_ISO3309_CRC32, false);
checksum.doFinal(data, (short)0, (short)data.length, checksum_value, (short)0);


The result is different from what the host creates.

Does anyone know how to fix this problem?

Re: CRC32 Checksum between Java and JavaCard

Posted: Thu Jan 14, 2016 10:50 pm
by Tarantino
What is the initial value that your Java CRC32 starts with?

Suppose that Java CRC32 starts with an initial value from 0xFFFFFFFF.
You should set the card to this initial value.

Code: Select all

byte[] ini = new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};
checksum.init(ini, (short)0, (short)ini.length);

Re: CRC32 Checksum between Java and JavaCard

Posted: Wed Jan 20, 2016 6:04 am
by UNKNwYSHSA
Yes, for algorithm ALG_ISO3309_CRCXX, the initialize value is 0xFFFF(16 bits)/0xFFFFFFFF(32 bits).
For more details, see JC api for javacard.security.Checksum.