You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by mu...@apache.org on 2010/07/20 21:00:56 UTC

svn commit: r965957 [4/4] - in /xml/security/branches/java_xmldsig11_ecdsa: ./ data/org/w3c/www/interop/xmldsig11/ data/org/w3c/www/interop/xmldsig11/microsoft/ data/org/w3c/www/interop/xmldsig11/oracle/ data/org/w3c/www/interop/xmldsig11/sun/ src/org/...

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java Tue Jul 20 19:00:52 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2010 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -27,14 +27,19 @@ import javax.xml.crypto.dom.DOMCryptoCon
 import javax.xml.crypto.dsig.*;
 import javax.xml.crypto.dsig.keyinfo.KeyValue;
 
+import java.io.IOException;
 import java.security.KeyException;
 import java.security.KeyFactory;
 import java.security.NoSuchAlgorithmException;
 import java.security.PublicKey;
 import java.security.interfaces.DSAParams;
 import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.ECPublicKey;
 import java.security.interfaces.RSAPublicKey;
 import java.security.spec.DSAPublicKeySpec;
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECPoint;
+import java.security.spec.ECPublicKeySpec;
 import java.security.spec.InvalidKeySpecException;
 import java.security.spec.KeySpec;
 import java.security.spec.RSAPublicKeySpec;
@@ -42,59 +47,46 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
+import org.apache.xml.security.exceptions.Base64DecodingException;
+import org.apache.xml.security.utils.Base64;
+
 /**
  * DOM-based implementation of KeyValue.
  *
  * @author Sean Mullan
  */
