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.

Checksum result is different between host and card

JavaCard Applet Development Related Questions and Answers.
afrascoi
Posts: 18
Joined: Mon Jan 25, 2016 1:20 am
Points :265
Contact:

Checksum result is different between host and card

Post by afrascoi » Mon Dec 26, 2016 11:42 pm

I tried 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 and I also created a checksum on the card side. But I got the different results from two sides.
Why?

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: Checksum result is different between host and card

Post by mabel » Tue Dec 27, 2016 3:03 am

pls make your question more detailed and show your code firstly.

afrascoi
Posts: 18
Joined: Mon Jan 25, 2016 1:20 am
Points :265
Contact:

Re: Checksum result is different between host and card

Post by afrascoi » Tue Dec 27, 2016 4:42 am

My host code to creates a checksum

Code: Select all

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


Create checksum on card

Code: Select all

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


But the result differs from what the host creates.

afrascoi
Posts: 18
Joined: Mon Jan 25, 2016 1:20 am
Points :265
Contact:

Re: Checksum result is different between host and card

Post by afrascoi » Tue Dec 27, 2016 5:27 am

I just found that Java CRC32 starts with an initial value 0xFFFFFFFF.
So I set the card to 0xFFFFFFFF, it works. Now both the card and host checksum result is same.

Code: Select all

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


The problem was caused by the initial value.

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: Checksum result is different between host and card

Post by mabel » Tue Dec 27, 2016 6:07 am

The below is the introduction about Checksum.ALG_ISO3309_CRC32 from javacard API document.
To obtain the PKZIP (also JDKTM java.util.zip.CRC32 class) behavior:
- Initialize with 0xFFFFFFFF via the init() method


You do not have the required permissions to view the files attached to this post. Please login first.

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 56 guests

JavaCard OS : Disclaimer