-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use JCDK's simulator to run APDU tasks #10
Comments
@sigalor I've never used the cref utility. Note that the sendHello task calls global platform pro with the following parameters (see logs) : gp -d -a 00A404000A01020304050607080901 -a 0040000000 so you can test with global platform pro if you need to tweak parameters Note that I have just updated the lib to work with the most recent version of global platform pro. Use 1.5.6 and add global platform pro dependency in apply plugin: 'javacard'
dependencies {
compile 'com.github.martinpaljak:globalplatformpro:18.09.14'
}
javacard {
....
} |
@bertrandmartel Thanks a lot for your answer! So, I investigated further on this myself and found out the following. There are two methods of simulating a Java Card application. First, the one I thought of initially using the Yet, there is a problem: Maskgen needs a config file. I am really confused by this, as the documentation states that some "mapping to native functions" is supposed to happen. Additionally, I am not able to find the mentioned I think Maskgen is supposed to create a Then, I stumbled over a Q&A with a Java Card engineer from Oracle. She even wrote a book about Java Card. Although, because that article is from 2000, she is taking about JCDK 2.1.1 in it, I could still extract some useful information from it. For this method, you need the Java Card Workstation Development Environment (JCWDE). Apparently, it has been dropped from JCDK 3.x releases, but version 2.2.2 still has it. The following JAR files are needed to execute it (they're all part of the To make invocation easier, I then wrote a small BASH script I put into
Note that in the following, the environment variable Next, as a temporary solution, I created a file called
Next, one needs to run the JCWDE with a command like the following. If it succeeds it outputs
We're almost done. There's just one more file to create: the list of APDU bytes to send. I just called it
Note that the initial So finally, the ApduTool command, which should be rather trivial; it just sends all data from
Coming to an end, I hope you can forgive me for this wall of text. My main motivation of writing this down was that I couldn't find any real condensed information on this, as everyone developing with the JCDK seems to use the Eclipse plugin provided by Oracle. As you can see, this entire process really isn't elegant, especially because of the JAR files needed from an older JCDK release. That's why I'd really appreciate if these instructions would be added to the repository. One could be able to specify whether to use GlobalPlatform or this type of simulator in the Sadly, my knowledge in Gradle development is practically non-existent, so I won't be able to make any meaningful source code contributions to this repository. Thus, I am looking forward to its further development! |
nice digging ! why not using jcardsim like in javacard-tutorial repo. This javacard plugin makes it easy to use it in a test sourceSet like this. My personal advice if you come from Eclipse & are new to gradle :
You can build a new project from one of these module to start. In the test folder keep @RunWith(Suite.class)
@SuiteClasses({PasswordEntryTest.class, PasswordManagerTest.class}) <=== change this
public class TestSuite Then you can start to develop while testing your applet(s) sending your own APDU and checking for the result etc... Other project examples you can check : I developped all projects above without physical card with only the tests using Jcardsim and tested on physical cards afterwards When you have access to physical smartcard, in IntelIJ check the gradle tasks : This plugin includes default tasks like installJavacard, listJavacard which are wrapping global platform pro and you can create yours using the scripts fields (check https://github.com/bertrandmartel/javacard-gradle-plugin#usage) Note that if you use some external Javacard library like org.globalplatform, you would need to mock all those calls for instance here |
Hi everyone!
First, thanks so much for this astonishing and incredibly useful repository! I recently started getting into JavaCard/SIM development, and without open source projects like this, I would definitely be completely lost.
Currently, I am trying out the examples from your
javacard-tutorial
repository. The CAP file generation and everything else before it runs perfectly fine, but, as I don't have a physical smart card and reader yet, I'd like to try it out on a simulator. The JavaCard Development Kit by Oracle comes with thecref
utility; that should be the simulator, right? Sadly, it comes as a Windows EXE file only, so one will need to usewine
to execute it on Mac/Linux (I tried it and it works).Still, it seems like currently, the Gradle plugin cannot use it yet. When I try something like
gradle sendHello
in the other repository, I get an error message like:And, well, the message The Smart card resource manager is not running. is a fairly clear indication of what's going on. So, does anyone know how I can use the simulator here?
Regarding my system setup: I'm using Ubuntu 16.04 with OpenJDK 1.8.0_181. My JavaCard Development Kit version is 3.0.5u3.
The text was updated successfully, but these errors were encountered: