When trying to use the getK()
method on a key pair in JavaCard I get this exception code: CryptoException.UNINITIALIZED_KEY
Here is my code where I generate the key pair:
KeyPair key = new KeyPair(KeyPair.ALG_EC_FP, (short)256);
key.genKeyPair();
later on in the code I am trying to run
ECPublicKey eCPublicKey = (ECPublicKey) key.getPublic();
short hLeng = eCPublicKey.getK();
but this is when I get the exception thrown. Is there something else I need to do to init the key?