-public final class DOMKeyValue extends DOMStructure implements KeyValue {
-
-    private KeyFactory rsakf, dsakf;
-    private PublicKey publicKey;
-    private javax.xml.crypto.dom.DOMStructure externalPublicKey;
-
-    // DSAKeyValue CryptoBinaries
-    private DOMCryptoBinary p, q, g, y, j, seed, pgen;
+public abstract class DOMKeyValue extends DOMStructure implements KeyValue {
 
-    // RSAKeyValue CryptoBinaries
-    private DOMCryptoBinary modulus, exponent;
+    private static final String XMLDSIG_11_XMLNS 
+        = "http://www.w3.org/2009/xmldsig11#";
+    private final PublicKey publicKey;
 
-    public DOMKeyValue(PublicKey key)  throws KeyException {
+    public DOMKeyValue(PublicKey key) throws KeyException {
 	if (key == null) {
 	    throw new NullPointerException("key cannot be null");
 	}
 	this.publicKey = key;
-	if (key instanceof DSAPublicKey) {
-	    DSAPublicKey dkey = (DSAPublicKey) key;
-	    DSAParams params = dkey.getParams();
-	    p = new DOMCryptoBinary(params.getP());
-	    q = new DOMCryptoBinary(params.getQ());
-	    g = new DOMCryptoBinary(params.getG());
-	    y = new DOMCryptoBinary(dkey.getY());
-	} else if (key instanceof RSAPublicKey) {
-	    RSAPublicKey rkey = (RSAPublicKey) key;
-	    exponent = new DOMCryptoBinary(rkey.getPublicExponent());
-	    modulus = new DOMCryptoBinary(rkey.getModulus());
-	} else {
-	    throw new KeyException("unsupported key algorithm: " +
-		key.getAlgorithm());
-	}
     }
 
     /**
      * Creates a <code>DOMKeyValue</code> from an element.
      *
-     * @param kvElem a KeyValue element
+     * @param kvtElem a KeyValue child element
      */
-    public DOMKeyValue(Element kvElem) throws MarshalException {
+    public DOMKeyValue(Element kvtElem) throws MarshalException {
+        this.publicKey = unmarshalKeyValue(kvtElem);
+    }
+
+    static KeyValue unmarshal(Element kvElem) throws MarshalException {
 	Element kvtElem = DOMUtils.getFirstChildElement(kvElem);
         if (kvtElem.getLocalName().equals("DSAKeyValue")) {
-            publicKey = unmarshalDSAKeyValue(kvtElem);
+            return new DSA(kvtElem);
         } else if (kvtElem.getLocalName().equals("RSAKeyValue")) {
-            publicKey = unmarshalRSAKeyValue(kvtElem);
+            return new RSA(kvtElem);
+        } else if (kvtElem.getLocalName().equals("ECKeyValue")) {
+            return new EC(kvtElem);
         } else {
-	    publicKey = null;
-	    externalPublicKey = new javax.xml.crypto.dom.DOMStructure(kvtElem);
+            return new Unknown(kvtElem);
 	}
     }
 
@@ -118,122 +110,13 @@ public final class DOMKeyValue extends D
         parent.appendChild(kvElem);
     }
 
-    private void marshalPublicKey(Node parent, Document doc, String dsPrefix,
-	DOMCryptoContext context) throws MarshalException {
-        if (publicKey != null) {
-            if (publicKey instanceof DSAPublicKey) {
-                // create and append DSAKeyValue element
-                marshalDSAPublicKey(parent, doc, dsPrefix, context);
-            } else if (publicKey instanceof RSAPublicKey) {
-                // create and append RSAKeyValue element
-                marshalRSAPublicKey(parent, doc, dsPrefix, context);
-            } else {
-                throw new MarshalException(publicKey.getAlgorithm() +
-                    " public key algorithm not supported");
-            }
-        } else {
-	    parent.appendChild(externalPublicKey.getNode());
-        }
-    }
+    abstract void marshalPublicKey(Node parent, Document doc, String dsPrefix, 
+        DOMCryptoContext context) throws MarshalException;
 
-    private void marshalDSAPublicKey(Node parent, Document doc, 
-	String dsPrefix, DOMCryptoContext context) throws MarshalException {
-        Element dsaElem = DOMUtils.createElement
-	    (doc, "DSAKeyValue", XMLSignature.XMLNS, dsPrefix);
-        // parameters J, Seed & PgenCounter are not included
-        Element pElem = DOMUtils.createElement
-	    (doc, "P", XMLSignature.XMLNS, dsPrefix);
-        Element qElem = DOMUtils.createElement
-	    (doc, "Q", XMLSignature.XMLNS, dsPrefix);
-        Element gElem = DOMUtils.createElement
-	    (doc, "G", XMLSignature.XMLNS, dsPrefix);
-        Element yElem = DOMUtils.createElement
-	    (doc, "Y", XMLSignature.XMLNS, dsPrefix);
-        p.marshal(pElem, dsPrefix, context);
-        q.marshal(qElem, dsPrefix, context);
-        g.marshal(gElem, dsPrefix, context);
-        y.marshal(yElem, dsPrefix, context);
-        dsaElem.appendChild(pElem);
-        dsaElem.appendChild(qElem);
-        dsaElem.appendChild(gElem);
-        dsaElem.appendChild(yElem);
-        parent.appendChild(dsaElem);
-    }
-
-    private void marshalRSAPublicKey(Node parent, Document doc, 
-	String dsPrefix, DOMCryptoContext context) throws MarshalException {
-        Element rsaElem = DOMUtils.createElement
-	    (doc, "RSAKeyValue", XMLSignature.XMLNS, dsPrefix);
-        Element modulusElem = DOMUtils.createElement
-	    (doc, "Modulus", XMLSignature.XMLNS, dsPrefix);
-        Element exponentElem = DOMUtils.createElement
-	    (doc, "Exponent", XMLSignature.XMLNS, dsPrefix);
-	modulus.marshal(modulusElem, dsPrefix, context);
-	exponent.marshal(exponentElem, dsPrefix, context);
-        rsaElem.appendChild(modulusElem);
-        rsaElem.appendChild(exponentElem);
-        parent.appendChild(rsaElem);
-    }
+    abstract PublicKey unmarshalKeyValue(Element kvtElem) 
+	throws MarshalException;
 
-    private DSAPublicKey unmarshalDSAKeyValue(Element kvtElem) 
-	throws MarshalException {
-	if (dsakf == null) {
-	    try {
-	        dsakf = KeyFactory.getInstance("DSA");
-	    } catch (NoSuchAlgorithmException e) {
-	        throw new RuntimeException("unable to create DSA KeyFactory: " +
-		    e.getMessage());
-	    }
-	}
-	Element curElem = DOMUtils.getFirstChildElement(kvtElem);
-	// check for P and Q
-	if (curElem.getLocalName().equals("P")) {
-	    p = new DOMCryptoBinary(curElem.getFirstChild());
-	    curElem = DOMUtils.getNextSiblingElement(curElem);
-	    q = new DOMCryptoBinary(curElem.getFirstChild());
-	    curElem = DOMUtils.getNextSiblingElement(curElem);
-	} 
-        if (curElem.getLocalName().equals("G")) {
-            g = new DOMCryptoBinary(curElem.getFirstChild());
-	    curElem = DOMUtils.getNextSiblingElement(curElem);
-	}
-        y = new DOMCryptoBinary(curElem.getFirstChild());
-        curElem = DOMUtils.getNextSiblingElement(curElem);
-        if (curElem != null && curElem.getLocalName().equals("J")) {
-	    j = new DOMCryptoBinary(curElem.getFirstChild());
-	    curElem = DOMUtils.getNextSiblingElement(curElem);
-	}
-	if (curElem != null) {
-	    seed = new DOMCryptoBinary(curElem.getFirstChild());
-	    curElem = DOMUtils.getNextSiblingElement(curElem);
-	    pgen = new DOMCryptoBinary(curElem.getFirstChild());
-	}
-	//@@@ do we care about j, pgenCounter or seed?
-	DSAPublicKeySpec spec = new DSAPublicKeySpec
-	    (y.getBigNum(), p.getBigNum(), q.getBigNum(), g.getBigNum());
-        return (DSAPublicKey) generatePublicKey(dsakf, spec);
-    }
-
-    private RSAPublicKey unmarshalRSAKeyValue(Element kvtElem) 
-	throws MarshalException {
-	if (rsakf == null) {
-	    try {
-	        rsakf = KeyFactory.getInstance("RSA");
-	    } catch (NoSuchAlgorithmException e) {
-	        throw new RuntimeException("unable to create RSA KeyFactory: " +
-		    e.getMessage());
-	    }
-	}
-	Element modulusElem = DOMUtils.getFirstChildElement(kvtElem);
-        modulus = new DOMCryptoBinary(modulusElem.getFirstChild());
-	Element exponentElem = DOMUtils.getNextSiblingElement(modulusElem);
-        exponent = new DOMCryptoBinary(exponentElem.getFirstChild());
-        RSAPublicKeySpec spec = new RSAPublicKeySpec
-	    (modulus.getBigNum(), exponent.getBigNum());
-        return (RSAPublicKey) generatePublicKey(rsakf, spec);
-    }
-
-    private PublicKey generatePublicKey(KeyFactory kf, KeySpec keyspec) {
+    private static PublicKey generatePublicKey(KeyFactory kf, KeySpec keyspec) {
         try {
             return kf.generatePublic(keyspec);
         } catch (InvalidKeySpecException e) {
@@ -266,8 +149,236 @@ public final class DOMKeyValue extends D
         return true;
     }
 
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 45;
+    static final class RSA extends DOMKeyValue {
+        // RSAKeyValue CryptoBinaries
+        private DOMCryptoBinary modulus, exponent;
+        private KeyFactory rsakf;
+
+        RSA(PublicKey key) throws KeyException {
+            super(key);
+	    RSAPublicKey rkey = (RSAPublicKey) key;
+	    exponent = new DOMCryptoBinary(rkey.getPublicExponent());
+	    modulus = new DOMCryptoBinary(rkey.getModulus());
+        }
+
+        RSA(Element elem) throws MarshalException {
+            super(elem);
+        }
+
+        void marshalPublicKey(Node parent, Document doc, String dsPrefix, 
+            DOMCryptoContext context) throws MarshalException {
+            Element rsaElem = DOMUtils.createElement
+	        (doc, "RSAKeyValue", XMLSignature.XMLNS, dsPrefix);
+            Element modulusElem = DOMUtils.createElement
+	        (doc, "Modulus", XMLSignature.XMLNS, dsPrefix);
+            Element exponentElem = DOMUtils.createElement
+	        (doc, "Exponent", XMLSignature.XMLNS, dsPrefix);
+	    modulus.marshal(modulusElem, dsPrefix, context);
+	    exponent.marshal(exponentElem, dsPrefix, context);
+            rsaElem.appendChild(modulusElem);
+            rsaElem.appendChild(exponentElem);
+            parent.appendChild(rsaElem);
+        }
+
+        PublicKey unmarshalKeyValue(Element kvtElem) 
+	    throws MarshalException {
+	    if (rsakf == null) {
+	        try {
+	            rsakf = KeyFactory.getInstance("RSA");
+	        } catch (NoSuchAlgorithmException e) {
+	            throw new RuntimeException
+                        ("unable to create RSA KeyFactory: " + e.getMessage());
+	        }
+	    }
+	    Element modulusElem = DOMUtils.getFirstChildElement(kvtElem);
+            modulus = new DOMCryptoBinary(modulusElem.getFirstChild());
+	    Element exponentElem = DOMUtils.getNextSiblingElement(modulusElem);
+            exponent = new DOMCryptoBinary(exponentElem.getFirstChild());
+            RSAPublicKeySpec spec = new RSAPublicKeySpec
+	        (modulus.getBigNum(), exponent.getBigNum());
+            return generatePublicKey(rsakf, spec);
+        }
+    }
+
+    static final class DSA extends DOMKeyValue {
+        // DSAKeyValue CryptoBinaries
+        private DOMCryptoBinary p, q, g, y, j, seed, pgen;
+        private KeyFactory dsakf;
+
+        DSA(PublicKey key) throws KeyException {
+            super(key);
+	    DSAPublicKey dkey = (DSAPublicKey) key;
+	    DSAParams params = dkey.getParams();
+	    p = new DOMCryptoBinary(params.getP());
+	    q = new DOMCryptoBinary(params.getQ());
+	    g = new DOMCryptoBinary(params.getG());
+	    y = new DOMCryptoBinary(dkey.getY());
+        }
+
+        DSA(Element elem) throws MarshalException {
+            super(elem);
+        }
+
+        void marshalPublicKey(Node parent, Document doc, String dsPrefix, 
+            DOMCryptoContext context) throws MarshalException {
+            Element dsaElem = DOMUtils.createElement
+	        (doc, "DSAKeyValue", XMLSignature.XMLNS, dsPrefix);
+            // parameters J, Seed & PgenCounter are not included
+            Element pElem = DOMUtils.createElement
+	        (doc, "P", XMLSignature.XMLNS, dsPrefix);
+            Element qElem = DOMUtils.createElement
+	        (doc, "Q", XMLSignature.XMLNS, dsPrefix);
+            Element gElem = DOMUtils.createElement
+	        (doc, "G", XMLSignature.XMLNS, dsPrefix);
+            Element yElem = DOMUtils.createElement
+	        (doc, "Y", XMLSignature.XMLNS, dsPrefix);
+            p.marshal(pElem, dsPrefix, context);
+            q.marshal(qElem, dsPrefix, context);
+            g.marshal(gElem, dsPrefix, context);
+            y.marshal(yElem, dsPrefix, context);
+            dsaElem.appendChild(pElem);
+            dsaElem.appendChild(qElem);
+            dsaElem.appendChild(gElem);
+            dsaElem.appendChild(yElem);
+            parent.appendChild(dsaElem);
+        }
+
+        PublicKey unmarshalKeyValue(Element kvtElem) 
+	    throws MarshalException {
+	    if (dsakf == null) {
+	        try {
+	            dsakf = KeyFactory.getInstance("DSA");
+	        } catch (NoSuchAlgorithmException e) {
+	            throw new RuntimeException
+                        ("unable to create DSA KeyFactory: " + e.getMessage());
+	        }
+	    }
+	    Element curElem = DOMUtils.getFirstChildElement(kvtElem);
+	    // check for P and Q
+	    if (curElem.getLocalName().equals("P")) {
+	        p = new DOMCryptoBinary(curElem.getFirstChild());
+	        curElem = DOMUtils.getNextSiblingElement(curElem);
+	        q = new DOMCryptoBinary(curElem.getFirstChild());
+	        curElem = DOMUtils.getNextSiblingElement(curElem);
+	    } 
+            if (curElem.getLocalName().equals("G")) {
+                g = new DOMCryptoBinary(curElem.getFirstChild());
+	        curElem = DOMUtils.getNextSiblingElement(curElem);
+	    }
+            y = new DOMCryptoBinary(curElem.getFirstChild());
+            curElem = DOMUtils.getNextSiblingElement(curElem);
+            if (curElem != null && curElem.getLocalName().equals("J")) {
+	        j = new DOMCryptoBinary(curElem.getFirstChild());
+	        curElem = DOMUtils.getNextSiblingElement(curElem);
+	    }
+	    if (curElem != null) {
+	        seed = new DOMCryptoBinary(curElem.getFirstChild());
+	        curElem = DOMUtils.getNextSiblingElement(curElem);
+	        pgen = new DOMCryptoBinary(curElem.getFirstChild());
+	    }
+	    //@@@ do we care about j, pgenCounter or seed?
+	    DSAPublicKeySpec spec = new DSAPublicKeySpec
+	        (y.getBigNum(), p.getBigNum(), q.getBigNum(), g.getBigNum());
+            return generatePublicKey(dsakf, spec);
+        }
+    }
+
+    static final class EC extends DOMKeyValue {
+        // ECKeyValue CryptoBinaries
+        private byte[] ecPublicKey;
+        private KeyFactory eckf;
+        private ECParameterSpec ecParams;
+
+        EC(PublicKey key) throws KeyException {
+            super(key);
+            ECPublicKey ecKey = (ECPublicKey) key;
+            ECPoint ecPoint = ecKey.getW();
+            ecParams = ecKey.getParams();
+            ecPublicKey = sun.security.ec.ECParameters.encodePoint(
+                ecPoint, ecParams.getCurve());
+        }
+
+        EC(Element dmElem) throws MarshalException {
+            super(dmElem);
+        }
+
+        void marshalPublicKey(Node parent, Document doc, String dsPrefix, 
+            DOMCryptoContext context) throws MarshalException {
+            String prefix = DOMUtils.getNSPrefix(context, XMLDSIG_11_XMLNS);
+            Element ecKeyValueElem = DOMUtils.createElement
+	        (doc, "ECKeyValue", XMLDSIG_11_XMLNS, prefix);
+            Element namedCurveElem = DOMUtils.createElement
+	        (doc, "NamedCurve", XMLDSIG_11_XMLNS, prefix);
+            Element publicKeyElem = DOMUtils.createElement
+	        (doc, "PublicKey", XMLDSIG_11_XMLNS, prefix);
+            String oid = sun.security.ec.ECParameters.getCurveName(ecParams);
+            DOMUtils.setAttribute(namedCurveElem, "URI", "urn:oid:" + oid);
+	    String qname = (prefix == null || prefix.length() == 0) 
+		       ? "xmlns" : "xmlns:" + prefix;
+            namedCurveElem.setAttributeNS
+                ("http://www.w3.org/2000/xmlns/", qname, XMLDSIG_11_XMLNS);
+            ecKeyValueElem.appendChild(namedCurveElem);
+            String encoded = Base64.encode(ecPublicKey);
+            publicKeyElem.appendChild
+	        (DOMUtils.getOwnerDocument(publicKeyElem).createTextNode(encoded));
+            ecKeyValueElem.appendChild(publicKeyElem);
+            parent.appendChild(ecKeyValueElem);
+        }
+
+        PublicKey unmarshalKeyValue(Element kvtElem) 
+	    throws MarshalException {
+	    if (eckf == null) {
+	        try {
+	            eckf = KeyFactory.getInstance("EC");
+	        } catch (NoSuchAlgorithmException e) {
+	            throw new RuntimeException
+                        ("unable to create EC KeyFactory: " + e.getMessage());
+	        }
+	    }
+            ECParameterSpec ecParams = null;
+	    Element curElem = DOMUtils.getFirstChildElement(kvtElem);
+            if (curElem.getLocalName().equals("ECParameters")) {
+                throw new UnsupportedOperationException
+                    ("ECParameters not supported");
+            } else if (curElem.getLocalName().equals("NamedCurve")) {
+                String uri = DOMUtils.getAttributeValue(curElem, "URI");
+                // strip off "urn:oid"
+                if (uri.startsWith("urn:oid:")) {
+                    String oid = uri.substring(8);
+                    ecParams = sun.security.ec.NamedCurve.getECParameterSpec(oid);
+                } else {
+                    throw new MarshalException("Invalid NamedCurve URI");
+                }
+            } else {
+                throw new MarshalException("Invalid ECKeyValue");
+            }
+	    curElem = DOMUtils.getNextSiblingElement(curElem);
+            ECPoint ecPoint = null;
+            try {
+                ecPoint = sun.security.ec.ECParameters.decodePoint(
+                    Base64.decode(curElem), ecParams.getCurve());
+            } catch (Base64DecodingException bde) {
+                throw new MarshalException("Invalid EC PublicKey", bde);
+            } catch (IOException ioe) {
+                throw new MarshalException("Invalid EC PublicKey", ioe);
+            }
+            ECPublicKeySpec spec = new ECPublicKeySpec(ecPoint, ecParams);
+            return generatePublicKey(eckf, spec);
+        }
+    }
+
+    static final class Unknown extends DOMKeyValue {
+        private javax.xml.crypto.dom.DOMStructure externalPublicKey;
+        Unknown(Element elem) throws MarshalException {
+            super(elem);
+        }
+        PublicKey unmarshalKeyValue(Element kvElem) throws MarshalException {
+            externalPublicKey = new javax.xml.crypto.dom.DOMStructure(kvElem);
+            return null;
+        }
+        void marshalPublicKey(Node parent, Document doc, String dsPrefix, 
+            DOMCryptoContext context) throws MarshalException {
+	    parent.appendChild(externalPublicKey.getNode());
+        }
     }
 }

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMManifest.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMManifest.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMManifest.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMManifest.java Tue Jul 20 19:00:52 2010
@@ -131,9 +131,4 @@ public final class DOMManifest extends D
 
 	return (idsEqual && references.equals(oman.getReferences()));
     }
-
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 46;
-    }
 }

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMReference.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMReference.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMReference.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMReference.java Tue Jul 20 19:00:52 2010
@@ -519,11 +519,6 @@ public final class DOMReference extends 
             allTransforms.equals(oref.getTransforms()) && digestValuesEqual;
     }
 
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 47;
-    }
-
     boolean isDigested() {
 	return digested;
     }

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java Tue Jul 20 19:00:52 2010
@@ -247,9 +247,4 @@ public final class DOMRetrievalMethod ex
 	return (uri.equals(orm.getURI()) && 
 	    transforms.equals(orm.getTransforms()) && typesEqual);
     }
