crocs-muni / javacard-gradle-template-edu

JavaCard project template for building CAP and running JCardSim with gradle + coverage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incompatibility with JCMathLib 1.0.1

mvondracek opened this issue · comments

Hello, I found a strange bug which makes this template incompatible with JCMathLib.

I tried to use JCMathLib 1.0.1. Method ECPoint#multiplication hangs in jcmathlib.jcmathlib.Bignat.sqrt_FP on line 1709 in while loop. I first thought this is a bug in JCMathLib, but I cannot replicate this issue when using JCMathLib for applet without this template.

So to isolate this issue I used fork of this repository, branched from master, added JCMathLib 1.0.1 in compact single file form, and added tests which demonstrate that ECPoint#multiplication hangs both while running in JUnit and in simulated applet. Here are the changes to demonstrate this issue. master...mvondracek:jcmathlib

Any idea what's wrong? Are there any incompatible changes between official jCardSim and com.klinec:jcardsim:3.0.5.9?

TBH no idea. @petrs any thoughts?

ping @mvondracek, do you have any new info/insights? I am way too busy to debug this on my own atm.

try bumping jcardsim to 3.0.5.11 and set

System.setProperty("com.licel.jcardsim.randomdata.secure", "1");

before loading the applet to the simulator.

hmm, no idea - but there is some new work planned for JCMathLib (adding support for cards with PLAIN_XY KeyAgreemnt which will speedup operations a lot) and we can check this issue while doing it

Also, try:

  • try bumping jcardsim to 3.0.5.11
  • bumping gradle plugin to 1.7.2
  • set:
System.setProperty("com.licel.jcardsim.randomdata.secure", "1");

Hello, thank you for your suggestions! I updated branch with bug example, but it did not solve the problem.

Unfortunately, I do not have time to debug it at the moment, neither. Our team was working on PV204 project while we detected this issue. So as our work on the project is finished, this is more of a bug report than critical problem blocking our team.

So at least this can be a note to future users that JCMathLib does not work with this template for now... Thanks anyway.

Hi, this issue should now be fixed in JCMathLib (OpenCryptoProject/JCMathLib#23) when bIsSimulator flag is set.

More recent versions of jCardSim (including those in this template) have problems with some underlying operations used to implement multiplication and point doubling. When bIsSimulator flag is set, JCMathLib avoids these operations and should work in the simulator as expected.

Closing issue, in case of a regression, reopen pls.
Thanks @dufkan