I am trying to implement ECDSA on JavaCard. So far I have this code:
Signature sig = Signature.getInstance(Signature.ALG_ECDSA_SHA_256, false);
KeyPair key = new KeyPair(KeyPair.ALG_EC_FP, (short)256);
key.genKeyPair();
sig.init(key.Private(), Signature.MODE_SIGN);
sig.sign(data, (short)0, dataLen, outputBuf, (short)0);
When I try to retire K using the getK() method so that I can send the public key in an APDU I get the error code 6F 00.
According to the documentation getK() can throw CryptoException.UNINITIALIZED_KEY if the 'cofactor of the order of the fixed point G of the curve of the key has not been successfully initialized'
Is there something else I need to initialise when setting up the keys/signature?