-
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 48;
-    }
 }

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java Tue Jul 20 19:00:52 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2010 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
 package org.jcp.xml.dsig.internal.dom;
 
 import javax.xml.crypto.*;
-import javax.xml.crypto.dom.DOMCryptoContext;
 import javax.xml.crypto.dsig.*;
 import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
 
@@ -32,10 +31,9 @@ import java.security.*;
 import java.security.spec.AlgorithmParameterSpec;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
 
+import org.apache.xml.security.algorithms.implementations.SignatureECDSA;
 import org.jcp.xml.dsig.internal.SignerOutputStream;
 
 /**
@@ -43,8 +41,7 @@ import org.jcp.xml.dsig.internal.SignerO
  *
  * @author Sean Mullan
  */
-public abstract class DOMSignatureMethod extends DOMStructure 
-    implements SignatureMethod {
+public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
 
     private static Logger log =
         Logger.getLogger("org.jcp.xml.dsig.internal.dom");
@@ -56,12 +53,14 @@ public abstract class DOMSignatureMethod
         "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384";
     final static String RSA_SHA512 =
         "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512";
-    final static String HMAC_SHA256 =
-        "http://www.w3.org/2001/04/xmldsig-more#hmac-sha256";
-    final static String HMAC_SHA384 =
-        "http://www.w3.org/2001/04/xmldsig-more#hmac-sha384";
-    final static String HMAC_SHA512 =
-        "http://www.w3.org/2001/04/xmldsig-more#hmac-sha512";
+    final static String ECDSA_SHA1 =
+        "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1";
+    final static String ECDSA_SHA256 =
+        "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256";
+    final static String ECDSA_SHA384 =
+        "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384";
+    final static String ECDSA_SHA512 =
+        "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512";
 
     private SignatureMethodParameterSpec params;
     private Signature signature;
@@ -86,7 +85,7 @@ public abstract class DOMSignatureMethod
 
     /**
      * Creates a <code>DOMSignatureMethod</code> from an element. This ctor
-     * invokes the abstract {@link #unmarshalParams unmarshalParams} method to
+     * invokes the {@link #unmarshalParams unmarshalParams} method to
      * unmarshal any algorithm-specific input parameters.
      *
      * @param smElem a SignatureMethod element
@@ -115,13 +114,21 @@ public abstract class DOMSignatureMethod
             return new SHA512withRSA(smElem);
         } else if (alg.equals(SignatureMethod.DSA_SHA1)) {
             return new SHA1withDSA(smElem);
+        } else if (alg.equals(ECDSA_SHA1)) {
+            return new SHA1withECDSA(smElem);
+        } else if (alg.equals(ECDSA_SHA256)) {
+            return new SHA256withECDSA(smElem);
+        } else if (alg.equals(ECDSA_SHA384)) {
+            return new SHA384withECDSA(smElem);
+        } else if (alg.equals(ECDSA_SHA512)) {
+            return new SHA512withECDSA(smElem);
         } else if (alg.equals(SignatureMethod.HMAC_SHA1)) {
             return new DOMHMACSignatureMethod.SHA1(smElem);
-        } else if (alg.equals(HMAC_SHA256)) {
+        } else if (alg.equals(DOMHMACSignatureMethod.HMAC_SHA256)) {
             return new DOMHMACSignatureMethod.SHA256(smElem);
-        } else if (alg.equals(HMAC_SHA384)) {
+        } else if (alg.equals(DOMHMACSignatureMethod.HMAC_SHA384)) {
             return new DOMHMACSignatureMethod.SHA384(smElem);
-        } else if (alg.equals(HMAC_SHA512)) {
+        } else if (alg.equals(DOMHMACSignatureMethod.HMAC_SHA512)) {
             return new DOMHMACSignatureMethod.SHA512(smElem);
         } else {
             throw new MarshalException
@@ -129,84 +136,11 @@ public abstract class DOMSignatureMethod
         }
     }
 
-    /**
-     * Checks if the specified parameters are valid for this algorithm. By
-     * default, this method throws an exception if parameters are specified
-     * since most SignatureMethod algorithms do not have parameters. Subclasses
-     * should override it if they have parameters.
-     *
-     * @param params the algorithm-specific params (may be <code>null</code>)
-     * @throws InvalidAlgorithmParameterException if the parameters are not
-     *    appropriate for this signature method
-     */
-    void checkParams(SignatureMethodParameterSpec params) 
-	throws InvalidAlgorithmParameterException {
-        if (params != null) {
-            throw new InvalidAlgorithmParameterException("no parameters " +
-                "should be specified for the " + getSignatureAlgorithm()
-                 + " SignatureMethod algorithm");
-        }
-    }
-
     public final AlgorithmParameterSpec getParameterSpec() {
 	return params;
     }
 
-    /**
-     * Unmarshals <code>SignatureMethodParameterSpec</code> from the specified 
-     * <code>Element</code>. By default, this method throws an exception since
-     * most SignatureMethod algorithms do not have parameters. Subclasses should
-     * override it if they have parameters.
-     *
-     * @param paramsElem the <code>Element</code> holding the input params
-     * @return the algorithm-specific <code>SignatureMethodParameterSpec</code>
-     * @throws MarshalException if the parameters cannot be unmarshalled
-     */
-    SignatureMethodParameterSpec 
-	unmarshalParams(Element paramsElem) throws MarshalException {
-        throw new MarshalException("no parameters should " +
-            "be specified for the " + getSignatureAlgorithm() +
-            " SignatureMethod algorithm");
-    }
-
-    /**
-     * This method invokes the abstract {@link #marshalParams marshalParams} 
-     * method to marshal any algorithm-specific parameters.
-     */
-    public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
-	throws MarshalException {
-        Document ownerDoc = DOMUtils.getOwnerDocument(parent);
-
-        Element smElem = DOMUtils.createElement
-	    (ownerDoc, "SignatureMethod", XMLSignature.XMLNS, dsPrefix);
-        DOMUtils.setAttribute(smElem, "Algorithm", getAlgorithm());
-
-        if (params != null) {
-	    marshalParams(smElem, dsPrefix);
-        }
-
-        parent.appendChild(smElem);
-    }
-
-    /**
-     * Verifies the passed-in signature with the specified key, using the
-     * underlying signature or MAC algorithm.
-     *
-     * @param key the verification key
-     * @param si the DOMSignedInfo
-     * @param signature the signature bytes to be verified
-     * @param context the XMLValidateContext
-     * @return <code>true</code> if the signature verified successfully,
-     *    <code>false</code> if not
-     * @throws NullPointerException if <code>key</code>, <code>si</code> or
-     *    <code>signature</code> are <code>null</code>
-     * @throws InvalidKeyException if the key is improperly encoded, of
-     *    the wrong type, or parameters are missing, etc
-     * @throws SignatureException if an unexpected error occurs, such
-     *    as the passed in signature is improperly encoded
-     * @throws XMLSignatureException if an unexpected error occurs
-     */
-    boolean verify(Key key, DOMSignedInfo si, byte[] sig,
+    boolean verify(Key key, SignedInfo si, byte[] sig,
 	XMLValidateContext context) throws InvalidKeyException, 
 	SignatureException, XMLSignatureException {
         if (key == null || si == null || sig == null) {
@@ -221,8 +155,8 @@ public abstract class DOMSignatureMethod
                 Provider p = (Provider) context.getProperty
                     ("org.jcp.xml.dsig.internal.dom.SignatureProvider");
                 signature = (p == null) 
-		    ? Signature.getInstance(getSignatureAlgorithm())
-                    : Signature.getInstance(getSignatureAlgorithm(), p);
+                    ? Signature.getInstance(getJCAAlgorithm()) 
+                    : Signature.getInstance(getJCAAlgorithm(), p);
             } catch (NoSuchAlgorithmException nsae) {
                 throw new XMLSignatureException(nsae);
             }
@@ -232,34 +166,23 @@ public abstract class DOMSignatureMethod
             log.log(Level.FINE, "Signature provider:"+ signature.getProvider());
             log.log(Level.FINE, "verifying with key: " + key);
         }
-        si.canonicalize(context, new SignerOutputStream(signature));
+        ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature));
 
