Page 1 of 1

Why the byte length of KeyAgreement.generateSecret() is 20

Posted: Fri Jul 13, 2018 5:10 am
by DaHuFa
Hello,
I write a applet to implement KeyAgreement recently. I create a 256 bits EC key, then call KeyAgreement.generateSecret(). In the end, the length of result is 20 bytes. Why? My EC key length is 256 bits, 32 bytes. Why my result length is 20 bytes?

Re: Why the byte length of KeyAgreement.generateSecret() is 20

Posted: Fri Jul 13, 2018 5:12 am
by happy123654
Because the function implements SHA_1 calculation in the last step.

Re: Why the byte length of KeyAgreement.generateSecret() is 20

Posted: Fri Jul 13, 2018 5:29 am
by DaHuFa
But my sample card which installed other's applet return 32 bytes. I think there maybe something I don't know....

Re: Why the byte length of KeyAgreement.generateSecret() is 20

Posted: Fri Jul 13, 2018 5:42 am
by BirdKing
The sample applet maybe use ALG_EC_SVDP_DH_PLAIN.