cryptography - How to perform ECKA and have an ECPoint returned? -
i'm using bouncy castle perform elliptic curve key aggreement using ecdh protocol in smart card related software, defined in bsi-tr-03111 specs, §3.4
the purpose perform generic mapping of nonce in pace protocol, defined in icao sac technical report, §3.4.2.1.1
(i'm using java language not essential matter guess)
the keyagreement
class makes simple (as exemplified here) allows output x coordinate of generated ecpoint
, zab (which often, not required.)
is there way have actual ecpoint
(that sab) returned without having reimplement algorithm? tho' formula in simple, 1 must check errors , anomalies , account variations (e.g. cofactor multiplication)
i forgot question. solution implemented:
package com.arjowiggins.arjonaut.crypto.ec; import org.bouncycastle.crypto.basicagreement; import org.bouncycastle.crypto.cipherparameters; import org.bouncycastle.crypto.params.ecprivatekeyparameters; import org.bouncycastle.crypto.params.ecpublickeyparameters; import org.bouncycastle.math.ec.ecpoint; import java.math.biginteger; /** * created salvatore on 22/04/2015. */ public class ecdhpointagreement implements basicagreement { private ecprivatekeyparameters key; public void init(cipherparameters key) { this.key = (ecprivatekeyparameters) key; } public int getfieldsize() { return (key.getparameters().getcurve().getfieldsize() + 7) / 8; } public biginteger calculateagreement(cipherparameters pubkey) { ecpoint p = calculatepoint(pubkey); return p.getaffinexcoord().tobiginteger(); } public ecpoint calculatepoint(cipherparameters pubkey) { ecpublickeyparameters pub = (ecpublickeyparameters) pubkey; ecpoint p = pub.getq().multiply(key.getd()).normalize(); if (p.isinfinity()) { throw new illegalstateexception("infinity not valid agreement value ecdh"); } return p; } }
most of code comes bouncycastle's keyagreement
class.
Comments
Post a Comment