-        if (getAlgorithm().equals(SignatureMethod.DSA_SHA1)) {
-            try {
+        try {
+            int type = getAlgorithmType();
+            if (type == DSA) {
                 return signature.verify(convertXMLDSIGtoASN1(sig));
-            } catch (IOException ioe) {
-                throw new XMLSignatureException(ioe);
+            } else if (type == ECDSA) {
+                return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig));
+            } else {
+                return signature.verify(sig);
             }
-        } else {
-            return signature.verify(sig);
+        } catch (IOException ioe) {
+            throw new XMLSignatureException(ioe);
         }
     }
 
-    /**
-     * Signs the bytes with the specified key, using the underlying
-     * signature or MAC algorithm.
-     *
-     * @param key the signing key
-     * @param si the DOMSignedInfo
-     * @param context the XMLSignContext
-     * @return the signature
-     * @throws NullPointerException if <code>key</code> or
-     *    <code>si</code> are <code>null</code>
-     * @throws InvalidKeyException if the key is improperly encoded, of
-     *    the wrong type, or parameters are missing, etc
-     * @throws XMLSignatureException if an unexpected error occurs
-     */
-    byte[] sign(Key key, DOMSignedInfo si, XMLSignContext context) 
+    byte[] sign(Key key, SignedInfo si, XMLSignContext context) 
         throws InvalidKeyException, XMLSignatureException {
         if (key == null || si == null) {
             throw new NullPointerException();
@@ -273,8 +196,8 @@ public abstract class DOMSignatureMethod
                 Provider p = (Provider) context.getProperty
                     ("org.jcp.xml.dsig.internal.dom.SignatureProvider");
                 signature = (p == null) 
-		    ? Signature.getInstance(getSignatureAlgorithm())
-                    : Signature.getInstance(getSignatureAlgorithm(), p);
+                    ? Signature.getInstance(getJCAAlgorithm()) 
+                    : Signature.getInstance(getJCAAlgorithm(), p);
             } catch (NoSuchAlgorithmException nsae) {
                 throw new XMLSignatureException(nsae);
             }
@@ -285,11 +208,14 @@ public abstract class DOMSignatureMethod
             log.log(Level.FINE, "Signing with key: " + key);
         }
 
-        si.canonicalize(context, new SignerOutputStream(signature));
+        ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature));
 
         try {
-            if (getAlgorithm().equals(SignatureMethod.DSA_SHA1)) {
+            int type = getAlgorithmType();
+            if (type == DSA) {
                 return convertASN1toXMLDSIG(signature.sign());
+            } else if (type == ECDSA) {
+                return SignatureECDSA.convertASN1toXMLDSIG(signature.sign());
             } else {
                 return signature.sign();
             }
@@ -301,52 +227,6 @@ public abstract class DOMSignatureMethod
     }
 
     /**
-     * Marshals the algorithm-specific parameters to an Element and
-     * appends it to the specified parent element. By default, this method
-     * throws an exception since most SignatureMethod algorithms do not have
-     * parameters. Subclasses should override it if they have parameters.
-     *
-     * @param parent the parent element to append the parameters to
-     * @param paramsPrefix the algorithm parameters prefix to use
-     * @throws MarshalException if the parameters cannot be marshalled
-     */
-    void marshalParams(Element parent, String paramsPrefix)
-	throws MarshalException {
-        throw new MarshalException("no parameters should " +
-            "be specified for the " + getSignatureAlgorithm() +
-            " SignatureMethod algorithm");
-    }
-
-    /**
-     * Returns the java.security.Signature standard algorithm name.
-     */
-    abstract String getSignatureAlgorithm();
-
-    /**
-     * Returns true if parameters are equal; false otherwise.
-     *
-     * Subclasses should override this method to compare algorithm-specific
-     * parameters.
-     */
-    boolean paramsEqual(AlgorithmParameterSpec spec) {
-        return (getParameterSpec() == spec);
-    }
-
-    public boolean equals(Object o) {
-	if (this == o) {
-            return true;
-	}
-
-        if (!(o instanceof SignatureMethod)) {
-            return false;
-	}
-        SignatureMethod osm = (SignatureMethod) o;
-
-	return (getAlgorithm().equals(osm.getAlgorithm()) && 
-	    paramsEqual(osm.getParameterSpec()));
-    }
-
-    /**
      * Converts an ASN.1 DSA value to a XML Signature DSA Value.
      *
      * The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
@@ -441,11 +321,6 @@ public abstract class DOMSignatureMethod
         return asn1Bytes;
     }
 
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 57;
-    }
-
     static final class SHA1withRSA extends DOMSignatureMethod {
         SHA1withRSA(AlgorithmParameterSpec params)
             throws InvalidAlgorithmParameterException {
@@ -457,9 +332,12 @@ public abstract class DOMSignatureMethod
         public String getAlgorithm() {
             return SignatureMethod.RSA_SHA1;
         }
-        String getSignatureAlgorithm() {
+        String getJCAAlgorithm() {
             return "SHA1withRSA";
         }
+        int getAlgorithmType() {
+            return RSA;
+        }
     }
 
     static final class SHA256withRSA extends DOMSignatureMethod {
@@ -473,9 +351,12 @@ public abstract class DOMSignatureMethod
         public String getAlgorithm() {
             return RSA_SHA256;
         }
-        String getSignatureAlgorithm() {
+        String getJCAAlgorithm() {
             return "SHA256withRSA";
         }
+        int getAlgorithmType() {
+            return RSA;
+        }
     }
 
     static final class SHA384withRSA extends DOMSignatureMethod {
@@ -489,9 +370,12 @@ public abstract class DOMSignatureMethod
         public String getAlgorithm() {
             return RSA_SHA384;
         }
-        String getSignatureAlgorithm() {
+        String getJCAAlgorithm() {
             return "SHA384withRSA";
         }
+        int getAlgorithmType() {
+            return RSA;
+        }
     }
 
     static final class SHA512withRSA extends DOMSignatureMethod {
@@ -505,9 +389,12 @@ public abstract class DOMSignatureMethod
         public String getAlgorithm() {
             return RSA_SHA512;
         }
-        String getSignatureAlgorithm() {
+        String getJCAAlgorithm() {
             return "SHA512withRSA";
         }
+        int getAlgorithmType() {
+            return RSA;
+        }
     }
 
     static final class SHA1withDSA extends DOMSignatureMethod {
@@ -521,8 +408,87 @@ public abstract class DOMSignatureMethod
         public String getAlgorithm() {
             return SignatureMethod.DSA_SHA1;
         }
-        String getSignatureAlgorithm() {
+        String getJCAAlgorithm() {
             return "SHA1withDSA";
         }
+        int getAlgorithmType() {
+            return DSA;
+        }
+    }
+
+    static final class SHA1withECDSA extends DOMSignatureMethod {
+        SHA1withECDSA(AlgorithmParameterSpec params)
+            throws InvalidAlgorithmParameterException {
+            super(params);
+        }
+        SHA1withECDSA(Element dmElem) throws MarshalException {
+            super(dmElem);
+        }
+        public String getAlgorithm() {
+            return ECDSA_SHA1;
+        }
+        String getJCAAlgorithm() {
+            return "SHA1withECDSA";
+        }
+        int getAlgorithmType() {
+            return ECDSA;
+        }
+    }
+
+    static final class SHA256withECDSA extends DOMSignatureMethod {
+        SHA256withECDSA(AlgorithmParameterSpec params)
+            throws InvalidAlgorithmParameterException {
+            super(params);
+        }
+        SHA256withECDSA(Element dmElem) throws MarshalException {
+            super(dmElem);
+        }
+        public String getAlgorithm() {
+            return ECDSA_SHA256;
+        }
+        String getJCAAlgorithm() {
+            return "SHA256withECDSA";
+        }
+        int getAlgorithmType() {
+            return ECDSA;
+        }
+    }
+
+    static final class SHA384withECDSA extends DOMSignatureMethod {
+        SHA384withECDSA(AlgorithmParameterSpec params)
+            throws InvalidAlgorithmParameterException {
+            super(params);
+        }
+        SHA384withECDSA(Element dmElem) throws MarshalException {
+            super(dmElem);
+        }
+        public String getAlgorithm() {
+            return ECDSA_SHA384;
+        }
+        String getJCAAlgorithm() {
+            return "SHA384withECDSA";
+        }
+        int getAlgorithmType() {
+            return ECDSA;
+        }
+    }
+
+    static final class SHA512withECDSA extends DOMSignatureMethod {
+        SHA512withECDSA(AlgorithmParameterSpec params)
+            throws InvalidAlgorithmParameterException {
+            super(params);
+        }
+        SHA512withECDSA(Element dmElem) throws MarshalException {
+            super(dmElem);
+        }
+        public String getAlgorithm() {
+            return ECDSA_SHA512;
+        }
+        String getJCAAlgorithm() {
+            return "SHA512withECDSA";
+        }
+        int getAlgorithmType() {
+            return ECDSA;
+        }
     }
 }

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java Tue Jul 20 19:00:52 2010
@@ -143,9 +143,4 @@ public final class DOMSignaturePropertie
 
 	return (properties.equals(osp.getProperties()) && idsEqual);
     }
-
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 49;
-    }
 }

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java Tue Jul 20 19:00:52 2010
@@ -155,11 +155,6 @@ public final class DOMSignatureProperty 
 	    target.equals(osp.getTarget()) && idsEqual);
     }
 
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 50;
-    }
-
     private boolean equalsContent(List otherContent) {
 	int osize = otherContent.size();
 	if (content.size() != osize) {

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java Tue Jul 20 19:00:52 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2009 The Apache Software Foundation.
+ * Copyright 2005-2010 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -220,8 +220,7 @@ public final class DOMSignedInfo extends
 	dcm.marshal(siElem, dsPrefix, context); 
 
 	// create and append SignatureMethod element
-	((DOMSignatureMethod) signatureMethod).marshal
-	    (siElem, dsPrefix, context);
+	((DOMStructure) signatureMethod).marshal(siElem, dsPrefix, context);
 
 	// create and append Reference elements
 	for (int i = 0, size = references.size(); i < size; i++) {
@@ -253,9 +252,4 @@ public final class DOMSignedInfo extends
 	    && signatureMethod.equals(osi.getSignatureMethod()) && 
 	    references.equals(osi.getReferences()) && idEqual);
     }
-
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 59;
-    }
 }

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMTransform.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMTransform.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMTransform.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMTransform.java Tue Jul 20 19:00:52 2010
@@ -162,11 +162,6 @@ public class DOMTransform extends DOMStr
 		(getParameterSpec(), otransform.getParameterSpec()));
     }
 
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 58;
-    }
-
     /**
      * Transforms the specified data using the underlying transform algorithm.
      * This method invokes the {@link #marshal marshal} method and passes it

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMX509Data.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMX509Data.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMX509Data.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMX509Data.java Tue Jul 20 19:00:52 2010
@@ -278,9 +278,4 @@ public final class DOMX509Data extends D
 
 	return true;
     }
-
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 56;
-    }
 }

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java Tue Jul 20 19:00:52 2010
@@ -117,9 +117,4 @@ public final class DOMX509IssuerSerial e
 	return (issuerName.equals(ois.getIssuerName()) && 
 	    serialNumber.equals(ois.getSerialNumber()));
     }
-
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 52;
-    }
 }

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java Tue Jul 20 19:00:52 2010
@@ -183,11 +183,6 @@ public final class DOMXMLObject extends 
 	    equalsContent(oxo.getContent()));
     }
 
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 53;
-    }
-
     private boolean equalsContent(List otherContent) {
 	if (content.size() != otherContent.size()) {
 	    return false;

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java Tue Jul 20 19:00:52 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2009 The Apache Software Foundation.
+ * Copyright 2005-2010 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -386,16 +386,14 @@ public final class DOMXMLSignature exten
 	}
 
 	// calculate signature value
-	byte[] val = null;
 	try {
-            val = ((DOMSignatureMethod) si.getSignatureMethod()).sign
-		(signingKey, (DOMSignedInfo) si, signContext);
+            byte[] val = ((AbstractDOMSignatureMethod) 
+                si.getSignatureMethod()).sign(signingKey, si, signContext);
+	    ((DOMSignatureValue) sv).setValue(val);
 	} catch (InvalidKeyException ike) {
             throw new XMLSignatureException(ike);
 	}
 
-	((DOMSignatureValue) sv).setValue(val);
-
         this.localSigElem = sigElem;   
 	this.ksr = ksr;
     }
@@ -422,11 +420,6 @@ public final class DOMXMLSignature exten
 	    objects.equals(osig.getObjects()));
     }
 
-    public int hashCode() {
-	assert false : "hashCode not designed";
-	return 54;
-    }
-
     private void digestReference(DOMReference ref, XMLSignContext signContext)
 	throws XMLSignatureException {
 	if (ref.isDigested()) {
@@ -531,8 +524,8 @@ public final class DOMXMLSignature exten
 
 	    // canonicalize SignedInfo and verify signature
 	    try {
-		validationStatus = ((DOMSignatureMethod) sm).verify
-		    (validationKey, (DOMSignedInfo) si, value, validateContext);
+		validationStatus = ((AbstractDOMSignatureMethod) sm).verify
+		    (validationKey, si, value, validateContext);
 	    } catch (Exception e) {
 		throw new XMLSignatureException(e);
 	    }
@@ -558,12 +551,6 @@ public final class DOMXMLSignature exten
 	    //XXX compare signature values?
 	    return idEqual;
 	}
-    
-        public int hashCode() {
-	    // uncomment when JDK 1.4 is required
-	    // assert false : "hashCode not designed";
-	    return 55;
-	}
 
 	public void marshal(Node parent, String dsPrefix,
 	    DOMCryptoContext context) throws MarshalException {

Modified: xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java Tue Jul 20 19:00:52 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2009 The Apache Software Foundation.
+ * Copyright 2005-2010 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -216,12 +216,20 @@ public final class DOMXMLSignatureFactor
             return new DOMSignatureMethod.SHA1withDSA(params);
         } else if (algorithm.equals(SignatureMethod.HMAC_SHA1)) {
             return new DOMHMACSignatureMethod.SHA1(params);
-        } else if (algorithm.equals(DOMSignatureMethod.HMAC_SHA256)) {
+        } else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA256)) {
             return new DOMHMACSignatureMethod.SHA256(params);
-        } else if (algorithm.equals(DOMSignatureMethod.HMAC_SHA384)) {
+        } else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA384)) {
             return new DOMHMACSignatureMethod.SHA384(params);
-        } else if (algorithm.equals(DOMSignatureMethod.HMAC_SHA512)) {
+        } else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA512)) {
             return new DOMHMACSignatureMethod.SHA512(params);
+        } else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA1)) {
+            return new DOMSignatureMethod.SHA1withECDSA(params);
+        } else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA256)) {
+            return new DOMSignatureMethod.SHA256withECDSA(params);
+        } else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA384)) {
+            return new DOMSignatureMethod.SHA384withECDSA(params);
+        } else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA512)) {
+            return new DOMSignatureMethod.SHA512withECDSA(params);
         } else {
             throw new NoSuchAlgorithmException("unsupported algorithm");
         }

Modified: xml/security/branches/java_xmldsig11_ecdsa/src_samples/javax/xml/crypto/dsig/samples/Validate.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src_samples/javax/xml/crypto/dsig/samples/Validate.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src_samples/javax/xml/crypto/dsig/samples/Validate.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src_samples/javax/xml/crypto/dsig/samples/Validate.java Tue Jul 20 19:00:52 2010
@@ -14,7 +14,6 @@
  *  limitations under the License.
  *
  */
-package javax.xml.crypto.dsig.samples;
 
 import javax.xml.crypto.*;
 import javax.xml.crypto.dsig.*;
@@ -137,6 +136,9 @@ public class Validate {
             } else if (algName.equalsIgnoreCase("RSA") &&
                        algURI.equalsIgnoreCase(SignatureMethod.RSA_SHA1)) {
 		return true;
+            } else if (algName.equalsIgnoreCase("EC") &&
+                       algURI.equalsIgnoreCase("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256")) {
+		return true;
             } else {
 		return false;
             }

Modified: xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/KeySelectors.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/KeySelectors.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/KeySelectors.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/KeySelectors.java Tue Jul 20 19:00:52 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2009 The Apache Software Foundation.
+ * Copyright 2006-2010 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -156,27 +156,11 @@ public class KeySelectors {
 		    } catch (KeyException ke) {
 			throw new KeySelectorException(ke);
 		    }
-		    // make sure algorithm is compatible with method
-		    if (algEquals(sm.getAlgorithm(), pk.getAlgorithm())) {
-			return new SimpleKSResult(pk);
-		    } 
+		    return new SimpleKSResult(pk);
 		}
 	    }
 	    throw new KeySelectorException("No KeyValue element found!");
 	}
