Code: Select all
ECPublicKey pubKey = (ECPublicKey) KeyBuilder.buildKey(
KeyBuilder.TYPE_EC_FP_PUBLIC, (short) 0x0100, false);
pubKey.setFieldFP(p, (short) 0x0001, (short) 0x0020);
pubKey.setA(a, (short) 0x0001, (short) 0x0020);
pubKey.setB(b, (short) 0x0000, (short) 0x0020);
pubKey.setR(r, (short) 0x0001, (short) 0x0020);
pubKey.setG(g, (short) 0x0000, (short) g.length);
ECPrivateKey privKey = (ECPrivateKey) KeyBuilder.buildKey(
KeyBuilder.TYPE_EC_FP_PRIVATE, (short) 0x0100, false);
KeyPair keypair = new KeyPair(pubKey, privKey);
keypair.genKeyPair();
pubKey.getW(apduBuffer, (short) 0x0000);
setOutgoingAndSend((short) 0x0000, (short) 0x0041);
On the card side, the code above is performed .
I generate a KeyPair for ECDH,and send the the public one to the terminal side.
But i can't use java to reconstruct an ECPublicKey provided the response APDU I get.
What can i do? Could anyone give me any clues?Thanks a lot.