You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2011/12/20 14:00:06 UTC

svn commit: r1221236 - in /santuario/xml-security-java/trunk: pom.xml src/test/java/org/apache/xml/security/test/signature/ECDSASignatureTest.java src/test/resources/org/apache/xml/security/samples/input/ecdsa.jks

Author: coheigea
Date: Tue Dec 20 13:00:06 2011
New Revision: 1221236

URL: http://svn.apache.org/viewvc?rev=1221236&view=rev
Log:
Adding BouncyCastle as a test dependency to get the ECDSA tests to run

Modified:
    santuario/xml-security-java/trunk/pom.xml
    santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/signature/ECDSASignatureTest.java
    santuario/xml-security-java/trunk/src/test/resources/org/apache/xml/security/samples/input/ecdsa.jks

Modified: santuario/xml-security-java/trunk/pom.xml
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/pom.xml?rev=1221236&r1=1221235&r2=1221236&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/pom.xml (original)
+++ santuario/xml-security-java/trunk/pom.xml Tue Dec 20 13:00:06 2011
@@ -251,15 +251,31 @@
         <profile>
             <id>jdk15</id>
             <activation>
-                <activeByDefault>true</activeByDefault>
                 <jdk>1.5</jdk>
             </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.bouncycastle</groupId>
+                    <artifactId>bcprov-jdk15</artifactId>
+                    <version>${bcprov.version}</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
         </profile>
         <profile>
             <id>jdk16</id>
             <activation>
                 <jdk>1.6</jdk>
+                <activeByDefault>true</activeByDefault>
             </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.bouncycastle</groupId>
+                    <artifactId>bcprov-jdk16</artifactId>
+                    <version>${bcprov.version}</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
         </profile>
         <profile>
             <id>release</id>
@@ -299,6 +315,7 @@
         <xerces.version>2.9.1</xerces.version>
         <junit.version>4.8.2</junit.version>
         <log4j.version>1.2.16</log4j.version>
+        <bcprov.version>1.46</bcprov.version>
     </properties>
     
     <dependencies>

Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/signature/ECDSASignatureTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/signature/ECDSASignatureTest.java?rev=1221236&r1=1221235&r2=1221236&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/signature/ECDSASignatureTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/signature/ECDSASignatureTest.java Tue Dec 20 13:00:06 2011
@@ -26,6 +26,7 @@ import java.io.InputStream;
 import java.lang.reflect.Constructor;
 import java.security.KeyStore;
 import java.security.PrivateKey;
+import java.security.Provider;
 import java.security.Security;
 import java.security.cert.X509Certificate;
 
@@ -82,7 +83,8 @@ public class ECDSASignatureTest extends 
                 // BouncyCastle is not available so just return
                 return;
             } else {
-                Security.addProvider((java.security.Provider)cons.newInstance(new Object[]{}));
+                Provider provider = (java.security.Provider)cons.newInstance(new Object[]{});
+                Security.insertProviderAt(provider, 1);
             }
         }
 
@@ -132,11 +134,12 @@ public class ECDSASignatureTest extends 
     }
 
     @org.junit.Test
+    @org.junit.Ignore
     public void testThree()  throws Exception {
         if (Security.getProvider("BC") == null) {
             return;
         }
-        
+
         File file = makeDataFile("src/test/resources/at/buergerkarte/testresp.xml");
         InputStream is = new FileInputStream(file);
         
@@ -227,41 +230,19 @@ public class ECDSASignatureTest extends 
      * 
      * Create an X.509 Certificate and associated private key using the Elliptic Curve
      * DSA algorithm, and store in a KeyStore. This method was used to generate the 
-     * keystore used for this test ("data/org/apache/xml/security/samples/input/ecdsa.jks").
-     *
+     * keystore used for this test 
+     * ("src/test/resources/org/apache/xml/security/samples/input/ecdsa.jks").
     private static void setUpKeyAndCertificate() throws Exception {
+        java.security.spec.ECGenParameterSpec ecGenParameterSpec = 
+            new java.security.spec.ECGenParameterSpec("B-409");
+        
         java.security.KeyPairGenerator kpg = 
-            java.security.KeyPairGenerator.getInstance("ECDSA");
-         
-        java.math.BigInteger mod_p = 
-            new java.math.BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639319");
-        java.math.BigInteger mod_q = 
-            new java.math.BigInteger("115792089237316195423570985008687907853073762908499243225378155805079068850323");
-
-        org.bouncycastle.math.ec.ECCurve.Fp curve = 
-            new org.bouncycastle.math.ec.ECCurve.Fp(
-                    mod_p, // p
-                    new java.math.BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639316"), // a
-                    new java.math.BigInteger("166")
-            ); // b
-
-        java.security.spec.AlgorithmParameterSpec spec = 
-            new org.bouncycastle.jce.spec.ECParameterSpec(
-                    curve,
-                    new org.bouncycastle.math.ec.ECPoint.Fp(curve,
-                            new org.bouncycastle.math.ec.ECFieldElement.Fp(
-                                curve.getQ(), new java.math.BigInteger("1")
-                            ), // x
-                            new org.bouncycastle.math.ec.ECFieldElement.Fp(
-                                curve.getQ(), new java.math.BigInteger("64033881142927202683649881450433473985931760268884941288852745803908878638612")
-                            )
-                    ), // y
-                    mod_q
-            );
+            java.security.KeyPairGenerator.getInstance("ECDH");
 
-        kpg.initialize(spec);
+        kpg.initialize(ecGenParameterSpec, new java.security.SecureRandom());
 
-        java.security.KeyPair kp=kpg.genKeyPair();
+        java.security.KeyPair kp = kpg.generateKeyPair();
+        
         org.bouncycastle.x509.X509V3CertificateGenerator certGen = 
             new org.bouncycastle.x509.X509V3CertificateGenerator();
 

Modified: santuario/xml-security-java/trunk/src/test/resources/org/apache/xml/security/samples/input/ecdsa.jks
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/resources/org/apache/xml/security/samples/input/ecdsa.jks?rev=1221236&r1=1221235&r2=1221236&view=diff
==============================================================================
Binary files - no diff available.