Skip to content
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

Kryo NullPointerException when loading class KeyPair variable with ALG_EC_FP keys #213

Open
dempa opened this issue Dec 13, 2024 · 0 comments

Comments

@dempa
Copy link

dempa commented Dec 13, 2024

It looks like there is an issue when loading (deserializing) an installed applet with a KeyPair class variable that is initialized with ALG_EC_FP and has generated keys.

Using algorithm ALG_RSA does not trigger the crash.

public class OTPApplet extends Applet {
    private final KeyPair keyPair;
    OTPApplet(byte[] bArray, short bOffset, byte bLength) {
        //keyPair = new KeyPair(ALG_RSA, (short) 1024);  // works on both installation and on load
        keyPair = new KeyPair(ALG_EC_FP, (short) 256); // works on installation but crashes on load

        keyPair.genKeyPair(); // note: for the crash to occur the keys must be generated

The installation / instantiation of the applet works fine.
When the app is restarted it throws an exception in SimulatorRuntime::loadApplet()

Trying to load an instance of com.licel.globalplatform.GpSimulatorRuntime
Failed to load the instance! Will use the default SimulatorRuntime
com.licel.jcardsim.esotericsoftware.kryo.KryoException: java.lang.NullPointerException: Attempt to get length of null array
Serialization trace:
preCompTable (com.licel.jcardsim.bouncycastle.math.ec.ECPoint$Fp)
G (com.licel.jcardsim.bouncycastle.crypto.params.ECDomainParameters)
params (com.licel.jcardsim.bouncycastle.crypto.generators.ECKeyPairGenerator)
engine (com.licel.jcardsim.crypto.KeyPairImpl)
impl (javacard.security.KeyPair)
keyPair (com.licel.samples.applet.OTPApplet)

The issue was found when trying out the app https://github.com/licel/hotp-authenticator which is using jcardsim-3.0.5.jar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant