From d3f610d5f4b4c43fed8ebfc0e178d4cfa65bb631 Mon Sep 17 00:00:00 2001 From: rudolf Date: Fri, 21 Jan 2005 18:13:38 +0000 Subject: added ECDSA Key comparison git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@236 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../VerifyXMLSignatureResponseValidator.java | 38 ++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/id.server/src/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java b/id.server/src/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java index c4c22fd02..5adbc5b3d 100644 --- a/id.server/src/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java +++ b/id.server/src/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java @@ -2,6 +2,7 @@ package at.gv.egovernment.moa.id.auth.validator; import java.security.PublicKey; import java.security.interfaces.RSAPublicKey; +import iaik.security.ecc.ecdsa.ECPublicKey; import iaik.asn1.structures.Name; import iaik.utils.RFC2253NameParserException; @@ -112,24 +113,35 @@ public class VerifyXMLSignatureResponseValidator { X509Certificate x509Response = verifyXMLSignatureResponse.getX509certificate(); PublicKey[] pubKeysIdentityLink = (PublicKey[]) idl.getPublicKey(); - RSAPublicKey pubKeyResponse = (RSAPublicKey) x509Response.getPublicKey(); + PublicKey pubKeySignature = x509Response.getPublicKey(); boolean found = false; for (int i = 0; i < pubKeysIdentityLink.length; i++) { - if (idl.getPublicKey()[i] - instanceof java.security.interfaces.RSAPublicKey) { - /* for (int j = 0; - j < idl.getPublicKey()[i].getClass().getInterfaces().length; - j++) { - if (idl.getPublicKey()[i].getClass().getInterfaces()[j].getName() - .equals("java.security.interfaces.RSAPublicKey")) {*/ - RSAPublicKey rsakey = (RSAPublicKey) pubKeysIdentityLink[i]; - if (rsakey.getModulus().equals(pubKeyResponse.getModulus()) - && rsakey.getPublicExponent().equals( - pubKeyResponse.getPublicExponent())) - found = true; + + //compare RSAPublicKeys + if ((idl.getPublicKey()[i] instanceof java.security.interfaces.RSAPublicKey) && + (pubKeySignature instanceof java.security.interfaces.RSAPublicKey)) { + + RSAPublicKey rsaPubKeySignature = (RSAPublicKey) pubKeySignature; + RSAPublicKey rsakey = (RSAPublicKey) pubKeysIdentityLink[i]; + + //TODO check the usage of equals method + if (rsakey.getModulus().equals(rsaPubKeySignature.getModulus()) + && rsakey.getPublicExponent().equals(rsaPubKeySignature.getPublicExponent())) + found = true; } + + //compare ECDSAPublicKeys + //TODO check implementation + if((idl.getPublicKey()[i] instanceof iaik.security.ecc.ecdsa.ECPublicKey) && + (pubKeySignature instanceof iaik.security.ecc.ecdsa.ECPublicKey)) { + ECPublicKey ecdsaPubKeySignature = (ECPublicKey) pubKeySignature; + ECPublicKey ecdsakey = (ECPublicKey) pubKeysIdentityLink[i]; + + if(ecdsakey.equals(ecdsaPubKeySignature)) + found = true; + } } if (!found) -- cgit v1.2.3