harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r425315 - in /incubator/harmony/enhanced/classlib/trunk: depends/files/ modules/security/ modules/security/make/ modules/security/src/main/java/common/java/security/ modules/security/src/main/native/security/windows/ modules/security/src/te...
Date Tue, 25 Jul 2006 07:27:22 GMT
Author: mloenko
Date: Tue Jul 25 00:27:21 2006
New Revision: 425315

URL: http://svn.apache.org/viewvc?rev=425315&view=rev
Log:
enabling new crypto provider

Modified:
    incubator/harmony/enhanced/classlib/trunk/depends/files/java.security
    incubator/harmony/enhanced/classlib/trunk/modules/security/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/security/make/hyproperties.xml
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandom.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/native/security/windows/makefile
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/SecureRandom_ImplTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/depends/files/java.security
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/depends/files/java.security?rev=425315&r1=425314&r2=425315&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/depends/files/java.security (original)
+++ incubator/harmony/enhanced/classlib/trunk/depends/files/java.security Tue Jul 25 00:27:21
2006
@@ -20,10 +20,12 @@
 # Providers
 # See also: J2SE doc. "How to Implement a Provider for the JavaTM Cryptography Architecture"
 #
-# Open Source providers
+# Harmony providers
 security.provider.1=org.apache.harmony.security.provider.cert.DRLCertFactory
-security.provider.2=org.bouncycastle.jce.provider.BouncyCastleProvider
+security.provider.2=org.apache.harmony.security.provider.crypto.CryptoProvider
 security.provider.3=org.apache.harmony.xnet.provider.jsse.JSSEProvider
+# Other Open Source providers
+security.provider.4=org.bouncycastle.jce.provider.BouncyCastleProvider
 
 #
 # Class to instantiate as a default Configuration implementation

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/build.xml?rev=425315&r1=425314&r2=425315&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/build.xml Tue Jul 25 00:27:21
2006
@@ -49,31 +49,26 @@
     <target name="test" depends="build, compile.tests, run.tests" />
 
 
-	<!-- Build native code -->
-    <target name="build.native" if="${hy.security.src.main.native}/security/${hy.os}"
>
-		<exec failonerror="true" 
-              executable="${make.command}" 
-              dir="${hy.security.src.main.native}/security/${hy.os}">
-            <env key="HY_HDK" value="${hy.hdk}" />
-        </exec>
+    <!-- Build native code -->
+    <available file="${hy.security.src.main.native}/security/${hy.os}" property="native.present"
/>
 
-		<!-- Copy the built shared libs over to the jre/bin dir -->
-		<copy todir="${hy.jdk}/jre/bin" overwrite="yes">
-			<fileset dir="${hy.security.src.main.native}/security">
+
+    <target name="build.native" if="native.present" >
+	<make dir="${hy.security.src.main.native}/security/${hy.os}" />
+
+        <!-- Copy the built shared libs over to the jre/bin dir -->
+        <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
+            <fileset dir="${hy.security.src.main.native}/security">
                 <patternset includes="*${shlib.suffix}*" />
             </fileset>
         </copy>
     </target>
 	
-	<!-- Clean natives -->
-    <target name="clean.native" if="${hy.security.src.main.native}/security/${hy.os}"
>
-		<exec failonerror="true" 
-              executable="${make.command}" 
-              dir="${hy.security.src.main.native}/security/${hy.os}">
-            <env key="HY_HDK" value="${hy.hdk}" />
-		    <arg line="clean" />
-        </exec>
+    <!-- Clean natives -->
+    <target name="clean.native" if="native.present" >
+        <make dir="${hy.security.src.main.native}/security/${hy.os}" target="clean" />
     </target>
+
 
     <target name="clean">
         <delete failonerror="false">

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/make/hyproperties.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/make/hyproperties.xml?rev=425315&r1=425314&r2=425315&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/make/hyproperties.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/make/hyproperties.xml Tue Jul
25 00:27:21 2006
@@ -26,7 +26,6 @@
          <test location="src/test">
             <resources location="src/test/resources" />
          </test>
-         <natives location="src/natives" />
       </src>
       <bin>
         <main location="bin/main" />

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandom.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandom.java?rev=425315&r1=425314&r2=425315&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandom.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandom.java
Tue Jul 25 00:27:21 2006
@@ -28,6 +28,7 @@
 import org.apache.harmony.security.fortress.Engine;
 import org.apache.harmony.security.fortress.Services;
 
