Skip to content

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

@dempa

Description

@dempa

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions