diff options
Diffstat (limited to 'id.server')
-rw-r--r-- | id.server/src/at/gv/egovernment/moa/id/util/ECDSAKeyValueConverter.java | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/id.server/src/at/gv/egovernment/moa/id/util/ECDSAKeyValueConverter.java b/id.server/src/at/gv/egovernment/moa/id/util/ECDSAKeyValueConverter.java index adb28d4ed..2567cd739 100644 --- a/id.server/src/at/gv/egovernment/moa/id/util/ECDSAKeyValueConverter.java +++ b/id.server/src/at/gv/egovernment/moa/id/util/ECDSAKeyValueConverter.java @@ -1,20 +1,16 @@ package at.gv.egovernment.moa.id.util; -import iaik.ixsil.util.URI; - import iaik.security.ecc.ecdsa.ECDSAParameter; import iaik.security.ecc.ecdsa.ECPublicKey; -//import iaik.security.ecc.interfaces.ECDSAPublicKey; +import iaik.security.ecc.math.ecgroup.AffineCoordinate; +import iaik.security.ecc.math.ecgroup.Coordinate; +import iaik.security.ecc.math.ecgroup.CoordinateTypes; import iaik.security.ecc.math.ecgroup.ECGroupFactory; import iaik.security.ecc.math.ecgroup.ECPoint; import iaik.security.ecc.math.ecgroup.EllipticCurve; -import iaik.security.ecc.math.ecgroup.ProjectiveCoordinate; -//import iaik.security.ecc.math.field.BinaryField; -//import iaik.security.ecc.math.field.BinaryFieldValue; import iaik.security.ecc.math.field.Field; import iaik.security.ecc.math.field.FieldElement; -import iaik.security.ecc.math.field.FieldFactory; -import iaik.security.ecc.math.field.Value; +import iaik.security.ecc.math.field.PrimeField; import iaik.security.ecc.parameter.ECCParameterFactory; import iaik.security.ecc.spec.ECCParameterSpec; @@ -25,15 +21,11 @@ import java.util.Iterator; import java.util.Vector; import org.w3c.dom.Attr; -import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -//import at.gv.cio.identitylink.init.Constants; -import at.gv.egovernment.moa.id.util.ECDSAConstants; - public class ECDSAKeyValueConverter { @@ -49,7 +41,7 @@ public class ECDSAKeyValueConverter * * @author gregor karlinger */ -public static PublicKey element2ECDSAPublicKey(Element keyValueElem) throws Exception + public static PublicKey element2ECDSAPublicKey(Element keyValueElem) throws Exception { String ecdsaNS = ECDSAConstants.NAMESPACE_ECDSAKEYVALUE_; @@ -170,10 +162,10 @@ public static PublicKey element2ECDSAPublicKey(Element keyValueElem) throws Exce Element publicKeyYElem = getChildElement(publicKeyElem, ecdsaNS, "Y", 1); String publicKeyYStr = publicKeyYElem.getAttributeNS(null, "Value"); - ECDSAParameter ecdsaParams = new ECDSAParameter(eccParameterSpec, false); + ECDSAParameter ecdsaParams = new ECDSAParameter(eccParameterSpec, CoordinateTypes.PROJECTIVE_COORDINATES); ECGroupFactory ecGroupFactory = ECGroupFactory.getInstance(); - EllipticCurve eCurve = ecGroupFactory.getCurveWithProjective(eccParameterSpec.getA(), - eccParameterSpec.getB(), eccParameterSpec.getR()); + EllipticCurve eCurve = ecGroupFactory.getCurve(eccParameterSpec.getA(), + eccParameterSpec.getB(), eccParameterSpec.getR(), CoordinateTypes.PROJECTIVE_COORDINATES); Field field = eCurve.getField(); // Detect type of public key field elements @@ -187,18 +179,24 @@ public static PublicKey element2ECDSAPublicKey(Element keyValueElem) throws Exce FieldElement publicKeyPointX, publicKeyPointY; if (fieldElemType == FIELD_TYPE_PRIME) { - Value xValue = FieldFactory.getInstance().getPrimeFieldValue(new BigInteger(publicKeyXStr, 10)); - publicKeyPointX = field.newElement(xValue); - Value yValue = FieldFactory.getInstance().getPrimeFieldValue(new BigInteger(publicKeyYStr, 10)); - publicKeyPointY = field.newElement(yValue); + +// Value xValue = FieldFactory.getInstance().getPrimeFieldValue(new BigInteger(publicKeyXStr, 10)); +// publicKeyPointX = field.newElement(xValue); + PrimeField pf = (PrimeField) field; + publicKeyPointX = pf.newElement(new BigInteger(publicKeyXStr, 10)); +// Value yValue = FieldFactory.getInstance().getPrimeFieldValue(new BigInteger(publicKeyYStr, 10)); +// publicKeyPointY = field.newElement(yValue); + publicKeyPointY = pf.newElement(new BigInteger(publicKeyYStr, 10)); } else { publicKeyPointX = field.newElement(octetString2ByteArray(publicKeyXStr)); publicKeyPointY = field.newElement(octetString2ByteArray(publicKeyYStr)); } - ProjectiveCoordinate publicKeyPointCoordinate = new ProjectiveCoordinate(publicKeyPointX, - publicKeyPointY, field.getONEelement()); +// ProjectiveCoordinate publicKeyPointCoordinate = new ProjectiveCoordinate(publicKeyPointX, +// publicKeyPointY, field.getONEelement()); + Coordinate publicKeyPointCoordinate = new AffineCoordinate(publicKeyPointX, + publicKeyPointY).toProjective(); ECPoint publicKeyPoint = eCurve.newPoint(publicKeyPointCoordinate); ECPublicKey publicKey = new ECPublicKey(ecdsaParams, publicKeyPoint); |