Page 1 of 1

getS(byte[] buffer, short offset)

Posted: Tue Jul 05, 2016 5:00 am
by Girr16
I am studying ECC on javacard. I cannot understand the related API method:



- getS(byte[] buffer, short offset) : this method returns the value of the secret key in plaintext form.
IMO, the private key is supposed to be secret, and no one can get it. Why does this return the key?

Re: getS(byte[] buffer, short offset)

Posted: Tue Jul 05, 2016 8:39 am
by mabel
Girr16 wrote:- getS(byte[] buffer, short offset) : this method returns the value of the secret key in plaintext form.
IMO, the private key is supposed to be secret, and no one can get it. Why does this return the key?


The S parameter is indeed the private key of the ECC. The function ECPrivateKey.getS(...) is almost never used since objects KeyAgreement and Signature have a Private key parameter. You might sometimes use the getS function to verify the value of your private key in debug mode.

Re: getS(byte[] buffer, short offset)

Posted: Tue Jul 05, 2016 11:32 pm
by Girr16
Thank you for your answer.

But what makes me s little surprised is that we can indeed get the private key via this method.

Re: getS(byte[] buffer, short offset)

Posted: Wed Jul 06, 2016 11:26 pm
by lostsiwonlw
Girr16 wrote:But what makes me s little surprised is that we can indeed get the private key via this method.


The card won't stop you from getting the private key in any way. It provides you more flexibility but you also have more responsibility.