+import org.apache.harmony.security.provider.crypto.SHA1PRNG_SecureRandomImpl;
 
 /**
  * @com.intel.drl.spec_ref
@@ -98,8 +99,8 @@
         Provider.Service service = findService();
         if (service == null) {
             this.provider = null;
-            this.secureRandomSpi = new DummySecureRandom();
-            this.algorithm = "java.util.Random";
+            this.secureRandomSpi = new SHA1PRNG_SecureRandomImpl();
+            this.algorithm = "SHA1PRNG";
         } else {
             try {
                 this.provider = service.getProvider();
@@ -329,55 +330,4 @@
         return secureRandomSpi.engineGenerateSeed(numBytes);
     }
     
-    /**
-     * 
-     * Dummy SecureRandom based on Random
-     * 
-     */
-    private class DummySecureRandom extends SecureRandomSpi {
-        
-        Random rand;
-        
-        // Creates SecureRandomSpi object
-        public DummySecureRandom() {
-            rand = new Random();
-        }
-        
-        // Creates SecureRandomSpi object
-        public DummySecureRandom(long seed) {
-            rand = new Random(seed);
-        }
-
-        // Sets the seed of this random number generator 
-        public void engineSetSeed(byte[] seed) {
-            long l = 0;
-            int length = 8;
-            
-            if (seed.length < 8) {
-                length = seed.length;
-            }
-            for (int i = 0; i < length; i++) {
-                l = (l << 8) | (seed[i] & 0xFF);
-            }        
-            rand.setSeed(l);
-        }
-        
-        // Generates random bytes and places them into a byte array
-        public void engineNextBytes(byte[] bytes) {
-            rand.nextBytes(bytes);
-        }
-        
-        // Generates random bytes
-        //
-        // @param numBytes
-        // @return An array of random bytes
-        public byte[] engineGenerateSeed(int numBytes) {
-            if (numBytes < 1) {
-                return null;
-            }
-            byte[] next = new byte[numBytes]; 
-            nextBytes(next);
-            return next;
-        }
-    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/native/security/windows/makefile
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/native/security/windows/makefile?rev=425315&r1=425314&r2=425315&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/native/security/windows/makefile
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/native/security/windows/makefile
Tue Jul 25 00:27:21 2006
@@ -19,25 +19,16 @@
 !include <$(HY_HDK)\build\make\defines.mak>
 
 LIBBASE=hysecurity
-
-DLLNAME=$(DLLPATH)$(LIBBASE).dll
+DLLNAME=..\$(LIBBASE).dll
 LIBNAME=$(LIBPATH)$(LIBBASE).lib
-
-HYLDFLAGS = $(HYLDFLAGS) -def:$(LIBBASE).def
-HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) /I$(SHARED)common /I..\zip \
-	   /I$(SHARED)fdlibm
-
 BUILDFILES = security_copyright.obj getWindowsRandom.obj
-
 VIRTFILES = $(LIBBASE).res
+HYLDFLAGS = $(HYLDFLAGS) -def:$(LIBBASE).def
 
 SYSLIBFILES = ws2_32.lib Iphlpapi.lib
 
 MDLLIBFILES = $(LIBPATH)hycommon.lib $(LIBPATH)hypool.lib
-
-DLLBASE=0x13900000
-
+DLLBASE=0x1300000
 COMMENT=/comment:"Security component native code. (c) Copyright 2006 The Apache Software
Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>
-

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/SecureRandom_ImplTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/SecureRandom_ImplTest.java?rev=425315&r1=425314&r2=425315&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/SecureRandom_ImplTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/SecureRandom_ImplTest.java
Tue Jul 25 00:27:21 2006
@@ -25,8 +25,6 @@
 import java.security.Provider;
 import java.security.SecureRandom;
 import java.security.Security;
-import java.util.Arrays;
-import java.util.Random;
 
 import junit.framework.TestCase;
 
@@ -88,25 +86,6 @@
 	}
 
 	/*
-	 * Class under test for void SecureRandom(byte[])
-	 */
-	public final void testSecureRandombyteArray() {
-		byte[] seed = {1,2,3,4,5,6,7,8};
-		SecureRandom sr = new SecureRandom(seed);
-
-		long l = 0;
-		for (int i = 0; i < seed.length; i++) {
-			l = (l << 8) | (seed[i] & 0xFF);
-		}
-		Random r = new Random(l);
-		byte[] b1 = new byte[8];
-		byte[] b2 = new byte[8];
-		sr.nextBytes(b1);
-		r.nextBytes(b2);
-        assertTrue("incorrect random bytes", Arrays.equals(b1, b2));
-	}
-
-	/*
 	 * Class under test for SecureRandom getInstance(String)
 	 */
 	public final void testGetInstanceString() {
@@ -122,8 +101,13 @@
 	}
 	
 	public final void testGetAlgorithm() {
+        //test default implementation
 		SecureRandom sr = new SecureRandom();
-        assertEquals("Incorrect algorithm", "java.util.Random", sr.getAlgorithm());
+        assertEquals("Incorrect algorithm", "SHA1PRNG", sr.getAlgorithm());
+        assertNull("Incorrect provider", sr.getProvider());
+        
+        //just in case
+        sr.nextBytes(new byte[100]);
 	}
 	
 	/*



Mime
View raw message