-	
-	//@@@FIXME: this should also work for key types other than DSA/RSA
-	static boolean algEquals(String algURI, String algName) {
-	    if (algName.equalsIgnoreCase("DSA") && 
-		algURI.equalsIgnoreCase(SignatureMethod.DSA_SHA1)) {
-		return true;
-	    } else if (algName.equalsIgnoreCase("RSA") &&
-		       algURI.equalsIgnoreCase(SignatureMethod.RSA_SHA1)) {
-		return true;
-	    } else {
-		return false;
-	    }
-	}
     }
 
     /**

Added: xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java?rev=965957&view=auto
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java (added)
+++ xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java Tue Jul 20 19:00:52 2010
@@ -0,0 +1,254 @@
+/*
+ * Copyright 2010 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package javax.xml.crypto.test.dsig;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.security.*;
+import java.security.spec.ECGenParameterSpec;
+import java.util.Collections;
+import javax.xml.crypto.KeySelector;
+import javax.xml.crypto.dom.*;
+import javax.xml.crypto.dsig.*;
+import javax.xml.crypto.dsig.dom.*;
+import javax.xml.crypto.dsig.keyinfo.*;
+import javax.xml.crypto.dsig.spec.*;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.*;
+import javax.xml.transform.stream.*;
+import org.w3c.dom.*;
+
+import junit.framework.*;
+
+import javax.xml.crypto.test.KeySelectors;
+
+/**
+ * This is a testcase to generate all the W3C xmldsig XMLDSig11 testcases.
+ *
+ * @author Sean Mullan
+ */
+public class CreateInteropXMLDSig11Test extends TestCase {
+
+    private File dir;
+    private KeySelector kvks, sks;
+    private CanonicalizationMethod withComments, withoutComments;
+    private DigestMethod sha1, sha256, sha384, sha512;
+    private SignatureMethod ecdsaSha1, ecdsaSha256, ecdsaSha384, ecdsaSha512, rsaSha256, rsaSha384, rsaSha512, hmacSha256, hmacSha384, hmacSha512;
+    private KeyInfo p256ki, p384ki, p521ki, rsaki, hmacki;
+    private XMLSignatureFactory fac;
+    private DocumentBuilder db;
+    private KeyPair p256, p384, p521;
+
+    static {
+        Security.insertProviderAt
+            (new org.jcp.xml.dsig.internal.dom.XMLDSigRI(), 1);
+    }
+
+    public CreateInteropXMLDSig11Test(String name) throws Exception {
+        super(name);
+        String fs = File.separator;
+        String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
+    	dir = new File(base + fs + "data" + fs
+            + "org" + fs + "w3c" + fs + "www" + fs
+	    + "interop" + fs + "xmldsig11");
+
+        // Create KeyPairs
+        KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
+        kpg.initialize(new ECGenParameterSpec("1.2.840.10045.3.1.7"));
+        p256 = kpg.generateKeyPair();
+        kpg.initialize(new ECGenParameterSpec("1.3.132.0.34"));
+        p384 = kpg.generateKeyPair();
+        kpg.initialize(new ECGenParameterSpec("1.3.132.0.35"));
+        p521 = kpg.generateKeyPair();
+
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        db = dbf.newDocumentBuilder();
+        // create common objects
+        fac = XMLSignatureFactory.getInstance();
+        KeyInfoFactory kifac = fac.getKeyInfoFactory();
+        withoutComments = fac.newCanonicalizationMethod
+            (CanonicalizationMethod.INCLUSIVE, (C14NMethodParameterSpec) null);
+        withComments = fac.newCanonicalizationMethod
+            (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
+             (C14NMethodParameterSpec) null);
+        sha1 = fac.newDigestMethod(DigestMethod.SHA1, null);
+        sha256 = fac.newDigestMethod(DigestMethod.SHA256, null);
+        sha384 = fac.newDigestMethod("http://www.w3.org/2001/04/xmldsig-more#sha384", null);
+        sha512 = fac.newDigestMethod(DigestMethod.SHA512, null);
+        p256ki = kifac.newKeyInfo(Collections.singletonList(kifac.newKeyValue(p256.getPublic())));
+        p384ki = kifac.newKeyInfo(Collections.singletonList(kifac.newKeyValue(p384.getPublic())));
+        p521ki = kifac.newKeyInfo(Collections.singletonList(kifac.newKeyValue(p521.getPublic())));
+        rsaki = kifac.newKeyInfo(Collections.singletonList(kifac.newKeyValue(TestUtils.getPublicKey("RSA"))));
+        ecdsaSha1 = fac.newSignatureMethod
+            ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1", null);
+        ecdsaSha256 = fac.newSignatureMethod
+            ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256", null);
+        ecdsaSha384 = fac.newSignatureMethod
+            ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384", null);
+        ecdsaSha512 = fac.newSignatureMethod
+            ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512", null);
+        rsaSha256 = fac.newSignatureMethod
+            ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", null);
+        rsaSha384 = fac.newSignatureMethod
+            ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384", null);
+        rsaSha512 = fac.newSignatureMethod
+            ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512", null);
+        hmacSha256 = fac.newSignatureMethod
+            ("http://www.w3.org/2001/04/xmldsig-more#hmac-sha256", null);
+        hmacSha384 = fac.newSignatureMethod
+            ("http://www.w3.org/2001/04/xmldsig-more#hmac-sha384", null);
+        hmacSha512 = fac.newSignatureMethod
+            ("http://www.w3.org/2001/04/xmldsig-more#hmac-sha512", null);
+	kvks = new KeySelectors.KeyValueKeySelector();
+	sks = new KeySelectors.SecretKeySelector("testkey".getBytes("ASCII"));
+    }
+
+    public void test_create_enveloping_p256_sha1() throws Exception {
+        test_create_signature_enveloping(ecdsaSha1, sha1, p256ki, p256.getPrivate(), kvks);
+    }
+
+    private void test_create_signature_enveloping
+        (SignatureMethod sm, DigestMethod dm, KeyInfo ki, Key signingKey,
+        KeySelector ks) throws Exception {
+
+        // create reference
+        Reference ref = fac.newReference("#DSig.Object_1", dm, null,
+                                         XMLObject.TYPE, null);
+
+        // create SignedInfo
+        SignedInfo si = fac.newSignedInfo(withoutComments, sm,
+            Collections.singletonList(ref));
+
+        Document doc = db.newDocument();
+        // create Objects
+        Element webElem = doc.createElementNS(null, "Web");
+        Text text = doc.createTextNode("up up and away");
+        webElem.appendChild(text);
+        XMLObject obj = fac.newXMLObject(Collections.singletonList
+            (new DOMStructure(webElem)), "DSig.Object_1", "text/xml", null);
+
+        // create XMLSignature
+        XMLSignature sig = fac.newXMLSignature
+            (si, ki, Collections.singletonList(obj), null, null);
+
+        DOMSignContext dsc = new DOMSignContext(signingKey, doc);
+        dsc.setDefaultNamespacePrefix("dsig");
+
+        sig.sign(dsc);
+	StringWriter sw = new StringWriter();
+//        dumpDocument(doc, sw);
+        System.out.println(sw.toString());
+
+        DOMValidateContext dvc = new DOMValidateContext
+            (ks, doc.getDocumentElement());
+        XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
+
+        assertTrue(sig.equals(sig2));
+        assertTrue(sig2.validate(dvc));
+    }
+
+    private void dumpDocument(Document doc, Writer w) throws Exception {
+        TransformerFactory tf = TransformerFactory.newInstance();
+        Transformer trans = tf.newTransformer();
+//      trans.setOutputProperty(OutputKeys.INDENT, "yes");
+        trans.transform(new DOMSource(doc), new StreamResult(w));
+    }
+
+    public void test_create_enveloping_p256_sha256() throws Exception {
+        test_create_signature_enveloping(ecdsaSha256, sha256, p256ki, p256.getPrivate(), kvks);
+    }
+
+    public void test_create_enveloping_p256_sha384() throws Exception {
+        test_create_signature_enveloping(ecdsaSha384, sha384, p256ki, p256.getPrivate(), kvks);
+    }
+
+    public void test_create_enveloping_p256_sha512() throws Exception {
+        test_create_signature_enveloping(ecdsaSha512, sha512, p256ki, p256.getPrivate(), kvks);
+    }
+
+    public void test_create_enveloping_p384_sha1() throws Exception {
+        test_create_signature_enveloping(ecdsaSha1, sha1, p384ki, p384.getPrivate(), kvks);
+    }
+
+    public void test_create_enveloping_p384_sha256() throws Exception {
+        test_create_signature_enveloping(ecdsaSha256, sha256, p384ki, p384.getPrivate(), kvks);
+    }
+
+    public void test_create_enveloping_p384_sha384() throws Exception {
+        test_create_signature_enveloping(ecdsaSha384, sha384, p384ki, p384.getPrivate(), kvks);
+    }
+
+    public void test_create_enveloping_p384_sha512() throws Exception {
+        test_create_signature_enveloping(ecdsaSha512, sha512, p384ki, p384.getPrivate(), kvks);
+    }
+
+    public void test_create_enveloping_p521_sha1() throws Exception {
+        test_create_signature_enveloping(ecdsaSha1, sha1, p521ki, p521.getPrivate(), kvks);
+    }
+
+    public void test_create_enveloping_p521_sha256() throws Exception {
+        test_create_signature_enveloping(ecdsaSha256, sha256, p521ki, p521.getPrivate(), kvks);
+    }
+
+    public void test_create_enveloping_p521_sha384() throws Exception {
+        test_create_signature_enveloping(ecdsaSha384, sha384, p521ki, p521.getPrivate(), kvks);
+    }
+
+    public void test_create_enveloping_p521_sha512() throws Exception {
+        test_create_signature_enveloping(ecdsaSha512, sha512, p521ki, p521.getPrivate(), kvks);
+    }
+
+    public void test_create_enveloping_rsa_sha256() throws Exception {
+        test_create_signature_enveloping(rsaSha256, sha1, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+    }
+
+    public void test_create_enveloping_rsa_sha384() throws Exception {
+        test_create_signature_enveloping(rsaSha384, sha1, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+    }
+
+    public void test_create_enveloping_rsa_sha512() throws Exception {
+        test_create_signature_enveloping(rsaSha512, sha1, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+    }
+
+    public void test_create_enveloping_sha256_rsa_sha256() throws Exception {
+        test_create_signature_enveloping(rsaSha256, sha256, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+    }
+
+    public void test_create_enveloping_sha384_rsa_sha256() throws Exception {
+        test_create_signature_enveloping(rsaSha256, sha384, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+    }
+
+    public void test_create_enveloping_sha512_rsa_sha256() throws Exception {
+        test_create_signature_enveloping(rsaSha256, sha512, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+    }
+
+    public void test_create_enveloping_hmac_sha256() throws Exception {
+        test_create_signature_enveloping(hmacSha256, sha1, rsaki, TestUtils.getSecretKey("testkey".getBytes("ASCII")), sks);
+    }
+
+    public void test_create_enveloping_hmac_sha384() throws Exception {
+        test_create_signature_enveloping(hmacSha384, sha1, rsaki, TestUtils.getSecretKey("testkey".getBytes("ASCII")), sks);
+    }
+
+    public void test_create_enveloping_hmac_sha512() throws Exception {
+        test_create_signature_enveloping(hmacSha512, sha1, rsaki, TestUtils.getSecretKey("testkey".getBytes("ASCII")), sks);
+    }
+}

Added: xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java?rev=965957&view=auto
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java (added)
+++ xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java Tue Jul 20 19:00:52 2010
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2010 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package javax.xml.crypto.test.dsig;
+
+import java.io.File;
+import java.security.Security;
+import javax.xml.crypto.KeySelector;
+
+import junit.framework.*;
+
+import javax.xml.crypto.test.KeySelectors;
+
+/**
+ * This is a testcase to validate all the W3C xmldsig XMLDSig11 testcases.
+ *
+ * @author Sean Mullan
+ */
+public class InteropXMLDSig11Test extends TestCase {
+
+    private SignatureValidator validator;
+    private File dir;
+    private KeySelector kvks, sks;
+
+    static {
+        Security.insertProviderAt
+            (new org.jcp.xml.dsig.internal.dom.XMLDSigRI(), 1);
+    }
+
+    public InteropXMLDSig11Test(String name) throws Exception {
+        super(name);
+        String fs = File.separator;
+        String base = System.getProperty("basedir") == null
+            ? "./": System.getProperty("basedir");
+    	dir = new File(base + fs + "data" + fs
+            + "org" + fs + "w3c" + fs + "www" + fs
+	    + "interop" + fs + "xmldsig11");
+        validator = new SignatureValidator(dir);
+	kvks = new KeySelectors.KeyValueKeySelector();
+	sks = new KeySelectors.SecretKeySelector("testkey".getBytes("ASCII"));
+    }
+
+    public void test_enveloping_p256_sha1() throws Exception {
+        test_xmldsig11("signature-enveloping-p256_sha1", "oracle");
+    }
+
+    public void test_enveloping_p256_sha256() throws Exception {
+        test_xmldsig11("signature-enveloping-p256_sha256", "oracle");
+    }
+
+    public void test_enveloping_p256_sha384() throws Exception {
+        test_xmldsig11("signature-enveloping-p256_sha384", "oracle");
+    }
+
+    public void test_enveloping_p256_sha512() throws Exception {
+        test_xmldsig11("signature-enveloping-p256_sha512", "oracle");
+    }
+
+    public void test_enveloping_p384_sha1() throws Exception {
+        test_xmldsig11("signature-enveloping-p384_sha1", "oracle");
+    }
+
+    public void test_enveloping_p384_sha256() throws Exception {
+        test_xmldsig11("signature-enveloping-p384_sha256", "oracle");
+    }
+
+    public void test_enveloping_p384_sha384() throws Exception {
+        test_xmldsig11("signature-enveloping-p384_sha384", "oracle");
+    }
+
+    public void test_enveloping_p384_sha512() throws Exception {
+        test_xmldsig11("signature-enveloping-p384_sha512", "oracle");
+    }
+
+    public void test_enveloping_p521_sha1() throws Exception {
+        test_xmldsig11("signature-enveloping-p521_sha1", "oracle");
+    }
+
+    public void test_enveloping_p521_sha256() throws Exception {
+        test_xmldsig11("signature-enveloping-p521_sha256", "oracle");
+    }
+
+    public void test_enveloping_p521_sha384() throws Exception {
+        test_xmldsig11("signature-enveloping-p521_sha384", "oracle");
+    }
+
+    public void test_enveloping_p521_sha512() throws Exception {
+        test_xmldsig11("signature-enveloping-p521_sha512", "oracle");
+    }
+
+    public void test_enveloping_rsa_sha256() throws Exception {
+        test_xmldsig11("signature-enveloping-rsa-sha256", "oracle");
+    }
+
+    public void test_enveloping_rsa_sha384() throws Exception {
+        test_xmldsig11("signature-enveloping-rsa_sha384", "oracle");
+    }
+
+    public void test_enveloping_rsa_sha512() throws Exception {
+        test_xmldsig11("signature-enveloping-rsa_sha512", "oracle");
+    }
+
+    public void test_enveloping_sha256_rsa_sha256() throws Exception {
+        test_xmldsig11("signature-enveloping-sha256-rsa-sha256", "oracle");
+    }
+
+    public void test_enveloping_sha384_rsa_sha256() throws Exception {
+        test_xmldsig11("signature-enveloping-sha384-rsa_sha256", "oracle");
+    }
+
+    public void test_enveloping_sha512_rsa_sha256() throws Exception {
+        test_xmldsig11("signature-enveloping-sha512-rsa_sha256", "oracle");
+    }
+
+    public void test_enveloping_hmac_sha256() throws Exception {
+        test_xmldsig11("signature-enveloping-hmac-sha256", sks, "oracle");
+    }
+
+    public void test_enveloping_hmac_sha384() throws Exception {
+        test_xmldsig11("signature-enveloping-hmac-sha384", sks, "oracle");
+    }
+
+    public void test_enveloping_hmac_sha512() throws Exception {
+        test_xmldsig11("signature-enveloping-hmac-sha512", sks, "oracle");
+    }
+
+    private void test_xmldsig11(String test, String vendor) throws Exception {
+        String file = vendor + File.separator + test + ".xml";
+        System.out.println("Validating " + file);
+        boolean coreValidity = validator.validate(file, kvks);
+        assertTrue(file + " failed core validation", coreValidity);
+    }
+
+    private void test_xmldsig11(String test, KeySelector ks, String vendor) 
+        throws Exception {
+        String file = vendor + File.separator + test + ".xml";
+        System.out.println("Validating " + file);
+        boolean coreValidity = validator.validate(file, ks);
+        assertTrue(file + " failed core validation", coreValidity);
+    }
+}

Modified: xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/org/apache/xml/security/c14n/implementations/UtfHelperTest.java
URL: http://svn.apache.org/viewvc/xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/org/apache/xml/security/c14n/implementations/UtfHelperTest.java?rev=965957&r1=965956&r2=965957&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/org/apache/xml/security/c14n/implementations/UtfHelperTest.java (original)
+++ xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/org/apache/xml/security/c14n/implementations/UtfHelperTest.java Tue Jul 20 19:00:52 2010
@@ -26,7 +26,7 @@ import junit.framework.TestSuite;
 
 public class UtfHelperTest extends TestCase {
 	public void testBug40156() {
-		String s="äöü";
+		String s="\u00e4\u00f6\u00fc";
 		byte a[]=UtfHelpper.getStringInUtf8(s);
 		try {
 			byte correct[]=s.getBytes("UTF8");