Page 1 of 1

Convert Object to byte[] in Java Card

Posted: Wed Oct 07, 2015 11:32 am
by aahmadzadeh
I am using Java Card 2.1.1 and JCDK 2.1.2

How can i convert an Object (an instance of PublicKey) to byte[] and vise versa in Java Card applets?

Re: Convert Object to byte[] in Java Card

Posted: Mon Oct 12, 2015 2:19 am
by UNKNwYSHSA
aahmadzadeh wrote:I am using Java Card 2.1.1 and JCDK 2.1.2

How can i convert an Object (an instance of PublicKey) to byte[] and vise versa in Java Card applets?


Do you need the function like Serializable interface?

You can use the getXXX() method to convert PublicKey to byte[];
And use the setXXX() method to convert byte[] to PublicKey;
Here's the getXXX/setXXX method PublicKey support:
1 DSAPublicKey: getY/setY;
2 ECPublicKey: getW/setW;
3 RSAPublicKey: getExponent/setExponent and getModulus/setModulus;