Page 1 of 1

I have a question about generateSecret

Posted: Wed Sep 12, 2018 6:29 am
by BirdKing
Hello,
I have a question about KeyAgreement.generateSecret.

In API specification, It descript the Throws of KeyAgreement.generateSecret as:

• CryptoException.ILLEGAL_VALUE if the publicData data format is incorrect, or if the
publicData data is inconsistent with the PrivateKey specified during initialization.
• CryptoException.INVALID_INIT if this KeyAgreement object is not initialized.

The result of generateSecret is a point. And the point maybe point-at-infinity. Or the algorithm ends in projective zero point during this operation.

My question is: Whether I should check the result point is on the curve when the API implemented?

Re: I have a question about generateSecret

Posted: Thu Sep 13, 2018 10:13 pm
by happy123654
I think you should check it.

Re: I have a question about generateSecret

Posted: Fri Sep 14, 2018 6:15 am
by BirdKing
Thanks for your answer. I think you are right. Ther error result may belong "the publicData data is inconsistent with the PrivateKey specified during initialization" .

Re: I have a question about generateSecret

Posted: Sat Sep 15, 2018 10:58 pm
by DaHuFa
I don't think so.
The "inconsistent" may mean "the public point " not on the curve of the private key. If the result is point-at-infinity, the return value may be 0. After all, the return is "byte length of secret".
All these are my conjectures. I hope it will help you.