Reputation: 8193
I'm trying to implement two way authentication flow for java card applet. Following is my approach.
I'm struggling at step two. All others seems trivial. I need to find a way to encode the public key created outside to card into byte array and then transfer that byte array to java card applet and reconstruct the public key and store it in the persistent memory.
Any hint on this.
Upvotes: 3
Views: 792
Reputation: 94038
Create an APDU with the following command data:
00
if present04
04
indicator01
anyways)set...
methods to set the keyAnd presto, one EC key for you.
You can of course also parse a PKCS#8 EC key or use length indicators for each and every field, but this method is probably the most compact one.
Upvotes: 2
Reputation: 502
To Achieve this you have to create a Javacard applet which....something like below
class MyApplet extends javacard.framework.Applet
{
// ...
public void process(APDU apdu)
{
// ...
byte[] buffer = apdu.getBuffer();
//Other stuff
}
}
To reach in public void process(APDU apdu)
method you should select your applet with its AID after that every command will start reaching to this method.
You can create your own proprietary APDU to send "offcard application private key" and can get that here
byte[] buffer = apdu.getBuffer();
and then you can store it in a persistent array of your applet.
Upvotes: -4