licel / jcardsim

https://jcardsim.org
223 stars 123 forks source link

javacard.framework.Util.arrayCompare() compares unsigned byte values #124

Open biafra23 opened 6 years ago

biafra23 commented 6 years ago

Util.arrayCompare() (in Jcardsim) compares unsigned byte values which is nice but incompatible with real cards by NXP and Infineon which compare signed byte values. The Javadoc does not mention explicitly whether signed or unsigned values will be used for comparision, which makes it unlikely that any implementation on cards would use unsigned values. Unfortunately bytes are signed in Java.

As a fix you can probably just remove the conversion to a unsigned short value in https://github.com/licel/jcardsim/blob/master/src/main/java/com/licel/jcardsim/framework/UtilProxy.java#L196 and https://github.com/licel/jcardsim/blob/master/src/main/java/com/licel/jcardsim/framework/UtilProxy.java#L197