Skip to Main Content

Java Card

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

CREF KeyAgreement.ALG_EC_SVDP_DH implementation

843851Sep 30 2009 — edited Oct 14 2009
Hi

I'm making tests with JC 2.2.2 and would like to know what is supposed to give back the KeyAgreement ECDH function when it is called. The JC 2.2.2 API guide states that this function follows the notation of IEEE 1363. However, if for example you make tests with public and private keys of the type LENGTH_EC_FP_112 (where any field element is 14 bytes long), after calling the "generateSecret" method you obtain a byte array of 20 bytes. The problem is that the ECDH method is supposed to provide a field element (of 14 bytes), so I don't know what those 20 bytes represent. Does anybody know what this KeyAgreeement implementation is suppossed to produce?

Here's a sample of my code:

try {
keyPair = new KeyPair(KeyPair.ALG_EC_FP, KeyBuilder.LENGTH_EC_FP_112);
keyPair.genKeyPair();

ecPublic = (ECPublicKey)keyPair.getPublic();
ecPrivate = (ECPrivateKey)keyPair.getPrivate();

baECPublic = new byte[100];
baOut = new byte[100];

keyAgreement = KeyAgreement.getInstance(KeyAgreement.ALG_EC_SVDP_DH, false);
keyAgreement.init(ecPrivate);
short lenW = ecPublic.getW(baECPublic, (short) 0);
short lenOut = keyAgreement.generateSecret(baECPublic, (short) 0, (short) lenW, baOut, (short)0);

apdu.setOutgoing();
apdu.setOutgoingLength((short) lenOut);
apdu.sendBytesLong(baOut, (short) 0, lenOut);
}
catch(Exception e)
{
ISOException.throwIt((short) 0x4401 );
}

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 11 2009
Added on Sep 30 2009
5 comments
2,068 views