JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html
https://ftsafe.en.alibaba.com/index.html
Checksum result is different between host and card
Checksum result is different between host and card
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?
Why?
Re: Checksum result is different between host and card
pls make your question more detailed and show your code firstly.
Re: Checksum result is different between host and card
My host code to creates a checksum
Create checksum on card
But the result differs from what the host creates.
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.
Re: Checksum result is different between host and card
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.
The problem was caused by the initial value.
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.
Re: Checksum result is different between host and card
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.
Who is online
Users browsing this forum: No registered users and 49 guests